Inbound Webhooks: Start an Automation from Another System
Inbound Webhooks in Mahadata let an external system (such as an e-commerce store, CRM, or payment service) send an HTTP POST JSON request to a dedicated endpoint URL to:
- Start an automation via the Inbound Webhook trigger.
- Resume an automation run paused at a Wait for webhook step.
You can view your full endpoint URL in the portal under Developer › Inbound webhooks. If the page shows a note to contact our team instead of a URL, ask our team for your endpoint URL. The URL has the form:
https://<your-webhook-host>/api/v1/hooks/<account_id>/<slug>Setup Steps
Section titled “Setup Steps”-
Create an inbound webhook endpoint
Open Developer › Inbound webhooks and click Create endpoint. Enter a Name, Slug, choose an Authentication method (HMAC-SHA256 signature (recommended)), and save your Secret.
-
Connect it to an automation trigger
Open Automation Builder › Triggers, create or edit a trigger of type Inbound Webhook, select the endpoint you created, and set Contact phone JSON path (default
$.phone). -
Activate the automation
Make sure the linked automation is active so incoming requests can start runs.
Request Format
Section titled “Request Format”- Method:
POST - Header:
Content-Type: application/json - Body: valid JSON object
- Maximum body size: 1 MB (1,048,576 bytes)
Authentication
Section titled “Authentication”Choose an authentication method when creating the endpoint in Developer › Inbound webhooks (we recommend HMAC-SHA256):
| Method | Header / Verification | Notes |
|---|---|---|
| HMAC-SHA256 (recommended) | X-Signature header (or the configured custom header name). Value is lowercase hex HMAC-SHA256 of the exact raw body (optional sha256= prefix). | Sign the exact bytes you send. |
| Bearer token | Authorization: Bearer <secret> | Exact secret match. |
| None | No authentication header required | Only for testing or private URLs. |
Request Examples (HMAC-SHA256)
Section titled “Request Examples (HMAC-SHA256)”curl + OpenSSL
BODY='{"phone":"6281234567890","order_id":"INV-1001","status":"paid"}'SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" | sed 's/^.* //')curl -X POST 'https://<your-webhook-host>/api/v1/hooks/<account_id>/<slug>' \ -H 'Content-Type: application/json' \ -H "X-Signature: sha256=$SIG" \ -d "$BODY"Node.js
import crypto from 'node:crypto';
const body = JSON.stringify({ phone: '6281234567890', order_id: 'INV-1001', status: 'paid',});const sig = crypto .createHmac('sha256', process.env.WEBHOOK_SECRET) .update(body) .digest('hex');
await fetch('https://<your-webhook-host>/api/v1/hooks/<account_id>/<slug>', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Signature': `sha256=${sig}`, }, body,});Python
import hashlibimport hmacimport osimport requests
body = b'{"phone":"6281234567890","order_id":"INV-1001","status":"paid"}'sig = hmac.new( os.environ["WEBHOOK_SECRET"].encode(), body, hashlib.sha256,).hexdigest()
requests.post( "https://<your-webhook-host>/api/v1/hooks/<account_id>/<slug>", data=body, headers={ "Content-Type": "application/json", "X-Signature": f"sha256={sig}", },)Contact Matching
Section titled “Contact Matching”- The phone number is read from Contact phone JSON path (default
$.phone, dot path such as$.customer.phone). - Matching compares digits only (e.g.,
6281234567890). - The contact must already exist in Mahadata and have a conversation. Otherwise the request is still accepted (
202) withstarted: 0and a reason.
Variables in Flows
Section titled “Variables in Flows”The JSON payload and request headers are exposed as flow variables:
| Variable | Source | Notes |
|---|---|---|
{{webhook.<field>}} | Top-level JSON body | Example: {{webhook.order_id}}, {{webhook.status}}. |
{{webhook.customer.name}} | Nested objects | Up to 3 levels deep; deeper objects are stored as JSON text. |
{{webhook.items}} | Arrays, numbers, booleans | Stored as JSON text / text. |
{{webhook.headers.<lowercase>}} | HTTP request headers | authorization and the HMAC signature header are removed when a run is started. |
{{webhook.endpoint_id}} | Endpoint metadata | ID of the inbound webhook endpoint that received the request. |
{{trigger.kind}} | Trigger metadata | Value is webhook. |
HTTP Responses
Section titled “HTTP Responses”| Status | Example Body | Meaning |
|---|---|---|
202 Accepted | {"started":1,"reason":null} | Trigger matched and automation run was queued. |
202 Accepted | {"started":0,"reason":"contact_not_found"} | No contact found for the extracted phone number. |
202 Accepted | {"started":0,"reason":"contact_has_no_conversation"} | Contact exists but has no conversation. |
202 Accepted | {"status":"captured","run_id":"…"} | Resumed a run waiting at a Wait for webhook step. |
204 No Content | (empty) | No waiting run and no active trigger on this endpoint. |
400 Bad Request | {"error":"invalid JSON: …"} | Invalid JSON body, or correlation ID extraction failed with no active trigger. |
401 Unauthorized | {"error":"authentication failed"} | Bearer or HMAC authentication failed. |
404 Not Found | {"error":"webhook endpoint not found"} | Endpoint not found or inactive. |
413 Payload Too Large | {"error":"payload exceeds 1 MB limit"} | Body exceeds 1 MB. |
5xx | — | Temporary error; retry with backoff. |
started counts the runs queued; automation rules (such as once per contact) can still stop a run.
Resuming a Waiting Run
Section titled “Resuming a Waiting Run”To resume a Wait for webhook step, configure Correlation ID source on the endpoint (default $.correlation_id, supporting $.field from the JSON body or header.X-Name from HTTP headers). Matching is per account and one-shot.
Processing order for each incoming request: waiting runs are checked first; if none match, active automation triggers are started.
After a run resumes, {{webhook.*}} holds the new request’s data, {{webhook.status}} is captured (it overrides a body field named status), and {{webhook_status}} is received. If no request arrives before the Wait for webhook timeout, the run continues with {{webhook_status}} set to timeout.
Retries & Idempotency
Section titled “Retries & Idempotency”- No automatic deduplication: every accepted
POSTstarts a new run. - Do not retry
2xxresponses (202or204). - Retry only on
5xxor network errors with exponential backoff. - HMAC-SHA256 signatures do not include a timestamp, so keep your secret private and rotate it by editing the endpoint in Developer › Inbound webhooks.
Limits
Section titled “Limits”- Maximum 50 endpoints per account.
- Maximum body size 1 MB.
- Slug must match
^[a-z0-9][a-z0-9-]{0,63}$(lowercase letters, numbers, and hyphens, max 64 characters). - No fixed request-rate limit is published for this route; keep request rates reasonable.