Webhooks
Send an HTTP request to another system when a Record changes.
A Webhook calls a URL when a Record of one RecType hits an event, such as a save or a submit. Only a System Manager creates webhooks, at /desk/webhook/new.
The request goes out after the save commits. If the save rolls back, nothing is sent.
Example: post submitted orders to a warehouse system
| Field | Value |
|---|---|
| RecType | Sales Order |
| Doc Event | on_submit |
| Condition | doc.grand_total > 40000 |
| Request URL | https://wms.acme.com/hooks/orders |
| Request Method | POST |
| Request Structure | JSON |
| Enable Security | ticked, with a Webhook Secret |
JSON Request Body:
{ "order": "{{ doc.name }}", "customer": "{{ doc.customer }}", "total": "{{ doc.grand_total }}" }Events
| Doc Event | Fires after |
|---|---|
after_insert | A new Record is saved |
on_update | Any save |
on_submit | Submit |
on_cancel | Cancel |
on_trash | Delete |
on_update_after_submit | A change to a submitted Record |
on_change | Any change, including docstatus moves |
RecType and Doc Event cannot change after the first save.
Request
| Field | Use |
|---|---|
| Condition | An expression. Empty sends on every event |
| Request URL | http or https. Private, loopback and link-local addresses are refused |
| Is Dynamic URL? | Render the URL as a Jinja template, such as https://crm.acme.com/orders/{{ doc.name }} |
| Request Timeout | Seconds, 1 to 30. 5 by default |
| Request Structure | Form URL-Encoded uses the Data table. JSON uses the JSON template. Both send a JSON body |
| Headers | Extra headers, such as Authorization |
| Data | Rows of a key and the Record field it takes |
Signatures
With Enable Security on, each request carries:
X-Cardinal-Signature: t=1795000000,v1=<hex HMAC-SHA256 of "<t>.<body>">The receiver recomputes the HMAC with the shared secret over the timestamp, a dot and the raw body, and compares.
Retries and logs
A request that fails or gets a non-2xx answer is tried 3 times in all, after 5 and 20 seconds. Each attempt writes a Webhook Request Log with the URL, headers, body, status and response. Logs are kept 30 days.
Disabling or deleting the webhook stops pending retries.
For several steps, branches or waits, use an automation. Its Call webhook step sends a saved Webhook's request.