Reference
Contacts API
Manage audiences, contacts, subscriptions, and CSV imports for marketing email.
On this page
- Create audience
- List audiences
- Get audience
- Update audience
- Archive audience
- Export audience
- Request subscription
- Unsubscribe contact
- Upsert contact
- List contacts
- Get contact
- Delete contact
- List contact import sources
- Create contact import
- List contact imports
- Get contact import
- Apply contact import
- Get contact import batch
- Apply contact import batch
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
| Name | Type | Required | Notes |
|---|---|---|---|
Idempotency-Key | string | Yes | At most 128 characters. |
Request body
| Name | Type | Required | Notes |
|---|---|---|---|
name | string | Yes | A name you choose. At most 200 characters. |
description | string or null | No | A longer description you choose. |
confirmationFrom | string | Yes | The sender of the double opt-in confirmation email. Email address. At most 320 characters. |
defaultLocale | string or null | No | The locale used for contacts that have none. |
privacyPolicyUrl | string or null | No | Your 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
| Name | Type | Required | Notes |
|---|---|---|---|
cursor | string | No | |
limit | integer | No | From 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
| Name | Type | Required | Notes |
|---|---|---|---|
audienceId | string | Yes |
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
| Name | Type | Required | Notes |
|---|---|---|---|
audienceId | string | Yes |
Request body
| Name | Type | Required | Notes |
|---|---|---|---|
name | string | No | A name you choose. At most 200 characters. |
description | string or null | No | A longer description you choose. |
confirmationFrom | string | No | The sender of the double opt-in confirmation email. Email address. At most 320 characters. |
defaultLocale | string or null | No | The locale used for contacts that have none. |
privacyPolicyUrl | string or null | No | Your 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
| Name | Type | Required | Notes |
|---|---|---|---|
audienceId | string | Yes |
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
| Name | Type | Required | Notes |
|---|---|---|---|
audienceId | string | Yes |
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
| Name | Type | Required | Notes |
|---|---|---|---|
audienceId | string | Yes |
Headers
| Name | Type | Required | Notes |
|---|---|---|---|
Idempotency-Key | string | Yes | At most 128 characters. |
Request body
| Name | Type | Required | Notes |
|---|---|---|---|
email | string | Yes | Email address. Email address. At most 320 characters. |
attributes | object | No | Custom contact data, such as { "plan": "pro" }. Templates read it as contact.<name>, and segments filter on it. |
locale | string | No | BCP 47 language tag such as en, sk or en-GB. At most 16 characters. |
consent | object | Yes | How 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
| Name | Type | Required | Notes |
|---|---|---|---|
audienceId | string | Yes | |
contactId | string | Yes |
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
| Name | Type | Required | Notes |
|---|---|---|---|
email | string | Yes | Email address. Email address. At most 320 characters. |
attributes | object | No | Custom contact data, such as { "plan": "pro" }. Templates read it as contact.<name>, and segments filter on it. |
locale | string or null | No | A 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
| Name | Type | Required | Notes |
|---|---|---|---|
cursor | string | No | |
limit | integer | No | From 1 to 100. Default 25. |
audienceId | string | No | |
state | string | No | One of pending, confirmed, unsubscribed. |
email | string | No | Only 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
| Name | Type | Required | Notes |
|---|---|---|---|
contactId | string | Yes |
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
| Name | Type | Required | Notes |
|---|---|---|---|
contactId | string | Yes |
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
| 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. |
consent | string | Yes | How the contact's consent was given. One of pending, confirmed. |
policyVersion | string | No | The version of your privacy or consent policy the person agreed to. At most 100 characters. |
wording | string | No | The consent wording the person agreed to. At most 2000 characters. |
source | string | No | The 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. |
status | string | No | The 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. |
columns | object | No | Renames 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": ""}. |
consentCapturedAt | string | No | For 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. |
consentSource | string | No | For 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. |
csv | string | Yes | The CSV file content, at most 10,000 rows. At most 5242880 characters. |
batch | object | No | Links this import to the other parts of one file. The CLI and MCP upload commands split a file and set this for you. |
fileName | string | No | The 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
| Name | Type | Required | Notes |
|---|---|---|---|
cursor | string | No | |
limit | integer | No | From 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
| Name | Type | Required | Notes |
|---|---|---|---|
importId | string | Yes |
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
| Name | Type | Required | Notes |
|---|---|---|---|
importId | string | Yes |
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
| Name | Type | Required | Notes |
|---|---|---|---|
batchId | string | Yes |
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
| Name | Type | Required | Notes |
|---|---|---|---|
batchId | string | Yes |
curl --request POST "https://ternwire.com/v1/contact-import-batches/{batchId}/apply" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"