SendForAI

Send transactional and broadcast email from your own domain through Claude or any MCP client, at Amazon SES cost. The agent sets itself up (no API key to paste); bulk broadcasts wait for human approval. First 3,000 emails/month free. Not for inboxes or open/click tracking.

託管 MCP 伺服器

npx add-mcp 'https://sendforai.com/mcp'

可安裝到 Claude Code、Codex、Cursor 等客戶端

文件

SendForAI docs

SendForAI is one JSON API for transactional email (one message to one person) and broadcasts (one message to a list), built so an AI agent can set it up and run it. Amazon SES underneath, sold at cost.

There are no API keys to request and no dashboard. Your identity is an Ed25519 key. The first authenticated request creates the account.

Fastest start (no domain, no DNS, no human)

npx sendforai sandbox
# -> { "domain": "k3f9c...sandbox.sendforai.com", "key_file": "~/.sendforai/k3f9c....key" }

npx sendforai send \
  --from agent@k3f9c...sandbox.sendforai.com \
  --to delivered@simulator.sendforai.com \
  --subject "Hello" --markdown "It works."

A sandbox identity can use the whole API, but only reaches the simulator. To send real email, add a domain you control (see "Domains").

The CLI prints JSON and never prompts. npx sendforai --help lists every command.

The same start in Python, no npm (pip install cryptography)

import base64, hashlib, json, time, urllib.request
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey

API = "https://api.sendforai.com"

# 1. A key, and the sandbox identity named after it. Save the PEM somewhere private.
key = Ed25519PrivateKey.generate()
pem = key.private_bytes(serialization.Encoding.PEM, serialization.PrivateFormat.PKCS8, serialization.NoEncryption())
pub = key.public_key().public_bytes(serialization.Encoding.Raw, serialization.PublicFormat.Raw)
domain = "k" + hashlib.sha256(pub).hexdigest()[:24] + ".sandbox.sendforai.com"

# 2. A connection token, signed locally. Nothing is registered anywhere first.
b64u = lambda b: base64.urlsafe_b64encode(b).rstrip(b"=").decode()
now = int(time.time())
payload = {"d": domain, "iat": now, "exp": now + 30 * 86400, "p": base64.b64encode(pub).decode()}
signed = "sfat1." + b64u(json.dumps(payload).encode())
token = signed + "." + b64u(key.sign(signed.encode()))

# 3. Send to the simulator. The first authenticated request creates the account.
body = json.dumps({"from": f"agent@{domain}", "to": "delivered@simulator.sendforai.com",
                   "subject": "Hello", "markdown": "It works."}).encode()
req = urllib.request.Request(API + "/v1/emails", data=body, method="POST",
                             headers={"Authorization": "Bearer " + token, "content-type": "application/json"})
print(json.load(urllib.request.urlopen(req))["status"])   # "sent"

Keep pem (the private key) and reuse it: the same key always gives the same sandbox identity and account.

Ways to connect

You areUse
A shell-driven agentnpx sendforai <command>
Node codenpm i @sendforai/sdk
An MCP client that can run a local processnpx -y @sendforai/mcp (see "MCP")
An MCP client that connects to a URLhttps://sendforai.com/mcp with a connection token (see "MCP")
Any other language, curl, no-code toolsPlain HTTP with a connection token (see "Signing")

Sandbox

A sandbox identity is named after its own key, so it needs no DNS:

k<first 24 hex chars of sha256(raw 32-byte public key)>.sandbox.sendforai.com
  • Sign requests exactly as for a domain (below), with that name as the domain.
  • On signed requests also send SendForAI-Public-Key: <raw public key, base64>. Connection tokens for sandbox identities already carry the key.
  • Sends are accepted only to @simulator.sendforai.com. Anything else returns 409 sandbox_identity with the steps to add a real domain.
  • Simulator addresses: delivered@, bounced@, complained@ produce email.delivery, email.bounce and email.complaint events, the same names real mail produces. Any other local part is delivered. Simulated sends are free, never leave SendForAI, and are not capped.
  • Adding a real domain to a sandbox account keeps the same key, balance and contacts.

Signing

Two credentials are accepted. Both prove you hold the identity's private key.

Option 1: connection token (simplest for curl and other languages)

A token is minted locally with the private key. Nothing is stored on the server. It expires on its own (30 days by default, 90 at most) and stops working if the key is rotated. Treat it like a password.

TOKEN=$(npx sendforai token --days 30 | jq -r .token)

