Gateway API reference
For applications integrating with the sendpetrel gateway. Base URL https://api.sendpetrel.com — JSON in, JSON out, errors as RFC 9457 problem documents.
/openapi.json is authoritative.All endpoints
Every /v1 route needs an API key; the scope column names the permission the key must carry ("any key" means any valid key of the tenant). Resources are always scoped to the key's own tenant — another tenant's id answers 404.
Health
/health/livepublicThe API process is up.
/health/readypublicDatabase reachable and delivery provider connected.
Sending domains
/v1/sending-domainsdomains:writeRegister a domain you intend to send from.
/v1/sending-domainsany keyList your domains and their status.
/v1/sending-domains/{domain_id}any keyRead one domain.
/v1/sending-domains/{domain_id}/dns-recordsdomains:readThe DNS records to publish and their last-checked status.
/v1/sending-domains/{domain_id}/verification-checksdomains:writeCheck the published records now.
/v1/sending-domains/{domain_id}/verification-checksdomains:readThe 20 most recent checks.
Messages and events
/v1/messagesmessages:writeSubmit a message (requires Idempotency-Key); answers 202.
/v1/messagesany keyList your messages, newest first.
/v1/messages/{message_id}any keyCurrent state of one message.
/v1/messages/{message_id}/eventsmessages:readOne message's state history, oldest first.
/v1/eventsmessages:readRecipient-level outcomes for your tenant, newest first, cursor-paged.
/v1/usagemessages:readCurrent per-minute and per-day usage against your limits.
Suppressions
/v1/suppressionssuppressions:readAddresses that will not receive your mail, filterable by reason.
/v1/suppressionssuppressions:writeSuppress an address manually.
/v1/suppressions/{address}suppressions:writeLift a manual or soft-bounce suppression (hard bounces and complaints are operator-only).
Unsubscribes rolling out
/v1/unsubscribesunsubscribes:readOpt-outs from your marketing mail, by topic, cursor-paged.
/v1/unsubscribesunsubscribes:writeRecord an opt-out you received elsewhere.
/v1/unsubscribes/{address}unsubscribes:writeRe-subscribe an address; requires a consent_reference, which is audited.
/u/{token}publicUnsubscribe confirmation page linked from marketing mail (never unsubscribes by itself).
/u/{token}publicRFC 8058 one-click unsubscribe used by mail apps.
Authentication
Every request carries the integration's API key as a bearer token. Keys are scoped (for example messages:write, domains:read) and act only within their own tenant.
Authorization: Bearer edg_yourprefix_…
Keys are shown once when issued and stored only as a hash. If a key leaks, it is revoked and a new one issued.
Sending domains
Before you can send from a domain it must be verified:
POST /v1/sending-domainswith{"domain": "example.com"}.GET /v1/sending-domains/{domain_id}/dns-recordsreturns the records to publish: an ownership TXT, an SPF include, a per-domain DKIM key, a return-path CNAME and (recommended) DMARC.POST /v1/sending-domains/{domain_id}/verification-checkschecks them. When everything passes, the domain is reviewed and enabled for sending.
Sending a message
# send one message
curl https://api.sendpetrel.com/v1/messages \
-H "Authorization: Bearer $SENDPETREL_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1042-receipt" \
-d '{
"from": "Example Shop <orders@example.com>",
"to": ["customer@example.org"],
"subject": "Your receipt",
"text": "Thanks for your order.",
"html": "<p>Thanks for your order.</p>"
}'
The response is 202 Accepted with a message_id. Repeating a request with the same Idempotency-Key and body returns the original result instead of sending again.
| Field | Notes |
|---|---|
from | An address on one of your verified domains, optionally with a display name. |
to | Up to 50 recipients. |
subject, text, html | At least one of text or html; the whole message up to 200 KB. |
reply_to, headers, tags | Optional. tags are returned with events. |
category | transactional (default) or marketing. Marketing mail gets List-Unsubscribe / List-Unsubscribe-Post (RFC 8058) headers automatically and must be addressed to a single recipient. |
unsubscribe_topic | Optional topic for marketing mail, e.g. newsletter; recipients can unsubscribe from one topic or from everything. |
Delivery status and events
GET /v1/messages/{message_id} returns the current state; GET /v1/messages/{message_id}/events its history; GET /v1/events recipient-level outcomes for your account, newest first and cursor-paged.
| State | Meaning |
|---|---|
queued | Accepted by the API, waiting for the delivery worker. |
sent | Handed to the mail server; the receiving server has not answered yet. |
delivered | The recipient's mail server accepted the message. |
deferred | A temporary failure; it will be retried. |
bounced / failed | Permanently undeliverable. Hard bounces suppress the address. |
Suppressions and unsubscribes
GET /v1/suppressions lists addresses that will not receive your mail (hard bounces, complaints, manual entries). POST /v1/suppressions adds one; DELETE /v1/suppressions/{address} lifts a manual or soft-bounce entry.
Unsubscribes from marketing mail are kept per account and topic: GET, POST and DELETE /v1/unsubscribes. Re-subscribing someone requires a reference to their consent. Unsubscribes never block transactional mail.
Limits
Each account has a per-minute rate limit and a daily quota; GET /v1/usage shows the current window. Requests over the limit get 429 with Retry-After.