API - Leads - Create or Update

Create a new lead, or update an existing one, with a POST request to the Leads endpoint.

Action Method URL API key permission Package
Create POST https://rental.software/api6/leads Leads Create: Full Access (or Leads: Full Access) WP/API
Update POST https://rental.software/api6/leads/{lead_id} Leads: Full Access WP/API

To update an existing lead, put the Lead ID in the URL, for example /api6/leads/234567, and send the fields you want to change. Any fields not sent will remain the same.

Note: updates use POST. A PUT request is refused with HTTP 405.


Request

All of the parameters below are optional except eventzip, which is required when creating a lead. This is not a complete list. Send the parameters as form fields or as a JSON body.

POST /api6/leads/?apiKey=YOUR_API_KEY {
  customerid: 533297
  locationid: 0
  eventname: Birthday Party
  eventstarttime: 1442003025
  eventendtime: 1442006025
  eventduration: 1.25
  eventstartdate_text: 7/25/2015
  eventstarttime_text: 2:00 pm
  eventenddate_text: 7/25/2015
  eventendtime_text: 4:00 pm
  eventstreet: 123 Happy St.
  eventcity: Harperville
  eventstate: OH
  eventzip: 44444
  eventcountry: United States
  taxexempt: No
  taxrate: 7.25
  salestax: 20.15
  status: Hold
  deliverytype: Drop-Off
  surface: Grass
  rental_names: Bounce House-1-125:Dora Panel-1-0|Slip & Slide-1-250
  rentals: 12345-1-125:12346-1-0|67890-1-250
  staffcost: 0
  distcharge: 0
  fee: 0
  adjust: 10.05
  coupon_code: FB Friend
  recalculate: 0
  notes: Has a rabid cat.
  additionalnotes1: test
  additionalnotes2: test2
  venuenotes: It's a park.
  venuename: Central Park
  venuecontact: Alex Kim
  guests: 100
  referral: Google Adwords
}

Parameters

Customer

Parameter Description
customerid ID of an existing customer. First create a customer record to get this ID (see API - Customers - Create or Update), OR pass the customer fields into this same call
name, firstname, lastname, organization, email, cellphone, homephone, officephone, fax, street, city, state, zip, country, customertype, custnotes, custtags, cleartags The same customer fields used by the Customers endpoint. When you do not send a customerid, we attempt to match an existing customer or create a new one from these fields

Event Date and Time

Parameter Description
eventstarttime Event start as a UNIX timestamp in seconds. Defaults to now if no time is sent
eventendtime Event end as a UNIX timestamp. Use this or eventduration
eventduration Event duration in hours, for example 1.25. Defaults to 1
eventstartdate_text, eventstarttime_text You can use these instead of eventstarttime if preferred. Send both. Send the date as MM/DD/YYYY unless your account is set as DD/MM/YYYY. Send the time with am/pm (2:00 pm) unless your account is set to use a different time format
eventenddate_text, eventendtime_text You can use these instead of eventendtime or eventduration. Send both, in the same formats as above

Delivery and Return Times

These set the delivery (setup) and return (tear down) times shown on the lead's Contract tab and used by the delivery schedule and availability checks. Send only the ones you want to change.

Add save_time_fields with the value 1 to save these fields. Without it they are ignored and not checked, so requests that already include them keep working as before.
Parameter Description
save_time_fieldsRequired to save the fields below. Send 1 (or true). Without it, the fields below are ignored
setupwindowstart, setupwindowend Delivery window as UNIX timestamps. Both must be at or before the event start, and the window must leave room for the setup duration before the event starts
tdownwindowstart, tdownwindowend Return window as UNIX timestamps. Both must be at or after the event end
setupstart Planned delivery start as a UNIX timestamp. Must leave room for the setup duration before the event start
tdownstart Planned pickup start as a UNIX timestamp. Must be at or after the event end
setupduration, tdownduration Setup and tear down time in hours, for example 1.5
ttimefrom Travel time in hours, each way
  • Send null to clear a value (0 also clears the timestamps). An empty value is ignored.
  • If a window half is blank, it is set to match the other half, the same as on the Contract tab. When moving a window that is already set, send both halves.
  • With save_time_fields sent, times that do not fit the event return an HTTP 400 error and nothing on the lead is saved.
  • If a lead is moved to a different date, its delivery and return windows are cleared unless new ones are sent in the same request.
  • The values you send are always kept. On later requests, recalculate=1 recalculates setupduration, tdownduration and ttimefrom when your account calculates them automatically. Leave recalculate at 0 or send these values again to keep them.

Event Location and Details

Parameter Description
eventzip Required when creating. The postal or zip code of the event
eventname, eventstreet, eventcity, eventstate, eventcounty, eventcountry Event name and address
venuename, venuecontact, venuenotes Venue details
deliverytype, surface Should match a delivery type and a surface set up in your account
status Name of a lead status, exactly as it is set up in your account (for example Hold). If the name does not match a status, your default new quote status is used
guests, referral Number of guests and referral source
notes, additionalnotes1, additionalnotes2 Notes saved with the lead
locationid Multi-location accounts only. The location to create the lead in. Use 0 on a single location account

Rentals

Use either rental_names or rentals to add rentals. Both use the same structure. rental_names identifies rentals and options by item name, while rentals identifies them by Rental ID.

