FlowmageDocs

Start a flow from a webhook

Give a flow a webhook: a private link that starts a run each time another system sends a POST request to it, with the request as the run's input.

Steps

Open New trigger

On the flow's Triggers tab, click Add trigger, then New trigger… (shown on its own while nothing starts the flow).

The Add trigger menu: New trigger and Existing trigger

Name the webhook

Click Webhook, give it a Name such as "Orders", and click Create and add. It is now a row on the Triggers tab.

New trigger, Webhook: the name Orders and Create and add

Open Triggers and click the webhook's name. Under Link, click Copy beside Webhook link.

Under Security, click Add key and copy it: it is shown once. Without a key, anyone with the link can start the flow.

The webhook's page: its Webhook link with Copy, and under Security the Sender key with Add key

Publish the flow

In the editor, click Publish, then Put on Test. The webhook now starts the Test version. To start it on Prod, see Test and Prod.

The Publish panel: your draft with Put on Test, above Test and Prod

Send a request

POST to the link, with the key in the x-api-key header. Build the request here with your link:

curl
curl -X POST 'https://hooks.flowmage.com/hook/whu_YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data '{"name":"Anna","email":"anna@example.com"}'
JavaScript
const response = await fetch("https://hooks.flowmage.com/hook/whu_YOUR_TOKEN", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"name":"Anna","email":"anna@example.com"}),
});
console.log(response.status, await response.text());
Python
import requests

response = requests.post(
    'https://hooks.flowmage.com/hook/whu_YOUR_TOKEN',
    headers={
        'Content-Type': 'application/json',
    },
    data='{"name":"Anna","email":"anna@example.com"}'.encode(),
)
print(response.status_code, response.text)

Each request starts a run on the flow's Runs tab, with the JSON you sent in {{ trigger.body }}. With no sender yet, click Send a test on the webhook's page.

Answer the caller with the flow's result

The webhook answers at once by default. To make the caller wait for the run's answer, open the webhook's ⋯ on the flow's Triggers tab, choose Settings for this flow, turn on Answer the caller and fill in Answer with. It works only while the flow is the webhook's one flow, from the next version you publish.

If it did not work

  • The request gets 404 "Not found". The link is wrong, the flow has no version in the webhook's environment, or the key is missing or wrong. Check the link, publish, send the key.
  • A GET request gets 404. A webhook takes POST requests only.
  • trigger.body holds text, not your fields. Send content-type: application/json: only then is the request read as JSON.
  • Two requests started one run. They shared an idempotency-key header, so the second counted as a repeat. Give each request its own.
  • The run started but failed. Fix a failed run.

Next