Run a flow from outside
Send a request to a flow's secret link and it runs as you.
A flow whose trigger is a webhook gets a secret link. A POST to that link starts a run of the flow as you, with the request's body as the run's input. Use it to start a flow from a form, a script, or another service's webhook.
Make the link
- Open the flow in the editor and add a trigger, or select the one it has.
- Set the trigger's kind to Webhook and save the flow.
- In the trigger's settings, make the link.
The link is shown once. Copy it then and keep it like a password: anyone who has it can start the flow. Making a new link stops the old one at once. If you change the trigger to another kind and save, its link stops working.
A link has this shape:
https://app.laziness.ai/api/hooks/{token}
The run starts from that trigger, using the flow as it is saved at the moment of the request. It runs whether or not the flow's schedules are switched on.
Send a request
Send a POST with the input in its body. The body can be JSON or plain text:
- JSON is read and passed on in compact form.
- Anything else is passed on as the text that was sent.
The body may be at most 64 KiB, and at most 8,000 characters once read (JSON counted in its compact form).
curl
curl -X POST "https://app.laziness.ai/api/hooks/YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "Ana", "email": "ana@example.com", "message": "Do you ship to Spain?"}'
JavaScript
const response = await fetch("https://app.laziness.ai/api/hooks/YOUR_TOKEN", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
name: "Ana",
email: "ana@example.com",
message: "Do you ship to Spain?",
}),
});
if (response.status === 202) {
const { runId } = await response.json();
console.log("Started run", runId);
} else {
console.log("Not started:", response.status);
}
Python
import requests
response = requests.post(
"https://app.laziness.ai/api/hooks/YOUR_TOKEN",
json={
"name": "Ana",
"email": "ana@example.com",
"message": "Do you ship to Spain?",
},
timeout=30,
)
if response.status_code == 202:
print("Started run", response.json()["runId"])
else:
print("Not started:", response.status_code)
The answer
The link answers as soon as the run has started; it does not wait for the run to finish.
| Status | Meaning |
|---|---|
202 Accepted | The run started. The body is {"runId": "…"}. |
404 Not Found | The link is unknown, was replaced, or its trigger is no longer a webhook. |
409 Conflict | The saved flow has problems to fix before it can run. |
413 Content Too Large | The body is over 64 KiB, or over 8,000 characters once read. |
429 Too Many Requests | Over a link's or an address's limit, or you already have as many runs going as your plan allows. |
503 Service Unavailable | The run could not be started just now. Try again later. |
Other than the 202, answers have no body.
Limits
- Each link takes at most 10 calls a minute and 500 a day.
- Each sending address may make at most 60 calls a minute to webhook links, good or not. This is checked before the link is looked up.
- Each run counts toward your plan's limits on runs, like a run you start in the app.
A run from outside always asks
The body of a webhook request is data from outside, so a run it starts is handled with care:
- Every action its steps take (sending an email, posting, changing a record) waits for your yes, even if you turned on full access. You answer in the app, or with the buttons in Telegram, Slack, Discord, or WhatsApp if you linked one.
- Its steps read the request as outside data, under a heading that says so, never as instructions from you.
- Work it hands to other steps follows the same rule.
You see each webhook run in the flow's runs, like any other.