Skip to main content
Courier provides two ways to trigger an automation programmatically: invoke a saved automation by ID, or define one inline (ad-hoc). Most use cases start with a saved automation built in the Designer; ad-hoc is useful when the workflow itself needs to change per request.

Prerequisites

Saved vs Ad-Hoc Automations

Saved AutomationAd-Hoc Automation
DefinitionBuilt and published in the Automations DesignerDefined inline in the API request
EndpointPOST /automations/:automationId/invokePOST /automations/invoke
Best forReusable workflows triggered by events or API callsDynamic workflows where steps change per request
Visual editorYes; build visually, test with debugger, then invoke via APINo

Invoke a Saved Automation

When you’ve built an automation in the Automations Designer and published it, invoke it by its ID. The automation defines the steps; you provide the runtime data.
1

Find the automation ID

Open your automation in the Designer. You can find the ID in two places:
  • The Invoke tab, which generates a ready-to-use curl command with the ID filled in
  • The URL bar: app.courier.com/automations/:automationId
You can also use an alias if you configured one in Automation Settings.
2

Invoke with runtime data

curl -X POST https://api.courier.com/automations/AUTOMATION_ID/invoke \
  -H "Authorization: Bearer $COURIER_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "recipient": "user_123",
    "data": {
      "order_id": "ORD-9042"
    },
    "profile": {
      "email": "jane@example.com"
    }
  }'
The data and profile objects become the automation’s run context, accessible in every node via refs.data.* and refs.profile.*.
3

Verify in the debugger

The response includes a runId. Open the Automations Debugger and search for it to see each step’s status and any errors.
New to building automations? Follow Build and Send Your First Automation to create one in the visual designer before invoking it here.

Invoke an Ad-Hoc Automation

Define the full workflow inline. This is useful when the steps or recipients need to change per request and you don’t want to create a saved automation for every variation.
1

Define the workflow and invoke

curl -X POST https://api.courier.com/automations/invoke \
  -H "Authorization: Bearer $COURIER_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "automation": {
      "steps": [
        {
          "action": "send",
          "template": "ORDER_CONFIRMATION"
        },
        {
          "action": "delay",
          "duration": "2 hours"
        },
        {
          "action": "send",
          "template": "SHIPPING_UPDATE"
        }
      ]
    },
    "recipient": "user_123",
    "data": {
      "order_id": "ORD-9042",
      "item_name": "Wireless Headphones"
    }
  }'
The response includes a runId you can use to track the automation in the Automations Debugger.
The template field inside each send step refers to a notification template (the content you design in the Template Designer), not an automation. This is the one place where “template” appears in the automations API.

What’s Next