Reference
Emails API
Submit an email, list sent messages, and check one message's delivery state.
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.
Submit email
POST /v1/emails (submitEmail)
Accepts an email for delivery and returns its message ID at once. Delivery happens in the background: read it with getMessage or receive webhook events. Every request needs an Idempotency-Key header: reuse the key when retrying a request whose outcome you don't know, and the API returns the first result instead of sending again. Send either subject with html and/or text, or a saved templateId with values.
A body with purpose "marketing" sends one email to a confirmed subscriber and needs the marketing:send scope and a live key. Its single to address must be the contact's own, and cc, bcc and listManagement must be empty because Ternwire adds the unsubscribe headers and footer.
Needs an API key with the send scope.
Headers
| Name | Type | Required | Notes |
|---|---|---|---|
Idempotency-Key | string | Yes | At most 128 characters. |
Request body
| Name | Type | Required | Notes |
|---|---|---|---|
from | string | Yes | Sender address on a verified domain, optionally with a display name: Acme Shop <hello@acme.com>. Quote a name that has commas or other punctuation. At most 800 characters. |
to | string[] | Yes, unless cc or bcc is set | At most 50 recipients across to, cc and bcc. |
cc | string[] | No | At most 50 recipients across to, cc and bcc. |
bcc | string[] | No | At most 50 recipients across to, cc and bcc. |
replyTo | string | No | The address replies go to, when it is not the sender. Email address. At most 320 characters. |
attachmentIds | string[] | No | Attachments uploaded with createAttachmentUploadSlot whose scan came back clean. At most 20 items. |
tags | object | No | Your own labels, such as { "order": "123" }. Keys are up to 64 letters, digits, _ or -, and values up to 256 characters. |
listManagement | object | No | Adds unsubscribe headers: { "unsubscribe": "https://...", "unsubscribePost": "List-Unsubscribe=One-Click" }. One-click needs an https URL. |
headers | object | No | Custom headers, such as { "X-Order-Id": "123" }. Names must start with X-. Values are up to 998 characters. |
subject | string | Yes, unless you send a template | At most 998 characters. |
html | string | Yes, unless text is set or you send a template | At most 5,000,000 characters. |
text | string | Yes, unless html is set or you send a template | At most 5,000,000 characters. |
tracking | object | No | Turns open or click tracking on or off for this email only. Tracking changes only the HTML part. |
templateId | string | No | Send a saved template instead of a subject and body. |
values | object | No | Data for the template, such as { "first_name": "Ada" }. |
purpose | string | No | Leave it out for app email. Set it to marketing to send one newsletter email to a contact, with audienceId and contactId. |
audienceId | string | No | With purpose: "marketing": the audience the contact belongs to. |
contactId | string | No | With purpose: "marketing": the contact to send to. |
curl --request POST "https://ternwire.com/v1/emails" \
--header "Authorization: Bearer $TERNWIRE_API_KEY" \
--header "Idempotency-Key: submitEmail-001" \
--header "Content-Type: application/json" \
--data '{
"from": "notifications@yourdomain.com",
"to": [
"ada@example.com"
],
"subject": "Your receipt",
"text": "Thanks for your order."
}'List messages
GET /v1/emails (listMessages)
Lists emails accepted for this workspace, newest first, one page at a time, with each one's overall state. Pass nextCursor back as cursor for the next page.
Needs an API key with the send scope.
Query parameters
| Name | Type | Required | Notes |
|---|---|---|---|
cursor | string | No | |
limit | integer | No | From 1 to 100. Default 25. |
state | string | No | One of accepted, queued, held, submitting, submitted, submission_unknown, failed. |
subject | string | No | At most 200 characters. |
recipient | string | No | A complete address matches recipients with exactly that address, in any case. Part of an address matches recipients whose address contains it, which is slower. At most 320 characters. |
acceptedFrom | string | No | ISO 8601 date and time. |
acceptedTo | string | No | ISO 8601 date and time. |
curl --request GET "https://ternwire.com/v1/emails" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"Get message
GET /v1/emails/{messageId} (getMessage)
Returns one email with the delivery state of each recipient, and opens and clicks when tracking was on.
Needs an API key with the send scope.
Path parameters
| Name | Type | Required | Notes |
|---|---|---|---|
messageId | string | Yes |
curl --request GET "https://ternwire.com/v1/emails/{messageId}" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"Get tracking settings
GET /v1/tracking-settings (getTrackingSettings)
Whether transactional email records opens and clicks. Needs the send scope. Broadcasts and automations use the marketing settings instead.
curl --request GET "https://ternwire.com/v1/tracking-settings" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"Update tracking settings
PATCH /v1/tracking-settings (updateTrackingSettings)
Turns open and click tracking on or off for transactional email accepted from now on, through the API or SMTP. Both are off until changed. A send can override them with its tracking field. In the EU, tracking may need each recipient's consent.
Needs an API key with the send scope.
Request body
| Name | Type | Required | Notes |
|---|---|---|---|
openTracking | boolean | No | Add a 1x1 image to the HTML part of each email, which records when the email is opened. |
clickTracking | boolean | No | Send each http and https link in the HTML part through a Ternwire redirect that records the click. |
curl --request PATCH "https://ternwire.com/v1/tracking-settings" \
--header "Authorization: Bearer $TERNWIRE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"openTracking": false,
"clickTracking": false
}'