Webhooks: send leads to another system automatically
Send a lead to any web address the moment it arrives, changes status, is assigned or starts a workflow. Signed, so the receiving system knows it came from OpenLeads.
On this page
A webhook tells another system the moment something happens in OpenLeads. OpenLeads sends the lead (as JSON) to a web address you give it, usually within a minute. Use it to post new leads to your own software, a data warehouse, a chat tool or anything else that can receive a web request.
Where: Settings > Apps & API > Webhooks tab. Administrators of the account set them up. Webhooks are part of the API & Webhooks module on the newer plans.
What can send a webhook
| When | Narrow it down to |
|---|---|
| A new lead comes in | One form or source, and/or one starting status. Imports are left out unless you tick Imports too. |
| A lead's status changes | Only when it changes to one status. |
| A lead is assigned | Only when it is assigned to one person. |
| A workflow starts on a lead | The workflow you choose. This works however the workflow was started: by a form, by hand, by a status change or from another app. |
Add one webhook for each thing you want sent. An account can have up to 25.
Adding a webhook
- Open the Webhooks tab and click Add webhook.
- Under Send when, choose what should send it, then narrow it down if you like.
- Paste the address to send to. It must be a public https:// address (addresses on your own network, or plain http, are not allowed).
- Give it a name you will recognise, leave it On, and click Save.
- Click Send a test. OpenLeads sends a sample lead to the address and tells you what it answered.
What is sent
A POST with a JSON body: the lead's fields (the same ones the OpenLeads API returns, including custom fields, status, types, who it is assigned to and its source) plus:
| Field | Meaning |
|---|---|
event |
lead.created, lead.status_changed, lead.assigned or workflow.started |
event_id |
A unique id for this event. Use it to ignore a repeat. |
occurred_at |
When it happened (ISO 8601). |
workflow_id, workflow |
Workflow started only: which workflow. |
test |
true on the sample sent by Send a test. |
Your address should answer with any 2xx code (for example 200) within 6 seconds. Anything else counts as a failure.
Checking that it came from OpenLeads
Every request carries these headers:
| Header | Value |
|---|---|
X-OpenLeads-Event |
The event |
X-OpenLeads-Webhook |
The webhook's id |
X-OpenLeads-Timestamp |
Unix time the request was signed |
X-OpenLeads-Signature |
sha256= followed by the HMAC-SHA256 of , made with the webhook's signing secret |
Click Secret next to a webhook to see and copy its signing secret. To check a request in PHP:
$body = file_get_contents('php://input');
$ts = $_SERVER['HTTP_X_OPENLEADS_TIMESTAMP'];
$sig = 'sha256=' . hash_hmac('sha256', $ts . '.' . $body, $secret);
$ok = hash_equals($sig, $_SERVER['HTTP_X_OPENLEADS_SIGNATURE']) && abs(time() - $ts) < 300;
And in Node.js:
const crypto = require('crypto');
const ts = req.headers['x-openleads-timestamp'];
const sig = 'sha256=' + crypto.createHmac('sha256', secret).update(ts + '.' + rawBody).digest('hex');
const ok = crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(req.headers['x-openleads-signature'])) && Math.abs(Date.now() / 1000 - ts) < 300;
If a secret is ever shared by mistake, click Secret > Make a new secret. The old one stops working at once, so update your receiving system straight after.
When something goes wrong
- The Problems column shows how many sends in a row failed and the last reason (for example HTTP 500 or Could not resolve host).
- Every send, good or bad, is listed on the Activity tab with the lead it was for.
- After 50 failures in a row a webhook turns itself off so it stops filling your log. Fix the address, then edit the webhook and turn it back On.
- A webhook is not sent again after a failure. If your system was down, use the API (or the lead's own page) to fetch what it missed.
Changing or removing a webhook
Click the pencil to change what sends it, where it goes or to turn it off. Click the bin to remove it; nothing more is sent to its address.
Questions
How quickly is it sent?
Usually within a minute. OpenLeads sends webhooks in the background so a slow address never slows down your account.
Webhooks or Zapier?
Use Zapier when you want to connect an app without writing code. Use a webhook when you (or a developer) have your own system that can receive the lead.