Reference
Automations API
Create and run automations, and send the contact events that start them.
On this page
Every request needs Authorization: Bearer with an API key. Errors use the shapes and codes in Errors and retry decisions. The OpenAPI document has the full schemas.
Create automation
POST /v1/automations (createAutomation)
Creates a draft automation: a trigger, an optional entry segment and 1 to 20 steps run in order. It enrolls nobody until activated.
Needs an API key with the automations:write scope. Test keys are refused.
Headers
| Name | Type | Required | Notes |
|---|---|---|---|
Idempotency-Key | string | Yes | At most 128 characters. |
Request body
| Name | Type | Required | Notes |
|---|---|---|---|
audienceId | string | Yes | The ID of an audience. |
name | string | Yes | A name you choose. At most 200 characters. |
from | string | Yes | Sender address, optionally with a display name: Acme <hello@acme.com>. Email address. At most 320 characters. |
replyTo | string or null | No | The address replies go to, when it is not the sender. |
trigger | object | Yes | What enrolls a contact. |
segment | object or null | No | Contacts must match it when they enter. Leave it out to enroll every member. |
steps | object[] | Yes | The steps run in order for each enrolled contact. At most 20 items. |
reentry | string | No | once enrolls a contact at most one time. always enrolls again on each trigger after the previous enrollment finished. One of once, always. Default "once". |
curl --request POST "https://ternwire.com/v1/automations" \
--header "Authorization: Bearer $TERNWIRE_API_KEY" \
--header "Idempotency-Key: createAutomation-001" \
--header "Content-Type: application/json" \
--data '{
"audienceId": "audience_8f3c2a1b9d0e",
"name": "string",
"from": "ada@example.com",
"trigger": {
"type": "contact_subscribed"
},
"steps": [
{
"type": "send_email",
"templateId": "template_8f3c2a1b9d0e"
}
]
}'List automations
GET /v1/automations (listAutomations)
Lists automations, newest first, with their state and trigger.
Needs an API key with the automations:read scope.
Query parameters
| Name | Type | Required | Notes |
|---|---|---|---|
cursor | string | No | |
limit | integer | No | From 1 to 100. Default 25. |
curl --request GET "https://ternwire.com/v1/automations" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"Get automation
GET /v1/automations/{automationId} (getAutomation)
Returns one automation with its trigger, entry segment and steps.
Needs an API key with the automations:read scope.
Path parameters
| Name | Type | Required | Notes |
|---|---|---|---|
automationId | string | Yes |
curl --request GET "https://ternwire.com/v1/automations/{automationId}" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"Update automation
PATCH /v1/automations/{automationId} (updateAutomation)
Edits a draft or paused automation. The audience can change only while it is a draft. Running enrollments keep the version they entered with.
Needs an API key with the automations:write scope. Test keys are refused.
Path parameters
| Name | Type | Required | Notes |
|---|---|---|---|
automationId | string | Yes |
Request body
| Name | Type | Required | Notes |
|---|---|---|---|
audienceId | string | No | The ID of an audience. |
name | string | No | A name you choose. At most 200 characters. |
from | string | No | Sender address, optionally with a display name: Acme <hello@acme.com>. Email address. At most 320 characters. |
replyTo | string or null | No | The address replies go to, when it is not the sender. |
trigger | object | No | What enrolls a contact. |
segment | object or null | No | Contacts must match it when they enter. Leave it out to enroll every member. |
steps | object[] | No | The steps run in order for each enrolled contact. At most 20 items. |
reentry | string | No | Whether a contact can be enrolled again after finishing. One of once, always. |
curl --request PATCH "https://ternwire.com/v1/automations/{automationId}" \
--header "Authorization: Bearer $TERNWIRE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"audienceId": "audience_8f3c2a1b9d0e",
"name": "string",
"from": "ada@example.com"
}'Activate automation
POST /v1/automations/{automationId}/activate (activateAutomation)
Freezes the steps as a new version when they changed and starts enrolling contacts. Activating an active automation returns it unchanged.
Needs an API key with the automations:write scope. Test keys are refused.
Path parameters
| Name | Type | Required | Notes |
|---|---|---|---|
automationId | string | Yes |
curl --request POST "https://ternwire.com/v1/automations/{automationId}/activate" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"Pause automation
POST /v1/automations/{automationId}/pause (pauseAutomation)
Stops enrolling contacts and holds every active enrollment at its current step until the automation is activated again.
Needs an API key with the automations:write scope. Test keys are refused.
Path parameters
| Name | Type | Required | Notes |
|---|---|---|---|
automationId | string | Yes |
curl --request POST "https://ternwire.com/v1/automations/{automationId}/pause" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"Archive automation
POST /v1/automations/{automationId}/archive (archiveAutomation)
Ends the automation for good. Every active enrollment exits with reason archived. Copies already accepted are still delivered.
Needs an API key with the automations:write scope. Test keys are refused.
Path parameters
| Name | Type | Required | Notes |
|---|---|---|---|
automationId | string | Yes |
curl --request POST "https://ternwire.com/v1/automations/{automationId}/archive" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"Get automation stats
GET /v1/automations/{automationId}/stats (getAutomationStats)
Enrollment counts by state and exit reason, and sends, unique opens and unique clicks for each step of the current version. Opens are an estimate because privacy proxies load images.
Needs an API key with the automations:read scope.
Path parameters
| Name | Type | Required | Notes |
|---|---|---|---|
automationId | string | Yes |
curl --request GET "https://ternwire.com/v1/automations/{automationId}/stats" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"List automation enrollments
GET /v1/automations/{automationId}/enrollments (listAutomationEnrollments)
Lists the contacts enrolled in the automation, with the step each one is at or why it exited, one page at a time.
Needs an API key with the automations:read scope.
Path parameters
| Name | Type | Required | Notes |
|---|---|---|---|
automationId | string | Yes |
Query parameters
| Name | Type | Required | Notes |
|---|---|---|---|
cursor | string | No | |
limit | integer | No | From 1 to 100. Default 25. |
state | string | No | One of active, completed, exited, failed. |
contactId | string | No |
curl --request GET "https://ternwire.com/v1/automations/{automationId}/enrollments" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"Send automation test
POST /v1/automations/{automationId}/test (sendAutomationTest)
Sends one send_email step as a test copy to up to 5 verified members of the organization. The copy renders with the recipient address as contact.email and the sample event properties from the request, and enrolls nobody.
Needs an API key with the automations:write scope. Test keys are refused.
Path parameters
| Name | Type | Required | Notes |
|---|---|---|---|
automationId | string | Yes |
Headers
| Name | Type | Required | Notes |
|---|---|---|---|
Idempotency-Key | string | Yes | At most 128 characters. |
Request body
| Name | Type | Required | Notes |
|---|---|---|---|
to | string[] | Yes | Recipient addresses. At most 5 items. |
step | integer | Yes | Zero-based index of a send_email step. From 0 to 19. |
locale | string | No | BCP 47 language tag such as en, sk or en-GB. At most 16 characters. |
event | object | No | Sample event properties for a template that reads event.*. |
curl --request POST "https://ternwire.com/v1/automations/{automationId}/test" \
--header "Authorization: Bearer $TERNWIRE_API_KEY" \
--header "Idempotency-Key: sendAutomationTest-001" \
--header "Content-Type: application/json" \
--data '{
"to": [
"ada@example.com"
],
"step": 0
}'Create contact event
POST /v1/events (createContactEvent)
Records a named event for a contact, by id or email, and enrolls the contact in every active automation triggered by that name where the contact is a confirmed member. The Idempotency-Key is required: repeating it with the same body returns the first result and enrolls nobody again, and reusing it with a different body is a conflict. Use one key per real occurrence, such as the order id.
Needs an API key with the events:write scope. Test keys are refused.
Headers
| Name | Type | Required | Notes |
|---|---|---|---|
Idempotency-Key | string | Yes | At most 128 characters. |
Request body
| Name | Type | Required | Notes |
|---|---|---|---|
contactId | string | No | The ID of a contact. |
email | string | No | Email address. Email address. At most 320 characters. |
name | string | Yes | A name you choose. At most 100 characters. |
properties | object | No | Templates in the enrolled sequence read these as event.*. |
curl --request POST "https://ternwire.com/v1/events" \
--header "Authorization: Bearer $TERNWIRE_API_KEY" \
--header "Idempotency-Key: createContactEvent-001" \
--header "Content-Type: application/json" \
--data '{
"name": "string"
}'