API Reference
Version v1 · Base URL https://api.birdrelay.com
Quickstart
- Create an API key on the API keys page. Keys belong to one project and are shown only once.
- Store it server-side as an environment variable, for example
BIRDRELAY_API_KEY. Never put the key in browser code, a mobile app or a public repository. - Send an email with
POST https://api.birdrelay.com/v1/emails. With cURL:KEY=$BIRDRELAY_API_KEY curl -X POST \ https://api.birdrelay.com/v1/emails \ -H "Authorization: Bearer $KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: hello-0001" \ -d '{ "from": "App <hi@mg.example.com>", "to": "you@example.com", "subject": "Hello", "html": "<p>Hello, BirdRelay</p>" }'Or withfetchfrom Node.js:const key = process.env.BIRDRELAY_API_KEY; const url = "https://api.birdrelay.com/v1/emails"; // New per email, the same on a retry const idemKey = crypto.randomUUID(); const res = await fetch(url, { method: "POST", headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json", "Idempotency-Key": idemKey, }, body: JSON.stringify({ from: "App <hi@mg.example.com>", to: "you@example.com", subject: "Hello", html: "<p>Hello from BirdRelay</p>", }), }); // 200 → { id: "msg_..." } // else { name, message, statusCode } const body = await res.json(); - Check the status with
GET /v1/emails/:id.const statusUrl = `${url}/${body.id}`; const r = await fetch(statusUrl, { headers: { Authorization: `Bearer ${key}`, }, }); const status = await r.json(); // queued → sending → sent → delivered console.log(status.status);
Recipients must be on the server-side allowlist, and a new organization starts in Sandbox. The TypeScript SDK in packages/sdk is not published to npm yet; use fetch or cURL for now.
Authentication
Send a project API key as Authorization: Bearer ma_…. Create keys on the API keys page; each key belongs to one project and only sees that project’s emails.
Sandbox and Production
Every organization has a sending status that decides who it may send to. A new organization starts in Sandbox.
| Status | Who can receive | How you get it |
|---|---|---|
| Sandbox | Only the verified email addresses of your organization's own active accounts, plus addresses BirdRelay approved for your organization. Every recipient of an email (to, cc and bcc) must be one of them. | Automatic for every new organization. |
| Production | Any recipient, within the platform rules below. | Ask BirdRelay. It is a manual review, not a setting you can change yourself. |
- A Sandbox email to any other address is refused with
403 recipient_not_allowed_in_sandbox. Nothing is queued and no quota is used. - Both statuses use the same API, keys and domains: moving to Production changes nothing in your code.
- Production does not lift the other rules. The server-side allowlist (
403 recipient_not_allowed), the suppression list, your quotas and the sending domain checks apply in both statuses. - Sending must also be enabled for your organization (
403 organization_not_activated) and its subscription must be active (403 subscription_inactive). These are separate from Sandbox and Production. - If an organization goes back to Sandbox, or an approved address is removed, emails still queued to recipients the Sandbox no longer allows end as
failedwithout being sent. An email that is already being handed over cannot be recalled.
POST /v1/emails
POST /v1/emails
Authorization: Bearer ma_...
Content-Type: application/json
Idempotency-Key: order-1234 (optional)
{
// exactly one mailbox
"from": "App <hi@mg.example.com>",
// string or array, max 50 recipients
// in total (to, cc and bcc together)
"to": ["you@example.com"],
"cc": [], "bcc": [], "reply_to": [],
"subject": "Welcome",
// html and/or text is required
"html": "<p>Hello</p>",
"text": "Hello",
"tags": [
{ "name": "type",
"value": "welcome" }
],
// only X-* headers (some reserved)
"headers": { "X-Entity-Ref": "123" },
// optional, with "variables":
// { "name": "Ada" }
"template_id": "tpl_..."
}
200 OK { "id": "msg_..." }Idempotency-Key (1–256 visible ASCII characters): repeating a request with the same key and the same body returns the stored response instead of sending again. The same key with a different body returns 409 idempotency_conflict.
GET /v1/emails/:id · GET /v1/emails
GET /v1/emails/msg_...
→ { "object": "email", "id", "from",
"to", "subject", "status",
"last_event", "created_at",
"sent_at", "delivered_at" }
GET /v1/emails?limit=20&before=msg_...
→ { "object": "list", "has_more": false,
"data": [ ... ] }limit is 1–100 (default 20). Pass the last id as before to fetch the next page.
Errors and retries
{
"name": "recipient_not_allowed",
"message": "…",
"statusCode": 403
}Use name in your code; the message is for people and can change. A 4xx or 503 error means the email was not queued and will not be sent. The one exception is suppressed: that email is recorded (status suppressed, with its id) but sent to nobody. For a 500 or no answer at all, see below.
| name | HTTP | Meaning | Retry? |
|---|---|---|---|
| validation_error | 422 | Invalid body: missing or unknown field, no html/text, more than 50 recipients, or a from value that is not exactly one mailbox. Also 400 for invalid JSON, 413 for a body that is too large and 415 for a wrong Content-Type. | No. Fix the request; the message says which field. |
| missing_api_key | 401 | No Authorization: Bearer header. | No. Send the key. |
| invalid_api_key | 403 | Unknown or revoked key. | No. Use a valid key. |
| recipient_not_allowed | 403 | A recipient is not on the server-side allowlist. | No. |
| recipient_not_allowed_in_sandbox | 403 | Your organization is in Sandbox and a recipient is not one of its allowed addresses. See Sandbox and Production. | No, until the recipient is allowed or the organization is in Production. |
| organization_not_activated | 403 | Sending is not enabled for this organization. | No, until BirdRelay enables sending. |
| subscription_inactive | 403 | The organization has no active subscription. | No, until the subscription is active. |
| idempotency_conflict | 409 | Idempotency-Key already used with a different body, or the first request is still being processed. | Different body: no, use a new key. A parallel duplicate with the same body waits for the first request and gets its answer. |
| not_found | 404 | The email does not exist in this project. | No. |
| invalid_from_address | 422 | The sender domain is not an allowed sending domain for this project. | No. Use one of your sending domains. |
| domain_not_verified | 422 | The sender domain is not verified for sending (domain verification or email authentication missing), or it is disabled. | After the domain is verified (or re-enabled). |
| suppressed | 422 | A recipient is on the suppression list (bounce or complaint). The email is recorded with status suppressed, is sent to nobody, and the response includes its id. | No, not with that recipient. The same Idempotency-Key returns this answer for 24 hours, also after the address is lifted: use a new key. |
| rate_limit_exceeded | 429 | Too many requests for this project or organization (all keys of a project share the limit). See the Retry-After header. | Yes, after the Retry-After seconds. |
| daily_quota_exceeded | 429 | Daily quota (recipients, UTC day) reached, or this request alone has more recipients than the quota allows. | After 00:00 UTC (see Retry-After). If the request alone is too large: split it. |
| monthly_quota_exceeded | 429 | Monthly quota (recipients, UTC calendar month) reached, or this request alone has more recipients than the quota allows. | After the first day of the next month (UTC). If the request alone is too large: split it. |
| internal_server_error | 500 | Unexpected error. | Yes, with the same Idempotency-Key. |
| provider_unavailable | 503 | Email sending is temporarily unavailable for this domain. Nothing was queued. | Yes, later. |
A 500, a timeout or a dropped connection
id back and nothing is sent twice; otherwise it is processed now. A repeat without an Idempotency-Key can send the email twice, so always send one when you retry automatically.Retry safely
TypeScript SDK
The dependency-free SDK in packages/sdk (not on npm yet) wraps the same API. It never throws for an API error: every call returns { data, error }. Exactly one of the two is set: check error first.
import { BirdRelay }
from "@revverk/mailapi-sdk";
// timeoutMs: 15000 by default
const birdrelay = new BirdRelay(
process.env.BIRDRELAY_API_KEY!,
);
// Stable per email; reuse it on a retry
const key = `order-${orderId}-mail`;
const { data, error } =
await birdrelay.emails.send(
{
from: "App <hi@mg.example.com>",
to: "you@example.com",
subject: "Hello",
text: "Hi",
},
{ idempotencyKey: key },
);
if (error) {
// error.name: see the table above,
// or network_error / http_error
console.error(error.name);
console.error(error.message);
} else {
console.log(data.id); // msg_...
}| error.name | statusCode | Meaning |
|---|---|---|
| an API error name | the HTTP status | The API answered with an error; handle it as in the table above. For suppressed, error.id holds the email's id. |
| network_error | 0 | No response: DNS, connection or the SDK timeout. It is unknown whether the email was accepted; retry with the same idempotencyKey. |
| http_error | the HTTP status | An error response that was not BirdRelay JSON, for example from a proxy in between: treat a 5xx like network_error. Also a success status whose body could not be read as a JSON object: the request may have succeeded, so retry with the same idempotencyKey to get its result. |
Statuses
queued → sending → sent → delivered
→ bounced
→ complained
sending → failed
sending → unknown (no automatic retry)
suppressed (at once: recipient blocked)| Status | Meaning |
|---|---|
| queued | Accepted by the API and waiting in the outbox. |
| sending | BirdRelay is handing the message to its delivery network right now. |
| sent | The message was accepted for delivery. This is not yet proof of delivery. |
| delivered | Delivery to the receiving mail server was confirmed. |
| bounced | Hard bounce. The address is added to the suppression list. |
| complained | Spam complaint. The address is added to the suppression list. |
| failed | Permanently refused, or the maximum number of attempts was reached. |
| suppressed | Not sent: a recipient was on the suppression list. |
| unknown | Uncertain whether the message was accepted for delivery (timeout or dropped connection). Never retried automatically: it is resolved by an automatic delivery-status check, or by an explicit owner decision. |
Delivery events
BirdRelay receives signed delivery events from its delivery network. Every event is signature-checked, replays and duplicates are ignored, and delivered, bounced, failed (permanent) and complained events update the email's status. Delivery confirmation (delivered) comes from these events or from BirdRelay's own delivery-status checks.
BirdRelay does not send webhooks to your application yet. To follow an email, read its status with GET /v1/emails/:id or look at the Emails page in the dashboard.
What a delivery problem looks like in the status:
bounced: the receiving server permanently refused the address. It is suppressed; later emails to it get422 suppressed.complained: the recipient marked the email as spam. The address is suppressed as well.failed: permanently refused, all attempts used, or blocked or expired before sending. Not retried; send a new email once the cause is fixed.unknown: the hand-over result is uncertain. Do not send the email again yourself; BirdRelay resolves it (see Troubleshooting).- Staying on
sentmeans no delivery event has arrived yet. That is not a failure by itself.
Bounces, complaints and the suppression list
- A hard bounce sets the email to
bounced; a spam complaint sets it tocomplained. In both cases the address is suppressed, normally on your organization's suppression list. - Sending to a suppressed address is refused with
422 suppressed. The email is recorded with statussuppressedand the response includes itsid, so you can see it in the dashboard. - You see the list on the Problems page of your dashboard. Hard bounces and complaints cannot be removed, to protect your sender reputation; other entries can.
- Complaints and certain hard bounces (such as a mailbox that does not exist) also block the address platform-wide, so one bad address cannot harm every sender.
Limits
Rate limit per project, shared by all its keys (configurable per project, 5 requests per second by default, burst 2×), plus a limit per organization across its projects. Quotas count unique recipients per accepted request: a platform daily quota (100 recipients by default) plus the organization’s daily and monthly limits. Only recipients on the server-side allowlist are accepted.
Resend compatibility
The v1 API follows the shape of Resend's REST API for the parts BirdRelay supports, so moving an existing fetch integration is mostly a change of base URL and key:
- Same:
POST /v1/emailswithfrom,to,cc,bcc,reply_to,subject,html,text,tagsandheaders; the{ "id" }response;GET /v1/emails/:id; theIdempotency-Keyheader; errors as{ "name", "message", "statusCode" }. - Not supported: attachments, scheduled sending, batch sending, audiences/contacts, and the other Resend endpoints. Unknown body fields are rejected with
422 validation_errorrather than ignored. Custom headers must start withX-. - Error names and statuses are BirdRelay's own (see Errors); status values include
unknownandsuppressed. - The official Resend SDKs are not tested against BirdRelay; use
fetch, cURL or the BirdRelay TypeScript SDK (not yet on npm).
Troubleshooting
401 missing_api_key No key sent
Authorization: Bearer … header. Check that BIRDRELAY_API_KEY is set in the server environment that makes the request.403 invalid_api_key Key not accepted
failed without being sent.403 recipient_not_allowed Recipient blocked by the allowlist
MAIL_RECIPIENT_ALLOWLIST). An empty allowlist blocks everyone. This is a safety boundary and cannot be bypassed from the API.422 invalid_from_address / domain_not_verified Sender domain not usable
invalid_from_address: the domain in from is not a sending domain of this organization (or project). domain_not_verified: the domain exists but its domain verification or email authentication is not complete, or it is disabled. Check the Domains page.422 validation_error Multiple sender mailboxes
from must be exactly one mailbox, such as "Name <sender@domain>". Lists (a@x, b@y), groups and comments are rejected.429 rate_limit_exceeded / daily_quota_exceeded / monthly_quota_exceeded Too many requests or recipients
Retry-After. Quotas reset at the start of the next UTC day or UTC calendar month; there are no automatic upgrades or overage.unknown Status is uncertain
sent ≠ delivered Sent but not delivered
sent means the message was accepted for delivery. delivered only appears once delivery is confirmed by a delivery event. If emails stay on sent for a long time, contact support with the email's ID.DNS troubleshooting
A custom sending domain needs two separate kinds of DNS records, and we recommend a third:
- Domain verification record: a TXT record at
_birdrelay-challenge.<domain>whose value is the ownership token shown on the Domains page. It proves you control the domain. BirdRelay only reads public DNS and never changes your records. - Email authentication records: SPF, DKIM and the bounce-handling (MAIL FROM) records, exactly as the DNS wizard generates them. They authorize BirdRelay to send for the domain and let receivers verify your email.
- DMARC (recommended): a TXT record at
_dmarc.<domain>that tells receivers what to do with mail that fails aligned SPF and DKIM checks, and where to send reports. BirdRelay does not create or check this record for you. If you have none yet, start with a monitoring policy such asv=DMARC1; p=none; rua=mailto:dmarc@<your domain>and tighten it once reports look clean. Mailbox providers increasingly expect DMARC from senders.
Email authentication is a separate requirement: a domain can only send when ownership is proven and its SPF and DKIM records are verified.
Propagation delays
Check what public resolvers see
NAME=_birdrelay-challenge.mg.example.com dig +short TXT "$NAME" @1.1.1.1 dig +short TXT "$NAME" @9.9.9.9
“Record not found”
_birdrelay-challenge (or _birdrelay-challenge.mg for a subdomain) instead of the full name.“Incorrect value”
“DNS lookup failed”
Proven domains are re-checked every 24 hours. After 3 consecutive definitive failures (record missing or wrong) the proof is revoked and sending stops. Temporary DNS errors never count.