Reference

Contacts API

Manage audiences, contacts, subscriptions, and CSV imports for marketing email.

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 audience

POST /v1/audiences (createAudience)

Creates a newsletter list. Contacts join it through a double opt-in subscription or an import.

Needs an API key with the contacts:write scope. Test keys are refused.

Headers

NameTypeRequiredNotes
Idempotency-KeystringYesAt most 128 characters.

Request body

NameTypeRequiredNotes
namestringYesA name you choose. At most 200 characters.
descriptionstring or nullNoA longer description you choose.
confirmationFromstringYesThe sender of the double opt-in confirmation email. Email address. At most 320 characters.
defaultLocalestring or nullNoThe locale used for contacts that have none.
privacyPolicyUrlstring or nullNoYour privacy policy. The hosted sign-up page links to it.
curl --request POST "https://ternwire.com/v1/audiences" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY" \
  --header "Idempotency-Key: createAudience-001" \
  --header "Content-Type: application/json" \
  --data '{
    "name": "string",
    "confirmationFrom": "ada@example.com"
  }'

List audiences

GET /v1/audiences (listAudiences)

Lists the workspace's audiences with their member counts.

Needs an API key with the contacts:read scope.

Query parameters

NameTypeRequiredNotes
cursorstringNo
limitintegerNoFrom 1 to 100. Default 25.
curl --request GET "https://ternwire.com/v1/audiences" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

Get audience

GET /v1/audiences/{audienceId} (getAudience)

Returns one audience with its member counts by subscription state.

Needs an API key with the contacts:read scope.

Path parameters

NameTypeRequiredNotes
audienceIdstringYes
curl --request GET "https://ternwire.com/v1/audiences/{audienceId}" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

Update audience

PATCH /v1/audiences/{audienceId} (updateAudience)

Changes the audience's name, sender, default locale or the text of its confirmation email.

Needs an API key with the contacts:write scope. Test keys are refused.

Path parameters

NameTypeRequiredNotes
audienceIdstringYes

Request body

NameTypeRequiredNotes
namestringNoA name you choose. At most 200 characters.
descriptionstring or nullNoA longer description you choose.
confirmationFromstringNoThe sender of the double opt-in confirmation email. Email address. At most 320 characters.
defaultLocalestring or nullNoThe locale used for contacts that have none.
privacyPolicyUrlstring or nullNoYour privacy policy. The hosted sign-up page links to it.
curl --request PATCH "https://ternwire.com/v1/audiences/{audienceId}" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "name": "string",
    "description": "string",
    "confirmationFrom": "ada@example.com"
  }'

Archive audience

POST /v1/audiences/{audienceId}/archive (archiveAudience)

Stops new subscriptions and broadcasts. Existing contacts and history stay.

Needs an API key with the contacts:write scope. Test keys are refused.

Path parameters

NameTypeRequiredNotes
audienceIdstringYes
curl --request POST "https://ternwire.com/v1/audiences/{audienceId}/archive" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

Export audience

GET /v1/audiences/{audienceId}/export (exportAudience)

Streams every member as CSV with the columns email, state, updated_at and attributes. Cells that start with a formula character are prefixed with an apostrophe.

Needs an API key with the contacts:read scope.

Path parameters

NameTypeRequiredNotes
audienceIdstringYes
curl --request GET "https://ternwire.com/v1/audiences/{audienceId}/export" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

Request subscription

POST /v1/audiences/{audienceId}/subscriptions (requestSubscription)

Records the customer's consent attestation and emails a confirmation link. The contact stays pending until the recipient confirms, so a request never subscribes anyone by itself. Until marketing sending is turned on for your organization, or while its daily warm-up allowance is used up, the confirmation email waits (status held) and goes out then.

Needs an API key with the contacts:write scope. Test keys are refused.

Path parameters

NameTypeRequiredNotes
audienceIdstringYes

Headers