rental_names: Item Name-Qty-Price:Option Name-Qty-Price|Next Item-Qty-Price
rentals:      12345-1-125:12346-1-0|67890-1-250
  • Dashes separate the identifier, quantity, and price.
  • Colons add options or accessories to the preceding rental.
  • Bars separate additional rentals.
  • Names sent through rental_names match without regard to upper or lower case or trailing spaces. If a name does not match an active item, the system creates a Quick Add item for it.
  • A Rental ID sent through rentals that does not belong to your account, or to the lead's location, is skipped, together with the options sent with it.
  • Only specify one of rental_names or rentals, not both. If both are sent, rental_names will be used.
  • When updating a lead, the rentals you send replace all of the rentals already on the lead. Send the complete list, not only the change.
Add strict_rentals with the value 1 to reject rentals that are not found. With it, a name that does not match an active item (no Quick Add item is created) or a Rental ID that is not found, including one sent as an option, returns an HTTP 422 error that lists them, and the lead is not saved. Use it when your integration sends names or IDs from your own catalog, so a typo is reported instead of becoming a Quick Add item.
{
  "status": 422,
  "message": "Unknown rental(s): Bounce Huose"
}

Pricing

Parameter Description
taxexempt Yes or No. Defaults to No
taxrate Tax rate as a percent, for example 7.25. Will auto-calculate if not sent
salestax Sales tax amount. Will auto-calculate if not sent
staffcost, distcharge, fee Amounts for the staff, distance and fee charges
adjust Adjustment to the lead total. 10.05 is a $10.05 discount
coupon_code Coupon code to be applied. The coupon must be set up in Settings > Promotions
recalculate Controls how prices are handled when the lead is saved. See below

recalculate accepts these values:

  • 0 (or not sent): the prices you send are kept, except fees set to auto-recalculate (in Promotions & Fees, or Distance, Staff, Surface and Delivery fees with auto-recalculate on in Optional Fields). Those are still recalculated, added if they apply, and removed if they no longer apply.
  • 1: all prices, tax and fees are recalculated, overriding any prices you send. Fees added by hand on the lead are kept.
  • 2: exactly what you send is saved and nothing is recalculated, including auto-recalculate fees. Only prices left blank are filled in.

When recalculate is 0 and you send a coupon_code, you must also send cpdiscount with the amount of the coupon discount. Otherwise it will be auto-calculated based on the promotion.

Default values specified in Settings > Optional Fields will be used if nothing is sent for that field.

Custom Fields

To fill in a lead custom field, send one parameter per field using the custom field ID:

customfield-35854: Blue balloons

You can find the IDs in the customfields_ids of a retrieved lead. See API - Leads - Retrieve Details.

You can also send custom fields in the same shapes a retrieved lead returns them. This makes it easy to read a lead, change a value, and send it back. All of these set the same field:

Parameter Keyed by Example
customfield-ID Custom field ID customfield-35854=Blue balloons
customfields[Name] Custom field name customfields[Party Theme]=Blue balloons
customfields_ids[ID] Custom field ID customfields_ids[35854]=Blue balloons
customfields_ids[ID][value] Custom field ID customfields_ids[35854][value]=Blue balloons

In a JSON body, send customfields or customfields_ids as an object:

{
  "apiKey": "YOUR_API_KEY",
  "customfields": {
    "Party Theme": "Blue balloons"
  }
}
  • The name must match the custom field name in your account exactly.
  • If the same field is sent more than one way, customfield-ID is used first, then customfields[Name], then customfields_ids[ID].
  • Names and IDs that do not match a lead custom field in your account are ignored. No error is returned for them, so retrieve the lead afterwards if you need to confirm the value was saved.
  • HTML tags are removed from the values.

Example

curl -X POST "https://rental.software/api6/leads" \
  -d "apiKey=YOUR_API_KEY" \
  -d "name=Jordan Rivera" \
  -d "email=jordan.rivera@example.com" \
  -d "eventname=Birthday Party" \
  -d "eventstartdate_text=7/25/2026" \
  -d "eventstarttime_text=2:00 pm" \
  -d "eventduration=2" \
  -d "eventzip=44444" \
  -d "rental_names=Bounce House-1-125"

Response

Status Meaning recordid contains
201 Created A new lead was created The new lead ID
200 OK The existing lead was updated The lead ID
409 Conflict The resource already exists. The same lead was already submitted within the last hour The ID of the existing (duplicate) lead
{
  "status": 201,
  "message": "Created",
  "recordid": 520248,
  "request_time": 1760000000
}

Add _body=true to the request to get the full saved lead back instead of the short response.


Errors

Status Message What to do
400 eventzip required Send eventzip when creating a lead. You can use your company's postal code if you are not gathering it from your customer
403 Permission access restricted To create leads, set Leads Create to Full Access on the API key. To update leads, set Leads to Full Access
403 Location access restricted The lead belongs to a location the key cannot access
404 Lead not found The lead ID in the URL does not exist in your account
405 Only accepts GET, POST, and DELETE requests Use POST to create or update
422 Unknown rental(s): ... Only with strict_rentals=1. The listed names or Rental IDs were not found. Correct them, or leave out strict_rentals to create Quick Add items for unknown names

Deleting a Lead

Send a DELETE request with the Lead ID in the URL. The key needs Leads Full Access.

DELETE /api6/leads/234567?apiKey=YOUR_API_KEY

Related Links

Is this article helpful?
0 0 0