Site · API
Send Data to Another System on Change
Last updated 18 November 2026
When a record changes, send it to another service from a background job with the api_call_send GraphQL mutation.
At the end of this guide, each time your code saves a record, Insites sends it to another service, such as a CRM, a chat tool or your own server. The call runs in a background job, so the person on your site does not wait for it.
This is a developer job. You write it in your site's code, not in an admin screen. You need the Insites CLI and a place in your code where the record is saved.
Store the other service's secret
Keep the address and the key of the other service in constants, never in your code. Set them with the Insites CLI:
insites-cli constants set --name CRM_WEBHOOK_URL --value 'https://example.com/hooks/records' devinsites-cli constants set --name CRM_WEBHOOK_KEY --value 'YOUR_SECRET' devYour code reads them as context.constants.CRM_WEBHOOK_URL and context.constants.CRM_WEBHOOK_KEY.
Write the call in a job partial
Create a partial for the background job. It builds the request and sends it with the api_call_send mutation:
app/views/partials/jobs/send_record.liquid
{% parse_json headers %}
{ "Authorization": "Bearer {{ url_key }}", "Content-Type": "application/json" }
{% endparse_json %}
{% assign body = record | json %}
{% graphql r, u: url, h: headers, b: body %}
mutation ($u: String!, $h: HashObject, $b: String) {
api_call_send(
api_call: { url: $u, method: "POST", headers: $h, body: $b }
options: { timeout: 30 }
) { response { status body } }
}
{% endgraphql %}
{% assign status = r.api_call_send.response.status | default: 0 %}
{% if status < 200 or status >= 300 %}
{% log r, type: 'send_record' %}
{% endif %}Change the headers to match what the other service expects. timeout is in seconds, from 1 to 180.
Queue the job where the record is saved
In the page or form handler that saves the record, add one line after the save. Pass in every value the job needs: a job cannot see the page's other variables.
{% background job_id = 'jobs/send_record', record: saved, url: context.constants.CRM_WEBHOOK_URL, url_key: context.constants.CRM_WEBHOOK_KEY, max_attempts: 3, source_name: 'send_record' %}Here saved is the record your code just created or updated. max_attempts can be from 1 to 5.
Warning
Do not call another service straight from a page and wait for it. A page request is cut off after about 20 seconds, and a page should not wait more than 5. A background job can wait up to 180 seconds.
Deploy and check the logs
Deploy your change, then save a record. Watch the logs while you do it:
insites-cli logs devA failed call writes an entry with the type send_record. If the other service does not answer in time, response is empty, the status reads as 0, and the logged result carries a timeout error.