curl https://api.sendforai.com/v1/emails \
  -H "Authorization: Bearer $TOKEN" -H "content-type: application/json" \
  -d '{"from":"hi@example.com","to":"ada@example.org","subject":"Hello","markdown":"Hi.","max_cost_usd":0.01}'

Format, if you mint it yourself: sfat1.<payload>.<signature>

  • payload = base64url (no padding) of the JSON {"d":"<identity domain>","iat":<unix seconds>,"exp":<unix seconds>}. Sandbox identities add "p":"<raw public key, base64>".
  • signature = base64url (no padding) of the Ed25519 signature over the ASCII bytes of sfat1.<payload>.
  • exp - iat may be at most 7,776,000 seconds (90 days).

Python (pip install cryptography):

import base64, json, time
from cryptography.hazmat.primitives import serialization

key = serialization.load_pem_private_key(open("sendforai.key", "rb").read(), password=None)
b64u = lambda b: base64.urlsafe_b64encode(b).rstrip(b"=").decode()
now = int(time.time())
signed = "sfat1." + b64u(json.dumps({"d": "example.com", "iat": now, "exp": now + 30 * 86400}).encode())
token = signed + "." + b64u(key.sign(signed.encode()))

Option 2: sign every request

Send three headers:

SendForAI-Domain: example.com
SendForAI-Timestamp: <unix seconds, within 300s of server time>
SendForAI-Signature: sfa1=<base64 Ed25519 signature>

The signature is over this string, six lines joined by \n, no trailing newline:

sfa1
<METHOD, uppercase>
<path including query string, e.g. /v1/events?limit=10>
<the same timestamp>
<domain, lowercase>
<SHA-256 of the exact request body bytes, lowercase hex; for an empty body, the hash of the empty string>

Python:

import base64, hashlib, json, time, urllib.request
from cryptography.hazmat.primitives import serialization

key = serialization.load_pem_private_key(open("sendforai.key", "rb").read(), password=None)
domain, method, path = "example.com", "POST", "/v1/emails"
body = json.dumps({"from": "hi@example.com", "to": "ada@example.org", "subject": "Hello", "text": "Hi."}).encode()
ts = str(int(time.time()))
canonical = "\n".join(["sfa1", method, path, ts, domain, hashlib.sha256(body).hexdigest()])
sig = base64.b64encode(key.sign(canonical.encode())).decode()
req = urllib.request.Request("https://api.sendforai.com" + path, data=body, method=method, headers={
    "SendForAI-Domain": domain, "SendForAI-Timestamp": ts, "SendForAI-Signature": "sfa1=" + sig,
    "content-type": "application/json"})
print(urllib.request.urlopen(req).read().decode())

Shell (OpenSSL 3 or newer):

openssl genpkey -algorithm ed25519 -out sendforai.key
PUB=$(openssl pkey -in sendforai.key -pubout -outform DER | tail -c 32 | base64)   # goes in DNS

DOMAIN=example.com; METHOD=GET; REQ_PATH=/v1/account; BODY=''
TS=$(date +%s)
HASH=$(printf '%s' "$BODY" | openssl dgst -sha256 -hex | sed 's/^.*= //')
printf 'sfa1\n%s\n%s\n%s\n%s\n%s' "$METHOD" "$REQ_PATH" "$TS" "$DOMAIN" "$HASH" > /tmp/sfa-canonical
SIG=$(openssl pkeyutl -sign -inkey sendforai.key -rawin -in /tmp/sfa-canonical | base64 | tr -d '\n')
curl "https://api.sendforai.com$REQ_PATH" \
  -H "SendForAI-Domain: $DOMAIN" -H "SendForAI-Timestamp: $TS" -H "SendForAI-Signature: sfa1=$SIG"

Node: new SendForAI({ domain, privateKey }) from @sendforai/sdk signs for you. SendForAI.sandbox() returns a ready client with a new sandbox identity.

Domains

Identity domain

Publish the public key (raw 32 bytes, base64) as a TXT record. Whoever controls the domain's DNS controls the account.

_sendforai.example.com  TXT  "v=sfa1; k=ed25519; p=<public key>"

GET /v1/domains/{domain}/setup?p=<public key> (public) returns the exact record. npx sendforai init example.com generates the key and prints it.

Sending records

To send real mail, Amazon SES also needs DKIM and MAIL FROM records. POST /v1/domains/{domain}/verify creates the SES identity and returns them; GET /v1/domains/{domain} shows their status. Until SES has verified the domain, a send returns 409 domain_not_verified listing the records still missing.

Automatic DNS

