# Transactional email API: keys, streams, first send

> Set up the Inspiremail transactional email API: create a scoped API key, a stream with a verified sender, and send your first receipt with safe retries.

Published 2026-11-22 by Reda El Kasraoui, Founder of Inspiremail. Canonical page: https://inspiremail.io/blog/transactional-email-api

**TL;DR:** create an API key under **Settings › API keys** with the **messages:send** scope, create a stream under **Transactional › Streams** with a verified sender identity, then call `POST https://platform.inspiremail.io/v1/messages` with `Authorization: Bearer im_live_…`, a `from` address on the stream's identity, a `to`, a `subject` and HTML or text. Add an `Idempotency-Key` header so retries never send twice. Every message gets a timeline in the log, and events can go to your own webhook.

**Transactional email** is mail a person triggers and expects, such as a receipt or a password reset. **An idempotency key** is a value you send with a request so that repeating the same request never repeats its effect.

Transactional email is the mail people expect: receipts, password resets, booking confirmations. It should never be held up by a marketing unsubscribe, and it should never go out twice because your server retried. Streams handle the first, idempotency keys the second.

## Step 1: create a scoped key

:::screenshot{src="https://inspiremail.io/media/blog/2026/11/b44dbc8e-c838-4903-9994-70ea57a73cb3.webp" alt="Inspiremail Settings › API keys with the Create API key dialog open: a Name field, a grid of scopes such as lists:read, contacts:write, messages:send described as Send transactional messages (POST /v1/messages), messages:read, hooks:write, journeys:write, and an Expires select set to Never"}
Settings › API keys. Each scope has a one-line description; tick only what the application needs.
:::

:::steps
1. Open **Settings › API keys** and click **Create key**. Only the owner and Organization Managers can manage keys.
2. Name it after the application ("Shop – order emails") so you know what breaks if you revoke it.
3. Tick **messages:send**, plus **messages:read** if the app reads the log.
4. Choose an expiry, or **Never** for a long-lived server key.
5. Click **Create key** and copy the key straight into your secret manager. It starts with `im_live_` and is shown once; only a hash is stored.
:::

The list shows each key's prefix, scopes, last use and expiry. Revoking a key also disables any REST hooks it created.

## Step 2: create a stream

:::screenshot{src="https://inspiremail.io/media/blog/2026/11/7e82473f-bd3d-419c-b03e-47ef9102639a.webp" alt="New stream dialog on the Transactional page with Name, Slug used as the API stream value, Kind set to Transactional (only hard bounces and complaints block) or Marketing (every suppression blocks, List-Unsubscribe added), a Sender (verified identity) select, an optional default From name, and options to respect marketing unsubscribes, respect the blocklist, track opens and track clicks by default"}
The New stream dialog. The slug is the value you pass as "stream" in API calls.
:::

:::steps
1. Open **Transactional › Streams** and click **New stream**.
2. Give it a **Name** and a **Slug** (for example `receipts`).
3. **Kind**: Transactional for receipts and resets, Marketing for product news you send through the API.
4. **Sender**: one verified identity of any connected provider. API calls must use this address, or any address at that domain, as `from`.
5. Leave **Respect the blocklist** on. Turn on **Respect marketing unsubscribes** only if the stream carries mail people can reasonably opt out of.
6. Tracking is off by default. Turn on opens or clicks if you need them; they run on the sender's tracking domain.
:::

## Step 3: send the first message

```bash
curl https://platform.inspiremail.io/v1/messages \
  -H "Authorization: Bearer $INSPIREMAIL_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-10482-receipt" \
  -d '{
    "stream": "receipts",
    "from": "Atlas Shop <orders@news.example.com>",
    "to": { "email": "customer@example.net", "name": "Dana Reyes" },
    "subject": "Your order 10482",
    "html": "<p>Thanks, {{first_name}}. Your order is on its way.</p>",
    "variables": { "first_name": "Dana" }
  }'
```

Addresses are either a string (`"Name <address>"`) or an object with `email` and `name`. A `201` means the provider accepted the message. The response carries the message ID; keep it if you want to look the message up later. You can also send a saved template with `template_id` and `variables` instead of inline HTML; variables are HTML-escaped. Other fields: `reply_to` (up to 5), custom `headers` (up to 20), `tags`, `metadata`, `attachments` and a `tracking` override.

