Get started
Quickstart
Create an API key, send your first email over HTTP, and retry safely with idempotency keys.
On this page
Send your first email from code in a few minutes. The Free plan is active from the moment you sign up, so you don't need to pay or add a card.
Not writing code? Send a test email from the dashboard, install the WordPress plugin, or send a newsletter without code.
Pick your path
Your first email works with or without a domain of your own. The two paths differ in steps 1, 2 and 4:
| I have a domain | No domain yet | |
|---|---|---|
| Step 1 | Add your domain and wait until it shows Verified | Skip it |
| Step 2 | Create a Test key | Create a Live key |
| Step 4 sends from | An address on your domain | onboarding@sandbox.ternwire.com |
| Step 4 sends to | The reserved test address delivered@events.ternwire.test | Your own account email |
| What you see | No email is sent. The message reports a delivery a few seconds later. | The email arrives in your inbox. |
A test key never delivers real email. That is why the path without a domain uses a live key: otherwise the API answers 202 and nothing arrives.
1. Add and verify your domain
Add a domain you own (such as yourapp.com) under Domains in the dashboard. Ternwire shows a few DNS records. Copy them into the place where you manage your domain, usually your domain registrar or DNS host, and wait until the domain shows Verified. That usually takes a few minutes to a few hours. The domain guide explains each step.
No domain yet? Skip to step 2. Ternwire's test address, onboarding@sandbox.ternwire.com, sends only to verified members of your workspace. Send before your domain is ready lists its limits.
2. Create an API key
Open API keys and choose Create API key. Pick Test if you have a verified domain, or Live if you don't, and choose Send email only. Copy the key now; it is shown once. Test keys start with em_test_ and live keys start with em_live_.
Put the key in your terminal so the commands below can use it. Paste your own key between the quotes:
export TERNWIRE_API_KEY="em_test_paste_your_key"On a server, store the key as the TERNWIRE_API_KEY environment variable the same way your app stores its other secrets.
Keep your API key and webhook signing secret on your server only. Never put them in front-end code or in an environment variable that ships to the browser (for example NEXT_PUBLIC_ or VITE_).
The API is served from https://ternwire.com, which every SDK, the CLI, and the MCP server use by default.
3. Install an SDK
# No install needed. cURL ships with macOS, Linux, and Windows 10 and later.Other languages: see SDKs.
4. Send a test email
Replace the sender with an address on your verified domain, and keep the reserved test recipient exactly as shown. The idempotency key names this one email, so keep it if you need to retry the same request.
curl --request POST "https://ternwire.com/v1/emails" \
--header "Authorization: Bearer $TERNWIRE_API_KEY" \
--header "Content-Type: application/json" \
--header "Idempotency-Key: quickstart-delivery-001" \
--data '{
"from": "notifications@your-verified-domain.com",
"to": ["delivered@events.ternwire.test"],
"subject": "Your first Ternwire test",
"text": "This message exercises a delivery event."
}'No domain yet? Send from Ternwire's test address to your own account email, with your live key:
curl --request POST "https://ternwire.com/v1/emails" \
--header "Authorization: Bearer $TERNWIRE_API_KEY" \
--header "Content-Type: application/json" \
--header "Idempotency-Key: quickstart-sandbox-001" \
--data '{
"from": "onboarding@sandbox.ternwire.com",
"to": ["you@your-account-email.com"],
"subject": "My first Ternwire email",
"text": "It works."
}'The cURL commands work in the macOS and Linux terminal. In Windows PowerShell, use the Node.js or Python tab, or run cURL from Git Bash.
A successful response has HTTP status 202:
{
"id": "msg_3f2b1c4e8a9d4e1fb6c72d5e8f9a0b1c",
"state": "queued",
"acceptedAt": "2026-11-08T12:00:00.000Z"
}Save the message ID. Acceptance means Ternwire has safely recorded the message. It does not mean the recipient has received it.
5. Check delivery state
Fetch the message with the ID from the response. In the cURL command, replace msg_paste_the_id_here with that ID. Delivery runs in the background, so the first answer may still be queued.
curl "https://ternwire.com/v1/emails/msg_paste_the_id_here" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"A few seconds later, the reserved recipient reports a delivery:
{
"id": "msg_3f2b1c4e8a9d4e1fb6c72d5e8f9a0b1c",
"state": "submitted",
"acceptedAt": "2026-11-08T12:00:00.000Z",
"recipients": { "queued": 0, "delivered": 1, "failed": 0 },
"possibleDuplicate": false,
"holdReason": null
}state describes the message: accepted, queued, held, submitting, submitted, submission_unknown, or failed. The recipients counts say how many addresses were delivered or failed. Delivery states explains each one, with the words the dashboard uses for it. You can also find the email under Messages in the dashboard.
6. Retry safely
Reuse the same idempotency key and identical payload after a network timeout. A successful replay returns the accepted message without accepting another copy. A different payload with that key returns a 409 conflict. Keys must contain 1-128 characters and are remembered for 7 days after Ternwire accepts the email. After that, the same key sends a new email, so retry within that window. Generate a new key for each new email.
The API accepts 10 email requests a second per workspace. Over that, it answers 429 with a Retry-After header. Wait that long, then retry with the same key. Limits lists every limit.
7. Go live
Live sending is turned on when you create your account, so no approval step is needed. Before you send to customers:
- Your domain shows Verified under Domains.
- You created a live API key (it starts with
em_live_) and stored it on your server in place of the test key. - Your code sends from an address on your verified domain.
- You checked your plan limits. On the Free plan you can send to 100 recipients a day at first.