With a Vercel or Cloudflare token in the environment (VERCEL_TOKEN plus VERCEL_TEAM_ID for team domains, or CLOUDFLARE_API_TOKEN), one call publishes the identity or delegation record, the DKIM and MAIL FROM records, and a DMARC record if the domain has none. The token is used on your machine and is never sent to SendForAI. Safe to run again.

npx sendforai dns setup --domain example.com --wait

SDK: sfa.dns.setup({ provider: dnsProviderFromEnv(), waitForVerification: true }). Local MCP: setup_dns. On any other DNS host, GET /v1/domains/{domain} lists the records for a person to add.

More domains on one account (and graduating from a sandbox)

One key can send for up to 50 domains. On each extra domain publish a delegation record pointing at your identity (a domain, or a sandbox name), then add it:

_sendforai.news.example.org  TXT  "v=sfa1; delegate=<your identity domain>"
npx sendforai domains add news.example.org      # POST /v1/domains {"name": "..."}
npx sendforai domains verify news.example.org   # DKIM + MAIL FROM records to publish

Subdomains of a domain you have are covered automatically. Balance and allowance are shared; reputation, warmup and daily caps stay per domain.

Send an email

POST /v1/emails

FieldNotes
fromAn address on any of the account's domains. "Name <a@b.com>" is allowed.
toOne address or an array of up to 50.
subjectUp to 998 characters.
markdown, html, textAt least one. Markdown is rendered to HTML with a plain-text part.
reply_to, headersOptional.
streamtransactional (default) or broadcast (adds one-click unsubscribe).
dry_runtrue plans the send: cost, capacity and lint warnings, nothing sent.
max_cost_usdThe send is refused with 402 if it would bill more.
idempotency_keyA retry with the same key returns the original result; nothing is sent twice.

Response (201):

{
  "id": "3f9c2a7e-...",
  "status": "sent",
  "recipients": [{ "to": "ada@example.org", "status": "accepted" }],
  "cost": { "emails": 1, "ses_usd": 0.0001, "billed_usd": 0.00011, "included_remaining": 0, "note": "..." },
  "capacity": { "daily_cap": 1000, "remaining_today": 999 },
  "lint": [],
  "receipt": "<signed record of what was sent and billed>"
}

Addresses that previously bounced, complained or unsubscribed come back with status suppressed and are not sent to. A dry run of a send that would start a paid month shows cost.month_fee_usd.

Money

  • 3,000 emails free every month. Then $10, and every email after that at cost.
  • Free: the first 3,000 emails every month, up to 100 a day, to anyone, from a verified domain. No card. Per account, across all its domains. Simulated sends to @simulator.sendforai.com are unlimited and never count.
  • The first send in a calendar month (UTC) that would go past 3,000 that month or 100 in a day starts a paid month: $10 from the prepaid balance. The first 3,000 that month stay free. Months under the free limits cost $0.
  • Every email after the free 3,000: $0.11 per 1,000.
  • GET /v1/account returns the balance, the budget used and remaining, usage, every domain, and next_action: add_domain (sandbox-only account), add_credit or raise_budget when something stands in the way of sending past the free allowance, otherwise null. Check it before the first real send.
  • Every dry run ("dry_run": true) includes funding: ok, needed_usd (month fee plus usage), balance_after_usd, and when ok is false a ready checkout_url or approval_url for your operator. Ask for money before sending, not after a failure.
  • POST /v1/account/topup {"amount_usd": 10, "auto_topup": true} returns a checkout_url. Hand it to a person; this is the one step that needs a human. account.topped_up appears in the event log when they pay.
  • Usage charges in a month never exceed the budget ($20 by default). POST /v1/account/budget {"monthly_usd": n}: lowering applies immediately; raising returns an approval_url for a person.
  • POST /v1/account/auto-topup {"enabled": false} turns auto top-up off or changes its amount. GET /v1/account/billing returns a billing portal link for a person.

Operator page

People never log in. When the person who runs the account wants to see it or manage the money, GET /v1/account/operator-link (MCP operator_link, CLI sendforai operator) returns { "url", "expires_at", "fix" }: a signed link to /operator, valid 7 days. Hand url to them and do not open it yourself. The page shows the balance, this month's plan and free emails left, the budget, auto top-up, every domain with its status and daily cap, the last 25 sends and the last 7 days' bounces and complaints. From it they can add credit ($10 to $100, optionally turning on auto top-up), set the monthly budget (raising is allowed there, because a person is clicking), turn auto top-up on or off, open the billing portal, and set the operator email. Anyone with the link can do those things until it expires, so give it only to the operator.

