BirdRelay

API Reference

Version v1 · Base URL https://api.birdrelay.com

Quickstart

  1. Create an API key on the API keys page. Keys belong to one project and are shown only once.
  2. 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.
  3. 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 with fetch from 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();
  4. 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.

StatusWho can receiveHow you get it
SandboxOnly 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.
ProductionAny 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 failed without 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.

nameHTTPMeaningRetry?
validation_error422Invalid 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_key401No Authorization: Bearer header.No. Send the key.
invalid_api_key403Unknown or revoked key.No. Use a valid key.
recipient_not_allowed403A recipient is not on the server-side allowlist.No.
recipient_not_allowed_in_sandbox403Your 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_activated403Sending is not enabled for this organization.No, until BirdRelay enables sending.
subscription_inactive403The organization has no active subscription.No, until the subscription is active.
idempotency_conflict409Idempotency-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_found404The email does not exist in this project.No.
invalid_from_address422The sender domain is not an allowed sending domain for this project.No. Use one of your sending domains.
domain_not_verified422The 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).
suppressed422A 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_exceeded429Too 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_exceeded429Daily 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_exceeded429Monthly 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_error500Unexpected error.Yes, with the same Idempotency-Key.
provider_unavailable503Email sending is temporarily unavailable for this domain. Nothing was queued.Yes, later.

A 500, a timeout or a dropped connection

Then you cannot tell whether the email was accepted. Repeat the request within 24 hours with the same Idempotency-Key and the same body: if the first request was accepted you get its 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

Retry only where the table says yes, with a growing pause (for example 1, 5 and 30 seconds) and a limit. Other 4xx errors get the same answer until you change something.

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.namestatusCodeMeaning
an API error namethe HTTP statusThe API answered with an error; handle it as in the table above. For suppressed, error.id holds the email's id.
network_error0No response: DNS, connection or the SDK timeout. It is unknown whether the email was accepted; retry with the same idempotencyKey.
http_errorthe HTTP statusAn 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)
StatusMeaning
queuedAccepted by the API and waiting in the outbox.
sendingBirdRelay is handing the message to its delivery network right now.
sentThe message was accepted for delivery. This is not yet proof of delivery.
deliveredDelivery to the receiving mail server was confirmed.
bouncedHard bounce. The address is added to the suppression list.
complainedSpam complaint. The address is added to the suppression list.
failedPermanently refused, or the maximum number of attempts was reached.
suppressedNot sent: a recipient was on the suppression list.
unknownUncertain 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 get 422 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 sent means 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 to complained. 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 status suppressed and the response includes its id, 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/emails with from, to, cc, bcc, reply_to, subject, html, text, tags and headers; the { "id" } response; GET /v1/emails/:id; the Idempotency-Key header; 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_error rather than ignored. Custom headers must start with X-.
  • Error names and statuses are BirdRelay's own (see Errors); status values include unknown and suppressed.
  • 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

The request has no 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

The key is unknown, mistyped or revoked. Keys are only shown once; if you lost it, create a new key and revoke the old one. Revoking a key also stops the messages it queued that were not sent yet: they end as failed without being sent.

403 recipient_not_allowed Recipient blocked by the allowlist

BirdRelay only sends to addresses on the server-side 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

For the rate limit, wait for the number of seconds in 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

The hand-over timed out or the connection dropped, so it is unclear whether the message was accepted for delivery. BirdRelay never resends automatically. An automatic delivery-status check runs first; if that gives no answer, the owner decides on the email’s detail page to resend (with a duplicate risk) or mark it as failed.

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 as v=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

New or changed records can take minutes to hours to become visible, depending on your DNS provider and the record’s TTL. Wait and check again; ownership checks are rate limited per organization.

Check what public resolvers see

BirdRelay looks up the ownership record through public resolvers (1.1.1.1 and 9.9.9.9 by default), not your local DNS. Check the same way:
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”

The resolver found no TXT record at that name. Check the host name: many DNS panels add the domain automatically, so enter only _birdrelay-challenge (or _birdrelay-challenge.mg for a subdomain) instead of the full name.

“Incorrect value”

A TXT record exists, but none of its values exactly matches the token. Remove extra quotes, spaces or an old token and paste the value again.

“DNS lookup failed”

The lookup timed out or the resolver returned an error. Nothing was changed; try again later. Persistent failures usually point to a problem with the domain’s name servers.

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.