![Diagram of a transactional message: POST /v1/messages with a messages:send key and optional Idempotency-Key, stream checks on the From address and suppressed recipients, sending through the stream's provider account, then the 90-day log and message webhooks](https://inspiremail.io/media/blog/2026/11/c522d04a-dc82-4916-9bad-24f62ca4846c.webp "Four checkpoints between your call and the inbox.")

## Responses worth handling

| Status | Meaning | What to do |
|---|---|---|
| 201 | Sent: the provider accepted it | Store the message ID |
| 200 + `Idempotent-Replayed` | Same key and body as an earlier call | Nothing; it wasn't sent again |
| 409 | Same Idempotency-Key, different body | Use a new key for a new message |
| 422 | Recipient suppressed, `from` not on the stream identity, or attachments the provider can't take | Fix the request; don't retry blindly |
| 429 | Over the per-key limit | Wait for `Retry-After` |
| 502 | The provider refused the message | Logged as failed; check the detail |

A suppressed recipient is logged with the status `suppressed`, so support can see why a customer didn't get their receipt.

## Transactional or marketing stream?

| | Transactional stream | Marketing stream |
|---|---|---|
| Typical mail | Receipts, password resets, alerts | Product news, announcements sent from your app |
| Refused recipients | Hard bounces and complaints, plus your blocklist unless you turn it off | Every suppression, including marketing unsubscribes |
| List-Unsubscribe header | Not added | Added automatically (a custom one is refused) |
| Opens and clicks | Off by default | Off by default, switch on per stream or per call |

The rule of thumb: if the recipient would be annoyed not to get it, it's transactional. If they could reasonably say "stop sending me these", it's marketing, and it should respect their unsubscribe. Mixing the two on one stream is how a password reset ends up blocked by a newsletter opt-out, or a promotion slips past one.

Recipient addresses in the log are masked and stored encrypted, so people looking at the Messages tab see enough to identify a message without the full address. Messages are kept for 90 days.

## Watch what happens next

The **Messages** tab on the Transactional page lists every message with its status and a timeline of events. The same log is available through `GET /v1/messages` (filter by status, recipient, stream or date) and `GET /v1/messages/{id}`. To react in real time, subscribe an endpoint to `message.delivered`, `message.bounced`, `message.complained` and the other `message.*` events; the [webhooks guide](https://inspiremail.io/blog/webhooks-setup) covers signatures and retries.

## Why this is quick to adopt

You reuse the providers, verified identities and tracking domains you already set up for drops. There's no separate account to warm up and no second suppression list to keep in sync. The API description is published as OpenAPI 3.1 under **Settings › API docs**, so you can generate a client instead of writing one, and the [OpenAPI specification](https://spec.openapis.org/oas/v3.1.0) tells your tooling how to read it.

## How we checked this guide

We tested each step in a demo organization with fictitious data on 22 November 2026 and compared it with the provider documentation linked above, and with [FIPS 198-1, the HMAC standard](https://csrc.nist.gov/pubs/fips/198-1/final) for the background on API security. Screens, button labels, limits and error messages are taken from the product as it works today. If something here no longer matches what you see, [contact us](https://inspiremail.io/contact) and we'll correct it, as our [editorial policy](https://inspiremail.io/editorial-policy) describes. Read more [about us](https://inspiremail.io/about).

## Related guides

[Webhooks](https://inspiremail.io/blog/webhooks-setup) for events, [Postmark](https://inspiremail.io/blog/postmark-setup) if you send through a Postmark transactional stream, and the [API & webhooks](https://inspiremail.io/features/api-webhooks) and [developers](https://inspiremail.io/developers) pages. Background on the headers: the IETF's draft [Idempotency-Key header](https://datatracker.ietf.org/doc/draft-ietf-httpapi-idempotency-key-header/) and [RFC 6585](https://www.rfc-editor.org/rfc/rfc6585) for status 429.

## Frequently asked questions

### Which API key scope do I need to send transactional email?

messages:send to call POST /v1/messages, and messages:read if your code also reads the message log. Give each application its own key with only those scopes.

### What is a stream?

A stream groups messages with one sender and one suppression policy. A transactional stream only refuses hard bounces, complaints and, by default, your blocklist. A marketing stream refuses every suppression and adds List-Unsubscribe headers.

### How do I retry a send safely?

Send an Idempotency-Key header. For 24 hours, the same key with the same body returns the original response instead of sending again, and the same key with a different body is refused with HTTP 409.

### What are the API limits?

600 requests per minute per key across the API, and 300 messages per minute per key on POST /v1/messages. Over the limit the API answers 429 with a Retry-After header.

### How long are transactional messages kept?

90 days, with the recipient address masked and stored encrypted. Each message keeps its event timeline: sent, delivered, delayed, bounced, complained, opened and clicked.

### Can I attach files?

Yes: up to 10 files, 5 MB each and 10 MB in total, sent base64-encoded. Executable files are refused.
