Skip to content
Support

Push leads from your website into Skeduler

Owner, AdminLast checked 25 November 20263 min readArticle ID: developers-push-leads
On this page

Send a web form to your own server, then create the contact and a job through the API.

Your website's form posts to your own server, and your server calls the API. Never call the API from the browser: that would put your client secret in the page. See Keep your client secret safe.

Who can do this: Owners and Admins with the Manage Developer Tools permission.

Your app needs read:contacts, write:contacts and write:jobs. In the examples, $SKEDULER_API is your Skeduler API address. Contact Skeduler support if you don't have it. In the JavaScript and PHP tabs, the same names in capitals (SKEDULER_API, ACCESS_TOKEN and so on) are variables you set.

For a no-code route, see Turn web form leads into contacts and jobs.

On each submission

  1. Look for an existing contact by email, so you don't create a duplicate:

    curl

    curl -s "$SKEDULER_API/api/v1/contacts?email=$EMAIL" -H "Authorization: Bearer $ACCESS_TOKEN"
    
  2. Create one if there's none, with an Idempotency-Key built from the form submission's own id:

    curl

    curl -s -X POST "$SKEDULER_API/api/v1/contacts" \
      -H "Authorization: Bearer $ACCESS_TOKEN" \
      -H "Idempotency-Key: lead-$SUBMISSION_ID-contact" -H "Content-Type: application/json" \
      -d '{"first_name":"Sam","last_name":"Rivera","email":"sam@example.com","mobile_phone":"0400 000 000"}'
    
  3. Create the job, with the form's message as the description:

    curl

    curl -s -X POST "$SKEDULER_API/api/v1/jobs" \
      -H "Authorization: Bearer $ACCESS_TOKEN" \
      -H "Idempotency-Key: lead-$SUBMISSION_ID-job" -H "Content-Type: application/json" \
      -d '{"title":"Website enquiry","description":"<what they wrote>","customer_id":"<contact id>"}'
    

To record where the lead came from, pass a lead_source_id taken from GET /job-lookups.

Why the keys matter

If a visitor double-clicks, or your server retries after a timeout, the same key returns the first answer instead of creating a second contact or job. Keep the same key for the same submission, and the answers are stored for 24 hours. See Safe retries.

In this section