# Hatched Send API reference (for AI agents) Base URL: https://send.hatched.digital/api/v1 All requests: `Authorization: Bearer $HATCHED_SEND_API_KEY`, JSON bodies, UTF-8. Keys: `sk_live_...` delivers; `sk_test_...` validates, renders and logs (status "test") but never delivers or bills. Responses to test keys include `"test": true`. Never put keys in client-side code or commit them. Store them in env (HATCHED_SEND_API_KEY). ## POST /email — send one email Fields: - from (string, required): address on a verified sending domain - to (string | string[], required): one address, or up to 50 (a list sends a separate email to each) - subject (string, required) - html (string) / text (string) / template_id (uuid): at least one body source - variables (object): values for {{name}} placeholders in subject, html, text and templates - from_name (string): display name, e.g. "Acme via YourApp" - reply_to (string) - cc, bcc (string | string[], up to 20 each): only with a single `to` - tags (string[], max 10) - category ("transactional" default | "marketing"): marketing adds the unsubscribe footer and List-Unsubscribe - sender_ref (string): your id for the business you send for (platforms); each gets its own bounce/complaint counters and can be paused alone - attachments ({ filename, content (base64), content_type }[], up to 5, 10 MB each) - track_opens (bool, default true), track_clicks (bool) Headers: - Idempotency-Key (recommended): same key + same body within 24h returns the first response with `Idempotent-Replayed: true` and sends nothing; same key + different body = 422; while the first is in flight = 409. Response 200: { "id": "", "status": "queued" }. With a `to` list: { "results": [{ id, to, status, reason? }] } in request order. Suppressed recipients (bounced, complained, unsubscribed) are never mailed: if none are left the request fails with 400 `suppressed`; in lists that address gets status "failed: recipient suppressed (unsubscribed/bounced)", reason "suppressed". Suppressed cc/bcc copies are dropped and listed in `suppressed_copies`. ## POST /email/batch — up to 100 different emails Body: { "messages": [ , ... ] }. Response lists every recipient with its own status. ## GET /email/{id}/status Current status (queued, sent, delivered, opened, clicked, bounced, complained, test) and every event. Use it to reconcile a missed webhook. ## Senders (platforms sending for many businesses) - GET /senders?paused=true — senders paused for high bounces/complaints (403 `sender_paused` on send) - POST /senders/resume { "sender_ref": "..." } ## Contacts and audiences (key permission: Write Contacts / Read Contacts) - GET /audiences - POST /contacts { email, audience_id, consent: true (required), first_name?, last_name?, tags? } — upsert, never duplicates; result "created" | "resubscribed" | "updated"; starts "New subscriber" automations - GET /contacts?email= - POST /contacts/unsubscribe { email } — all audiences + suppression - 120 requests a minute per key ## Domains (key permission: Manage Domains) - GET /domains - POST /domains { "domain": "yourapp.com" } — returns DNS records: { type, host, value, action } where action "ok" means already in place - GET /domains/{domain} - POST /domains/{domain}/verify — status "verified" | "pending" Publish the records once. With the email router add-on, the same records also cover the standby provider. ## Webhooks (key permission: Manage Webhooks) - GET /webhooks, POST /webhooks { url (https), events? }, GET /webhooks/{id}, DELETE /webhooks/{id} - The signing secret is returned once on create. Store it as HATCHED_SEND_WEBHOOK_SECRET. - Events: email.sent, email.delivered, email.opened, email.clicked, email.bounced, email.complained, email.unsubscribed, email.inbound, sender.paused - Signature header: X-HatchedSend-Signature-V1: t=,v1=. v1 = hex(HMAC-SHA256(secret, t + "." + rawBody)). Reject if t is older than 5 minutes. Payload `id` is unique per event: drop duplicates. Node verification: ```ts import { createHmac, timingSafeEqual } from "node:crypto"; export function verify(raw: string, header: string, secret: string) { const parts = Object.fromEntries(header.split(",").map((p) => p.split("="))); if (Math.abs(Date.now() / 1000 - Number(parts.t)) > 300) return false; const want = createHmac("sha256", secret).update(`${parts.t}.${raw}`).digest("hex"); return want.length === parts.v1?.length && timingSafeEqual(Buffer.from(want), Buffer.from(parts.v1)); } ``` ## Errors Shape: { "error": { "type": "...", "message": "..." } } - 400 validation_error / invalid_request — fix the request - 400 suppressed — every recipient bounced, complained or unsubscribed; don't retry - 401 authentication_error — missing or wrong key - 402 — workspace setup or billing needs attention before API sends (see the message) - 403 permission_error (key lacks the permission), domain_unverified (from is not on a verified domain), sender_paused (that sender_ref is paused), sending_suspended - 404 not_found — e.g. unknown template_id - 409 idempotency_conflict — the first request with this key is still running; retry later with the same key - 422 idempotency_mismatch — key reused with a different body - 429 rate_limit_error — back off; X-RateLimit-Limit / X-RateLimit-Remaining headers - 5xx — retry with the same Idempotency-Key Rate limits (send requests per minute per key): Free 30, Starter 50, Growth 200, Scale 1,000. ## MCP server URL: https://send.hatched.digital/mcp (Streamable HTTP, OAuth 2.1 with PKCE; sign in and pick workspaces and permissions). Developer tools: create_api_key (mode test|live; write the key into .env, never print it), list_api_keys, add_sending_domain, verify_sending_domain, register_webhook (secret shown once), list_webhooks, plus templates, previews, contacts and campaigns. Campaign sends are two-step with a confirmation code. Setup: - Claude Code: claude mcp add --transport http hatched-send https://send.hatched.digital/mcp - Codex: add [mcp_servers.hatched-send] url = "https://send.hatched.digital/mcp" to ~/.codex/config.toml, then codex mcp login hatched-send - Cursor: ~/.cursor/mcp.json { "mcpServers": { "hatched-send": { "url": "https://send.hatched.digital/mcp" } } } - VS Code: code --add-mcp '{"name":"hatched-send","type":"http","url":"https://send.hatched.digital/mcp"}' ## Plans (USD, monthly, unlimited contacts on every plan) - Free: 1,000 emails a month on us, then $0.0015 per email. New workspaces get 14 days of Growth free, no card - Starter $9: 10,000 emails, 1 sending domain - Growth $29: 50,000 emails, unlimited sending domains, no branding - Scale $149: 200,000 emails, priority support - Add-ons: email router (standby second provider, automatic failover) $29/mo with a 14-day trial