Reference
Account, keys and settings API
Read the account and the calling key, manage API keys, change marketing settings, and read delivery metrics.
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.
Get marketing settings
GET /v1/marketing-settings (getMarketingSettings)
Whether broadcasts and automations record opens and clicks.
Needs an API key with the broadcasts:read scope.
curl --request GET "https://ternwire.com/v1/marketing-settings" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"Update marketing settings
PATCH /v1/marketing-settings (updateMarketingSettings)
Turns open and click tracking on or off for broadcasts sent from now on. Both are off until changed. A broadcast keeps the settings it was sent with. In the EU, tracking may need each recipient's consent.
Needs an API key with the broadcasts:write scope. Test keys are refused.
Request body
| Name | Type | Required | Notes |
|---|---|---|---|
openTracking | boolean | No | Add a 1x1 image that records when a copy is opened. |
clickTracking | boolean | No | Send HTML links through a Ternwire redirect that records clicks. |
curl --request PATCH "https://ternwire.com/v1/marketing-settings" \
--header "Authorization: Bearer $TERNWIRE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"openTracking": false,
"clickTracking": false
}'Get delivery metrics
GET /v1/metrics (getDeliveryMetrics)
Counts messages and recipients accepted in a window of at most 90 days, with the current queue and billing period usage.
Needs an API key with the send scope.
Query parameters
| Name | Type | Required | Notes |
|---|---|---|---|
from | string | No | Window start, defaults to 7 days before to ISO 8601 date and time. |
to | string | No | Window end, defaults to now ISO 8601 date and time. |
curl --request GET "https://ternwire.com/v1/metrics" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"Get current account
GET /v1/me (getCurrentAccount)
Returns what a caller needs to know before it acts: the organization, the calling credential (its scopes, mode, domain limit and expiry), the plan, whether live sending is allowed and why not, the recipient quota for the billing period and, on the free plan, for today, whether marketing is on, and the AI template credits. Any valid key can call it, whatever its scopes and mode.
curl --request GET "https://ternwire.com/v1/me" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"List api keys
GET /v1/api-keys (listApiKeys)
Lists the organization's API keys, revoked ones too, newest first, one page at a time. Secrets are never returned. Needs the api_keys:write 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/api-keys" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"Create api key
POST /v1/api-keys (createApiKey)
Creates an API key and returns its secret in key, once. Needs the api_keys:write scope. The new key can have no more access than the calling key: only scopes the caller has, test mode if the caller is a test key, only the caller's sending domains if the caller is limited to some, and an expiry no later than the caller's if it expires. Otherwise 403 api_key_privilege_exceeded names the field. A key limited to some domains can't have broadcasts:write or automations:write, and every domain in allowedDomains must already be added.
Headers
| Name | Type | Required | Notes |
|---|---|---|---|
Idempotency-Key | string | No | At most 128 characters. |
Request body
| Name | Type | Required | Notes |
|---|---|---|---|
name | string | Yes | A name that says where the key is used, such as Production server. At most 100 characters. |
mode | string | Yes | live or test. A test key can only create test keys. One of live, test. |
scopes | string[] | Yes | What the key may do: a subset of the calling key's scopes. Each one of organization:read, send, contacts:read, contacts:write, broadcasts:read, broadcasts:write, marketing:send, automations:read, automations:write, events:write, inbound:read, api_keys:write, templates:generate. |
allowedDomains | string[] or null | No | Limit the key to these sending domains. Leave it out for every domain, which a domain-limited caller cannot do. |
expiresAt | string or null | No | When the key stops working, in ISO 8601 with an offset. No later than the calling key. |
curl --request POST "https://ternwire.com/v1/api-keys" \
--header "Authorization: Bearer $TERNWIRE_API_KEY" \
--header "Idempotency-Key: createApiKey-001" \
--header "Content-Type: application/json" \
--data '{
"name": "string",
"mode": "live",
"scopes": [
"organization:read"
]
}'Revoke api key
DELETE /v1/api-keys/{apiKeyId} (revokeApiKey)
Revokes the key at once: requests with it are refused from now on. Needs the api_keys:write scope. A key can revoke itself, and any key with no more access than its own; otherwise 403 api_key_privilege_exceeded. Revoking a revoked key returns it unchanged.
Path parameters
| Name | Type | Required | Notes |
|---|---|---|---|
apiKeyId | string | Yes |
curl --request DELETE "https://ternwire.com/v1/api-keys/{apiKeyId}" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"