Skip to Content

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

  1. Open the workflow in Flow.

  2. In Search blocks..., type "Webhook Trigger" and select Webhook Trigger to add it.

  3. Set up the trigger. Every setting but Authentication can keep its default to start with.

    SettingWhat it doesDefault
    HTTP MethodsThe methods the address takes.POST
    AuthenticationHow a sender proves it may start the workflow. See Choose how senders authenticate.None
    Response ModeWhat the sender gets back. See Responses.Respond Immediately
    Custom PathA 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 PathA 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
  4. Select Save.

Test it, then publish

The trigger's Where it is reached section shows its addresses.

  1. 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.
  2. When the workflow works, select Publish. The Production address starts runs from then on, until you unpublish the workflow.
  3. Select Copy URL next to the Production address, and give it to the system that sends the requests.
Production address
https://flow-api-fra.havnsight.com/webhook/<id>

Choose how senders authenticate

Under Authentication, choose the Mode:

ModeWhat the sender doesUse it when
NoneNothing. Anyone with the address can start the workflow.The data may be public, such as a contact form.
HeaderSends the Secret in the header named in Header Name, such as X-Api-Key.The sender lets you add a header.
Basic AuthSends the Username and Password with HTTP Basic authentication.The sender only supports a user name and password.
HMAC SignatureSigns each request with the Secret.You write the sender, or it already signs this way. It's the safest mode.

Send with a header

Header mode, with X-Api-Key as the Header Name
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-Timestamp by default): the current Unix time, in seconds.
  • Signature Header (X-Signature by default): the HMAC-SHA256 of the timestamp, a full stop and the raw body (<timestamp>.<body>), made with the secret and written in hex. A sha256= 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:

The trigger's output
{
  "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 ModeThe sender gets
Respond Immediately202 Accepted as soon as the run starts, with the run's id.
When Last Node Finishes200 OK when the run ends, with how it ended and the output of each block that succeeded.
Using Respond to Webhook NodeWhat 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.

202 Accepted
{ "status": "accepted", "execution_id": "0193f6b4-1d2e-7a8b-9c0d-3e4f5a6b7c8d" }
200 OK
{
  "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:

StatusWhat it means
403 ForbiddenAuthentication failed, or the sender's origin or IP address isn't allowed.
404 Not FoundThe workflow isn't published, the test URL has expired, or the id is unknown.
405 Method Not AllowedThe method isn't one of the trigger's HTTP Methods.
413 Payload Too LargeThe body is larger than Max Body Size (bytes).
415 Unsupported Media TypeA multipart body was sent to an address with HMAC Signature. Send one signed body instead.
429 Too Many RequestsToo many requests came from the sender's address. Wait a moment, then send again.
5xxSomething 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.

Was this page helpful?

Send feedback

On this page