NameTypeRequiredNotes
Idempotency-KeystringYesAt most 128 characters.

Request body

NameTypeRequiredNotes
emailstringYesEmail address. Email address. At most 320 characters.
attributesobjectNoCustom contact data, such as { "plan": "pro" }. Templates read it as contact.<name>, and segments filter on it.
localestringNoBCP 47 language tag such as en, sk or en-GB. At most 16 characters.
consentobjectYesHow the contact's consent was given.
curl --request POST "https://ternwire.com/v1/audiences/{audienceId}/subscriptions" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY" \
  --header "Idempotency-Key: requestSubscription-001" \
  --header "Content-Type: application/json" \
  --data '{
    "email": "ada@example.com",
    "consent": {
      "source": "string"
    }
  }'

Unsubscribe contact

DELETE /v1/audiences/{audienceId}/subscriptions/{contactId} (unsubscribeContact)

Unsubscribes the contact from the audience. An unsubscribed contact is never emailed again from this audience and cannot be resubscribed through the API.

Needs an API key with the contacts:write scope. Test keys are refused.

Path parameters

NameTypeRequiredNotes
audienceIdstringYes
contactIdstringYes
curl --request DELETE "https://ternwire.com/v1/audiences/{audienceId}/subscriptions/{contactId}" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

Upsert contact

POST /v1/contacts (upsertContact)

Creates a contact or updates the attributes of the contact with the same address. It changes no subscription.

Needs an API key with the contacts:write scope. Test keys are refused.

Request body

NameTypeRequiredNotes
emailstringYesEmail address. Email address. At most 320 characters.
attributesobjectNoCustom contact data, such as { "plan": "pro" }. Templates read it as contact.<name>, and segments filter on it.
localestring or nullNoA locale such as en or pt-BR.
curl --request POST "https://ternwire.com/v1/contacts" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "email": "ada@example.com"
  }'

List contacts

GET /v1/contacts (listContacts)

Lists contacts one page at a time, optionally only the members of one audience or one subscription state.

Needs an API key with the contacts:read scope.

Query parameters

NameTypeRequiredNotes
cursorstringNo
limitintegerNoFrom 1 to 100. Default 25.
audienceIdstringNo
statestringNoOne of pending, confirmed, unsubscribed.
emailstringNoOnly contacts whose email address contains this text, ignoring case. At most 320 characters.
curl --request GET "https://ternwire.com/v1/contacts" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

Get contact

GET /v1/contacts/{contactId} (getContact)

Returns one contact with its attributes and its subscription to each audience.

Needs an API key with the contacts:read scope.

Path parameters

NameTypeRequiredNotes
contactIdstringYes
curl --request GET "https://ternwire.com/v1/contacts/{contactId}" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

Delete contact

DELETE /v1/contacts/{contactId} (deleteContact)

Erases the contact's address and attributes. A minimal opt-out marker stays so a later import cannot resubscribe the address without new consent.

Needs an API key with the contacts:write scope. Test keys are refused.

Path parameters

NameTypeRequiredNotes
contactIdstringYes
curl --request DELETE "https://ternwire.com/v1/contacts/{contactId}" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

List contact import sources

GET /v1/contact-import-sources (listContactImportSources)

Lists the platforms whose export files an import reads directly, with how to export from each one.

Needs an API key with the contacts:read scope.

curl --request GET "https://ternwire.com/v1/contact-import-sources" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

Create contact import

POST /v1/contact-imports (createContactImport)

Validates a CSV upload, reading the columns of a known platform's export. Rows the platform marks as unsubscribed, bounced or complained become opt-outs when applied. A pending import asks every other row to confirm; a confirmed import needs per-row consent evidence and waits for operator review before it can be applied. One request holds at most 10,000 rows, so send a larger file as a batch of parts.

Needs an API key with the contacts:write scope. Test keys are refused.

Headers

NameTypeRequiredNotes
Idempotency-KeystringYesAt most 128 characters.

