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

NameTypeRequiredNotes
Idempotency-KeystringYesAt most 128 characters.

Request body

NameTypeRequiredNotes
audienceIdstringYesThe ID of an audience.
namestringYesA name you choose. At most 200 characters.
fromstringYesSender address, optionally with a display name: Acme <hello@acme.com>. Email address. At most 320 characters.
replyTostring or nullNoThe address replies go to, when it is not the sender.
triggerobjectYesWhat enrolls a contact.
segmentobject or nullNoContacts must match it when they enter. Leave it out to enroll every member.
stepsobject[]YesThe steps run in order for each enrolled contact. At most 20 items.
reentrystringNoonce 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

NameTypeRequiredNotes
cursorstringNo
limitintegerNoFrom 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

NameTypeRequiredNotes
automationIdstringYes
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

NameTypeRequiredNotes
automationIdstringYes

Request body

NameTypeRequiredNotes
audienceIdstringNoThe ID of an audience.
namestringNoA name you choose. At most 200 characters.
fromstringNoSender address, optionally with a display name: Acme <hello@acme.com>. Email address. At most 320 characters.
replyTostring or nullNoThe address replies go to, when it is not the sender.
triggerobjectNoWhat enrolls a contact.
segmentobject or nullNoContacts must match it when they enter. Leave it out to enroll every member.
stepsobject[]NoThe steps run in order for each enrolled contact. At most 20 items.
reentrystringNoWhether 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

NameTypeRequiredNotes
automationIdstringYes
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

NameTypeRequiredNotes
automationIdstringYes
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

NameTypeRequiredNotes
automationIdstringYes
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

NameTypeRequiredNotes
automationIdstringYes
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

NameTypeRequiredNotes
automationIdstringYes

Query parameters

NameTypeRequiredNotes
cursorstringNo
limitintegerNoFrom 1 to 100. Default 25.
statestringNoOne of active, completed, exited, failed.
contactIdstringNo
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

NameTypeRequiredNotes
automationIdstringYes

Headers

NameTypeRequiredNotes
Idempotency-KeystringYesAt most 128 characters.

Request body

NameTypeRequiredNotes
tostring[]YesRecipient addresses. At most 5 items.
stepintegerYesZero-based index of a send_email step. From 0 to 19.
localestringNoBCP 47 language tag such as en, sk or en-GB. At most 16 characters.
eventobjectNoSample 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

NameTypeRequiredNotes
Idempotency-KeystringYesAt most 128 characters.

Request body

NameTypeRequiredNotes
contactIdstringNoThe ID of a contact.
emailstringNoEmail address. Email address. At most 320 characters.
namestringYesA name you choose. At most 100 characters.
propertiesobjectNoTemplates 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"
  }'