Start a workflow with a webhook
Give a Flow workflow its own web address, and start a run each time a request arrives.
Applies to: Flow
A workflow that starts with a Webhook Trigger has its own web address. Each request sent to it starts a run, and the workflow's next blocks can use the request's method, headers, query and body.
Add the trigger
-
Open the workflow in Flow.
-
In Search blocks..., type "Webhook Trigger" and select Webhook Trigger to add it.
-
Set up the trigger. Every setting but Authentication can keep its default to start with.
Setting What it does Default HTTP Methods The methods the address takes. POSTAuthentication How a sender proves it may start the workflow. See Choose how senders authenticate. None Response Mode What the sender gets back. See Responses. Respond Immediately Custom Path A readable path for the address, such as orders/paid, instead of its id.None Allowed Origins (CORS) The websites whose pages may call the address from a browser. None IP Allow List (CIDR) The only addresses requests are taken from, such as 203.0.113.0/24.Any Deduplication Key Path A JSON path into the body, such as /order_id. A request whose value was seen before is dropped, so a sender's retry doesn't start a second run.None Max Body Size (bytes) The largest request body taken. 16 MB -
Select Save.
Test it, then publish
The trigger's Where it is reached section shows its addresses.
- Select Create a test URL, and then send a request to the Test address within two minutes. Check the run to see what the next blocks receive.
- When the workflow works, select Publish. The Production address starts runs from then on, until you unpublish the workflow.
- Select Copy URL next to the Production address, and give it to the system that sends the requests.
https://flow-api-fra.havnsight.com/webhook/<id>Choose how senders authenticate
Under Authentication, choose the Mode:
| Mode | What the sender does | Use it when |
|---|---|---|
| None | Nothing. Anyone with the address can start the workflow. | The data may be public, such as a contact form. |
| Header | Sends the Secret in the header named in Header Name, such as X-Api-Key. | The sender lets you add a header. |
| Basic Auth | Sends the Username and Password with HTTP Basic authentication. | The sender only supports a user name and password. |
| HMAC Signature | Signs each request with the Secret. | You write the sender, or it already signs this way. It's the safest mode. |
Send with a header
curl https://flow-api-fra.havnsight.com/webhook/<id> \
-H "X-Api-Key: $FLOW_SECRET" \
-H "Content-Type: application/json" \
-d '{ "order_id": "SO-10427", "status": "paid", "amount": 249.00, "currency": "EUR" }'Sign with HMAC
With HMAC Signature, each request carries two headers:
- Timestamp Header (
X-Timestampby default): the current Unix time, in seconds. - Signature Header (
X-Signatureby default): the HMAC-SHA256 of the timestamp, a full stop and the raw body (<timestamp>.<body>), made with the secret and written in hex. Asha256=prefix is allowed.
A request more than five minutes old, or one whose signature was used before, is refused.
BODY='{"order_id":"SO-10427","status":"paid","amount":249.00,"currency":"EUR"}'
TIMESTAMP=$(date +%s)
SIGNATURE=$(printf '%s.%s' "$TIMESTAMP" "$BODY" | openssl dgst -sha256 -hmac "$FLOW_SECRET" | sed 's/^.* //')
curl https://flow-api-fra.havnsight.com/webhook/<id> \
-H "X-Timestamp: $TIMESTAMP" \
-H "X-Signature: $SIGNATURE" \
-H "Content-Type: application/json" \
-d "$BODY"Important
Sign the exact bytes you send. If your code builds the body again after signing it, even with different spacing, the signature no longer matches.
What the workflow receives
The trigger passes the request on to the next blocks. The Authorization header and the Header mode's secret
header are replaced with [redacted], so those secrets never show in a run:
{
"method": "POST",
"headers": { "content-type": "application/json", "x-api-key": "[redacted]" },
"query": {},
"params": {},
"body": { "order_id": "SO-10427", "status": "paid", "amount": 249.0, "currency": "EUR" }
}Responses
The Response Mode sets what the sender gets back:
| Response Mode | The sender gets |
|---|---|
| Respond Immediately | 202 Accepted as soon as the run starts, with the run's id. |
| When Last Node Finishes | 200 OK when the run ends, with how it ended and the output of each block that succeeded. |
| Using Respond to Webhook Node | What a Respond to Webhook block in the workflow sends. |
| Streaming (as the Run Goes) | The result as the run produces it. |
With When Last Node Finishes and Using Respond to Webhook Node, the sender waits up to 30 seconds. If the run
isn't done by then, it keeps going, and the sender gets the 202 Accepted answer instead.
{ "status": "accepted", "execution_id": "0193f6b4-1d2e-7a8b-9c0d-3e4f5a6b7c8d" }{
"status": "succeeded",
"execution_id": "0193f6b4-1d2e-7a8b-9c0d-3e4f5a6b7c8d",
"outputs": { "<block id>": { "order_id": "SO-10427" } }
}A request that isn't taken gets one of these:
| Status | What it means |
|---|---|
403 Forbidden | Authentication failed, or the sender's origin or IP address isn't allowed. |
404 Not Found | The workflow isn't published, the test URL has expired, or the id is unknown. |
405 Method Not Allowed | The method isn't one of the trigger's HTTP Methods. |
413 Payload Too Large | The body is larger than Max Body Size (bytes). |
415 Unsupported Media Type | A multipart body was sent to an address with HMAC Signature. Send one signed body instead. |
429 Too Many Requests | Too many requests came from the sender's address. Wait a moment, then send again. |
5xx | Something went wrong on our side. Send the request again after a short wait. |
Every run shows in the workflow's runs. See Run a workflow and see its runs.
Related content
Was this page helpful?
Send feedback
