Reference

Domains API

Add, list, inspect, and delete sending domains and their DNS records.

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.

List sending domains

GET /v1/domains (listSendingDomains)

Lists the workspace's sending domains with their verification state and the DNS records each one needs.

Needs an API key with the send scope. Test keys are refused.

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

Create sending domain

POST /v1/domains (createSendingDomain)

Adds a domain to send from and returns the DNS records to publish at the domain's DNS provider. Email can be sent from the domain once it is verified.

Needs an API key with the send scope. Test keys are refused.

Request body

NameTypeRequiredNotes
domainstringYesThe domain to send from, such as mail.example.com. At most 253 characters.
purposestringNotransactional for app email, marketing for newsletters. One of transactional, marketing. Default "transactional".
curl --request POST "https://ternwire.com/v1/domains" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "domain": "updates.example.com"
  }'

Get sending domain

GET /v1/domains/{domainId} (getSendingDomain)

Refreshes the domain's verification state from the email provider and returns it with the DNS records still to publish.

Needs an API key with the send scope. Test keys are refused.

Path parameters

NameTypeRequiredNotes
domainIdstringYes
curl --request GET "https://ternwire.com/v1/domains/{domainId}" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

Delete sending domain

DELETE /v1/domains/{domainId} (deleteSendingDomain)

Removes the domain. The removal finishes in the background: the response says how far it got. Email can no longer be sent from the domain.

Needs an API key with the send scope. Test keys are refused.

Path parameters

NameTypeRequiredNotes
domainIdstringYes
curl --request DELETE "https://ternwire.com/v1/domains/{domainId}" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

List receiving addresses

GET /v1/domains/{domainId}/receiving-addresses (listReceivingAddresses)

The addresses on this domain that receive email, with the MX record that sends the domain's mail to Ternwire, and how many addresses the plan allows.

Needs an API key with the send scope.

Path parameters

NameTypeRequiredNotes
domainIdstringYes
curl --request GET "https://ternwire.com/v1/domains/{domainId}/receiving-addresses" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

Create receiving address

POST /v1/domains/{domainId}/receiving-addresses (createReceivingAddress)

Adds an address this domain receives email at. The Free plan has one address per domain and paid plans have more. Needs a live key with the send scope. Returns 409 receiving_address_limit_reached when the domain has as many as the plan allows, and 200 with the existing address when the domain already has this local part. Every received email counts against the plan's email quota like a sent one, and email beyond the quota is dropped. With forwardTo, email that passes the spam check is also sent on to that address, which counts as one more email. Mail arrives once the domain is verified and its MX record points to the host in mxRecord.

Path parameters

NameTypeRequiredNotes
domainIdstringYes

Request body

NameTypeRequiredNotes
localPartstringYesThe part before the @, such as support. Letters, digits and . _ + -, stored in lower case. At most 64 characters.
forwardTostring or nullNoWhere clean email is forwarded: the verified email address of a member of the organization. Null stores the email without forwarding it.
curl --request POST "https://ternwire.com/v1/domains/{domainId}/receiving-addresses" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "localPart": "string"
  }'

Check receiving addresses

POST /v1/domains/{domainId}/receiving-addresses/check (checkReceivingAddresses)

Looks up the domain's MX records now and returns its addresses.

Needs an API key with the send scope.

Path parameters

NameTypeRequiredNotes
domainIdstringYes
curl --request POST "https://ternwire.com/v1/domains/{domainId}/receiving-addresses/check" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

Update receiving address

PATCH /v1/domains/{domainId}/receiving-addresses/{addressId} (updateReceivingAddress)

Changes where the address forwards its email. forwardTo must be the verified email address of a member of the organization, or null to stop forwarding. Returns 422 forward_address_not_member otherwise.

Needs an API key with the send scope.

Path parameters

NameTypeRequiredNotes
domainIdstringYes
addressIdstringYes

Request body

NameTypeRequiredNotes
forwardTostring or nullYesWhere clean email is forwarded: the verified email address of a member of the organization. Null stores the email without forwarding it.
curl --request PATCH "https://ternwire.com/v1/domains/{domainId}/receiving-addresses/{addressId}" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "forwardTo": "ada@example.com"
  }'

Delete receiving address

DELETE /v1/domains/{domainId}/receiving-addresses/{addressId} (deleteReceivingAddress)

Stops receiving at this address. Email already received stays listable.

Needs an API key with the send scope.

Path parameters

NameTypeRequiredNotes
domainIdstringYes
addressIdstringYes
curl --request DELETE "https://ternwire.com/v1/domains/{domainId}/receiving-addresses/{addressId}" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

Check domain

POST /v1/domains/{domainId}/check (checkDomain)

Asks the email provider for the domain's status and looks up its DNS records now, then returns each record with whether it was found and, for one that does not match yet, the value DNS answered. readyToSend is true once the domain can send. Needs a live key with the send scope that is not limited to some domains.

Path parameters

NameTypeRequiredNotes
domainIdstringYes
curl --request POST "https://ternwire.com/v1/domains/{domainId}/check" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"

Get domain dns setup

GET /v1/domains/{domainId}/dns-setup (getDomainDnsSetup)

Finds the domain's DNS provider and whether it supports one-click setup (Domain Connect). With status ready, actionUrl is the page where a person signs in to the provider and approves the records; give it to the domain's owner. Otherwise add dnsRecords at the provider by hand. Then call checkDomain. Needs a live key with the send scope that is not limited to some domains.

Path parameters

NameTypeRequiredNotes
domainIdstringYes
curl --request GET "https://ternwire.com/v1/domains/{domainId}/dns-setup" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"