Run an automation from your own code (HTTP functions)
Any active automation with a Manual or Webhook trigger can be called from your own code as an HTTP endpoint. You send a POST request with an API key, the request body becomes the automation's input, and the response is the run's result.
This turns an automation into a small backend function: your website or another system asks your app to do something, and the automation does it.
What you need
- An automation whose trigger is Manual or Webhook and whose status is Active. Automations with record or schedule triggers cannot be called this way.
- An API key with the Automations (Execute via HTTP) scope. Add Automations (Read) if you also want to list them. See Create an API key.
- The Business plan or above, which includes the API.
Find your callable automations
Open Tools, choose Data & API and open the API Keys tab. The HTTP functions section lists every automation that can be called, with a button to copy its URL.
You can also list them with the API:
```bash
curl "https://unstack.us/api/v1/functions" \
-H "X-API-Key: usk_your_api_key"
```
Run one
Call it by its id or by its exact name. If the name has spaces, URL-encode it.
```bash
curl -X POST "https://unstack.us/api/v1/functions/AUTOMATION_ID" \
-H "X-API-Key: usk_your_api_key" \
-H "Content-Type: application/json" \
-d '{"customer_email": "dana@example.com", "plan": "weekly"}'
```
The JSON body is passed to the automation, along with a source field set to http. An empty body is allowed.
The response
The request waits while the automation runs, then returns:
```json
{
"automation_id": "5e0c7a1a-...",
"name": "Send welcome pack",
"status": "completed",
"result": { }
}
```
status is completed when the run went through and failed when it did not. A failed run also returns HTTP status 502, with the details in result.
Errors
404: no active automation with a Manual or Webhook trigger matches that id or name. Check that it is activated.400with "Automation name is ambiguous": two automations share the name. Call it by id instead.403: the key lacks the Automations (Execute via HTTP) scope.
Tips
- Use the id in code. Names can be changed by anyone editing the automation, and the id cannot.
- Keep the automation short if the caller is waiting for the answer.
- Tell the assistant what the caller will send when you build the automation, for example "this will be called with customer_email and plan", so the steps use the right field names.
- Each call is one automation run and uses one run credit.
- Calls also count toward the API rate limit of 600 requests per hour.
The other way to trigger from outside
If the sender cannot set an API key header, for example a form tool that only lets you paste a URL, use a Webhook trigger and its secret URL instead. See Trigger an automation from another service.