Request body

NameTypeRequiredNotes
audienceIdstringYesThe ID of an audience.
consentstringYesHow the contact's consent was given. One of pending, confirmed.
policyVersionstringNoThe version of your privacy or consent policy the person agreed to. At most 100 characters.
wordingstringNoThe consent wording the person agreed to. At most 2000 characters.
sourcestringNoThe platform the file came from. Omit it to detect the platform from the file's columns. One of generic, mailchimp, sendgrid, klaviyo, brevo, kit, beehiiv, activecampaign, constant_contact, mailerlite, hubspot, substack, ghost, aweber, getresponse, campaign_monitor, omnisend.
statusstringNoThe status of every row, for a file that holds one status and has no column saying so, such as a suppression export. A row keeps the stricter of this and its own status. One of subscribed, pending, unsubscribed, bounced, complained.
columnsobjectNoRenames the file's columns before they are read, from the header as written to a name such as email, first_name or a field of your own. An empty name leaves the column out. Example: {"E-Mail Adresse": "email", "Notes": ""}.
consentCapturedAtstringNoFor a confirmed import: when people in this file opted in, used for every row without its own consent_captured_at. ISO 8601 date and time.
consentSourcestringNoFor a confirmed import: how people in this file opted in, such as In my shop, used for every row without its own consent_source. At most 100 characters.
csvstringYesThe CSV file content, at most 10,000 rows. At most 5242880 characters.
batchobjectNoLinks this import to the other parts of one file. The CLI and MCP upload commands split a file and set this for you.
fileNamestringNoThe uploaded file's name, shown in the list of imports. At most 255 characters.
curl --request POST "https://ternwire.com/v1/contact-imports" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY" \
  --header "Idempotency-Key: createContactImport-001" \
  --header "Content-Type: application/json" \
  --data '{
    "audienceId": "audience_8f3c2a1b9d0e",
    "consent": "pending",
    "csv": "string"
  }'

List contact imports

GET /v1/contact-imports (listContactImports)

Lists contact imports, newest first, with their state and row counts.

Needs an API key with the contacts:read scope.

Query parameters

NameTypeRequiredNotes
cursorstringNo
limitintegerNoFrom 1 to 100. Default 25.
curl --request GET "https://ternwire.com/v1/contact-imports" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

Get contact import

GET /v1/contact-imports/{importId} (getContactImport)

Returns one import with its state, row counts and the first row errors. Check it before applying.

Needs an API key with the contacts:read scope.

Path parameters

NameTypeRequiredNotes
importIdstringYes
curl --request GET "https://ternwire.com/v1/contact-imports/{importId}" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

Apply contact import

POST /v1/contact-imports/{importId}/apply (applyContactImport)

Applies a ready import. The state is applied when it finishes in time, or applying while the worker finishes it. A part of a batch is applied through its batch.

Needs an API key with the contacts:write scope. Test keys are refused.

Path parameters

NameTypeRequiredNotes
importIdstringYes
curl --request POST "https://ternwire.com/v1/contact-imports/{importId}/apply" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

Get contact import batch

GET /v1/contact-import-batches/{batchId} (getContactImportBatch)

Reads every part of one file as a single import, with totals and the first errors.

Needs an API key with the contacts:read scope.

Path parameters

NameTypeRequiredNotes
batchIdstringYes
curl --request GET "https://ternwire.com/v1/contact-import-batches/{batchId}" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

Apply contact import batch

POST /v1/contact-import-batches/{batchId}/apply (applyContactImportBatch)

Applies every part of a file once all of them have arrived. The worker finishes a large batch in the background, so read the batch until its state is applied.

Needs an API key with the contacts:write scope. Test keys are refused.

Path parameters

NameTypeRequiredNotes
batchIdstringYes
curl --request POST "https://ternwire.com/v1/contact-import-batches/{batchId}/apply" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"