The operator email (taken from the first Stripe payment, or set on the operator page) gets short notices: a domain or the account paused, a failed auto top-up, the balance under $1 with auto top-up off, and a receipt when credit is added. At most one of each kind a day; each includes a fresh operator link. Removing the address on the operator page stops them.

Contacts and broadcasts

  • POST /v1/contacts upserts one contact by email (data is any JSON you can filter on; subscribed flag). GET /v1/contacts pages with limit and cursor. POST /v1/contacts/unsubscribe. POST /v1/contacts/import takes up to 10,000 per call in a paid month. Contacts are unlimited and free.
  • POST /v1/broadcasts creates a broadcast to every subscribed contact, or those matching filter. By default it is awaiting_approval and returns an approval_url for a person to click. Pass require_approval: false if your workflow has its own sign-off.
  • POST /v1/broadcasts/{id}/send starts an approved broadcast in the background (202). GET /v1/broadcasts/{id} shows status and progress (sent, queued, failed, cancelled, resumes_at). POST /v1/broadcasts/{id}/cancel stops it, also mid-send; the unsent part is refunded.

Events

GET /v1/events?cursor=&limit=&type= is a pullable log, so no webhook endpoint is needed. Keep next_cursor and pass it back to get only what is new. Types include email.sent, email.delivery, email.bounce, email.complaint, email.failed, broadcast.awaiting_approval, broadcast.approved, broadcast.rejected, broadcast.sending, broadcast.deferred, broadcast.sent, broadcast.cancelled, account.month_started, account.topped_up, account.budget_changed, account.auto_topup_failed, domain.added, domain.paused, contacts.imported and contact.unsubscribed.

Capacity and warmup

GET /v1/capacity returns today's cap, what has been sent, what remains and when it resets. GET /v1/usage returns the month so far. New sending domains start with a daily cap that rises in stages while bounce and complaint rates stay low. A domain, or a whole account, whose rates get too high is paused, and the error says how to clean the list.

Broadcasts warm up automatically:

  • A new sending domain starts at 1,000 emails a day in a paid month and steps up (5,000, 25,000, 100,000, 500,000, then unlimited) at most once a week, when it has sent at least 500 emails (or its whole cap) in the last 7 days with bounces under 2% and complaints under 0.05%.
  • Broadcasts use at most 80% of a domain's daily cap. The rest (at least 50 sends, never more than half the cap) stays free for transactional email, so a newsletter can never block sign-in links or receipts.
  • Each day's broadcast share is spread evenly over the remaining hours of the UTC day instead of going out in one burst.
  • A broadcast bigger than what's left today keeps going on its own. GET /v1/broadcasts/{id} shows progress.resumes_at, and the event log records broadcast.deferred with a reason of daily_cap, transactional_reserve or hourly_pace.

Example: 20,000 contacts from a brand-new domain go out at about 800 a day in hourly slices, faster as the cap steps up.

Rate limits

Fixed windows. Going over returns 429 rate_limited with a Retry-After header (seconds); wait that long and retry the same request.

WhatLimit
Authenticated requests600 per minute per account
POST /v1/emails120 per minute per account (on top of the above). Put up to 50 recipients in one send, or use a broadcast.
Public endpoints (GET /v1, /v1/pricing, /v1/status, /v1/domains/{domain}/setup) and failed authentication120 per minute per IP
New accounts (first request from a new identity)20 per hour per IP; 200 new sandbox accounts per hour across all users
Hosted MCP (/mcp)300 per minute per connection token (per IP without one)
{ "error": { "code": "rate_limited", "message": "Rate limit reached: ...", "fix": "Wait 12 seconds (the Retry-After header) and retry the same request. ...", "details": { "limit": 120, "window_seconds": 60, "retry_after_seconds": 12 }, "docs": "https://sendforai.com/docs.md#rate-limits" } }

Errors

Every error has the same shape, and fix is written for an agent to act on:

{ "error": { "code": "balance_required", "message": "...", "fix": "...", "details": {}, "docs": "..." } }
Status and codeWhat to do
401 unauthenticatedSign the request or send a valid token. details says what was wrong (clock, key mismatch, missing DNS record).
400 bad_requestFix the fields in details.issues. If from is not on your domains, details.record is the delegation record to publish.
402 balance_requiredNothing was sent. Give details.checkout_url (a ready Stripe Checkout link, 24 hours) to your operator; retry with the same idempotency_key after account.topped_up. Simulator sends and the free 3,000 a month (100 a day) keep working.
402 budget_exceededNothing was sent. Give details.approval_url to your operator to raise the budget, send less, or wait for next month.
402 max_cost_exceededThe request would cost more than its own max_cost_usd (usage, or the $10 fee that starts a paid month). Raise max_cost_usd or send to fewer recipients. A dry run refuses the same way.
409 sandbox_identitySandbox identities only reach the simulator. Add a real domain.
409 domain_not_verifiedPublish the records in details.records, then verify again.
409 (other codes)The broadcast needs approval, a domain is taken, or the domain limit is reached; the fix says which.
422 send_rejectedAmazon SES refused every recipient. Nothing was sent or billed. details.recipients has the reason per address.
429 capacity_exceededToday's cap is used. details.resets_at says when it resets.
429 rate_limitedToo many requests in the window. Wait Retry-After seconds (details.retry_after_seconds) and retry. See "Rate limits".
404 not_foundUnknown endpoint or id.

MCP

Hosted (nothing to install; Streamable HTTP):

{
  "mcpServers": {
    "sendforai": {
      "url": "https://sendforai.com/mcp",
      "headers": { "Authorization": "Bearer <connection token>" }
    }
  }
}

Claude Code: claude mcp add --transport http sendforai https://sendforai.com/mcp --header "Authorization: Bearer <connection token>"

Get the token with npx sendforai token. The hosted server authenticates with that bearer token, not OAuth; a client that only supports OAuth connectors should use the local server. npx sendforai mcp prints both configs filled in.

Local (holds the key itself, and adds generate_identity, setup_dns and create_connection_token):

{
  "mcpServers": {
    "sendforai": {
      "command": "npx",
      "args": ["-y", "@sendforai/mcp"],
      "env": { "SENDFORAI_DOMAIN": "example.com", "SENDFORAI_PRIVATE_KEY_FILE": "/path/to/sendforai.key" }
    }
  }
}

No identity yet? Start the local server without env and call generate_identity (omit domain for a sandbox identity).

Tools: whoami, get_account, get_pricing, get_capacity, get_usage, plan_email, send_email, list_domains, add_domain, get_domain_status, verify_domain, upsert_contact, list_contacts, import_contacts, create_broadcast, get_broadcast, send_broadcast, cancel_broadcast, add_credit, set_budget, set_auto_topup, billing_portal, operator_link, list_events.

Claude Code plugin

The plugin adds the SendForAI skill (the whole set-up-and-send workflow) and the local MCP server:

/plugin marketplace add https://sendforai.com/marketplace.json
/plugin install sendforai@sendforai

From a shell: claude plugin install sendforai --marketplace https://sendforai.com/marketplace.json. The skill on its own is at https://sendforai.com/skill.md.

Limits worth knowing

  • SendForAI sends email; it does not receive it. There are no inboxes.
  • The SDK is Node only. Other languages use plain HTTP with a connection token.
  • New sending domains warm up, so a new domain cannot take a large volume on day one.
  • Open and click tracking are not offered.

Endpoint list

EndpointAuthWhat it does
GET /v1publicIndex of docs, spec, MCP and status.
GET /v1/pricingpublicPricing as JSON.
GET /v1/statuspublicHealth check.
GET /v1/domains/{domain}/setup?p=publicThe identity TXT record for a public key.
POST /v1/emailsyesSend, or plan with dry_run.
GET /v1/accountyesBalance, budget, usage, domains.
POST /v1/account/topupyesCheckout link for a person to add credit.
POST /v1/account/budgetyesLower the budget, or get an approval link to raise it.
POST /v1/account/auto-topupyesTurn auto top-up off or change its amount.
GET /v1/account/billingyesBilling portal link for a person.
GET /v1/account/operator-linkyesSigned 7-day link to the operator page for a person.
GET /v1/domains, POST /v1/domainsyesList and add sending domains.
GET /v1/domains/{domain}yesIdentity and SES status, records to publish.
POST /v1/domains/{domain}/verifyyesCreate the SES identity; returns DKIM and MAIL FROM records.
GET /v1/capacity, GET /v1/usageyesToday's cap; month to date.
POST /v1/contacts, GET /v1/contactsyesUpsert and list contacts.
POST /v1/contacts/import, POST /v1/contacts/unsubscribeyesBulk import; unsubscribe.
POST /v1/broadcasts, GET /v1/broadcasts/{id}yesCreate and read a broadcast.
POST /v1/broadcasts/{id}/send, POST /v1/broadcasts/{id}/cancelyesStart and cancel.
GET /v1/eventsyesEvent log.

Questions: hello@sendforai.com. Abuse reports: abuse@sendforai.com.