Quickstart: send a website enquiry to Worxley
A key with leads:write and the id of the campaign the enquiry belongs to are all you need.
Before you start#
- An API key with the
leads:writescope (create one). - The id of the campaign the enquiry belongs to, for
sourceCampaign.
Create the lead#
POST the enquiry to /leads with your key in the Authorization header. Send an Idempotency-Key too, such as the form submission id, so a retried request can’t create the lead twice.
curl https://crm.api.worxley.com/api/public/v1/leads \
-H "Authorization: Bearer $WORXLEY_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: form-2026-10-15-4821" \
-d '{
"name": "Asha Rao",
"email": "asha@example.com",
"phoneNumber": "+919812345678",
"source": "WEBSITE",
"sourceCampaign": "6a4c3a85c01de391daf2b7ff"
}'const res = await fetch("https://crm.api.worxley.com/api/public/v1/leads", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WORXLEY_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": formSubmissionId, // retries can't create a second lead
},
body: JSON.stringify({
name: "Asha Rao",
email: "asha@example.com",
source: "WEBSITE",
sourceCampaign: "6a4c3a85c01de391daf2b7ff",
}),
});
const { data } = await res.json();
console.log(data.lead.id);import os, requests
res = requests.post(
"https://crm.api.worxley.com/api/public/v1/leads",
headers={
"Authorization": f"Bearer {os.environ['WORXLEY_API_KEY']}",
"Idempotency-Key": form_submission_id,
},
json={
"name": "Asha Rao",
"email": "asha@example.com",
"source": "WEBSITE",
"sourceCampaign": "6a4c3a85c01de391daf2b7ff",
},
timeout=15,
)
res.raise_for_status()
print(res.json()["data"]["lead"]["id"])What happens next#
The lead appears in Worxley right away, goes through your assignment rules, and fires any lead.created webhooks.
The Idempotency-Key header means a retry after a dropped response can’t create the lead twice. See Idempotency.