# weir > Transactional email API. One call to send. SMTP delivery with owned retries, DKIM, message logs, and signed webhooks. Base URL: https://weir.itcass.net This file tells an AI agent how to use weir correctly. Prefer the API over guessing behavior. Humans use the dashboard at /app; agents use /v1 with an API key. ## Quick start 1. Confirm the service is up: `GET /health` → `{"ok":true,"smtp":"ok"}`. 2. Use an API key. Keys are created at `/app/keys` by the account owner and start with `sk_live_` or `sk_test_`. They are shown once. Never invent a key. 3. Send: `POST /v1/send` with `Authorization: Bearer `. 4. Poll `GET /v1/messages/{id}` or read the dashboard message page. Test keys start with `sk_test_`. They do not touch SMTP, are marked `sandboxed`, and are not billed. ```bash curl -X POST https://weir.itcass.net/v1/send \ -H "Authorization: Bearer $WEIR_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: welcome-user-42" \ -d '{ "from": "hello@mail.example.com", "to": "you@example.com", "subject": "Hello", "text": "It works." }' ``` Response: `202` with `{"id":"msg_...","status":"queued"}`. ## Authentication - `Authorization: Bearer sk_live_...` or `sk_test_...` - Missing, invalid, or revoked key → `401 unauthorized`. - Keys are account-scoped. A key cannot read another account's messages. ## Preconditions A send succeeds only when all of these are true: 1. The account has a sender identity (`/app/senders`). Otherwise → `400 smtp_identity_missing`. 2. The `from` domain is `active` for the account, or is on the operator allowlist (operator accounts only). Otherwise → `403 domain_not_verified` or `403 domain_pending_activation`. 3. The API key is live. Test keys are sandboxed. Agents cannot create keys, senders, or activate domains. Ask the account owner to do those in the dashboard. ## `POST /v1/send` Headers: `Authorization`, optional `Idempotency-Key`, `Content-Type: application/json`. Body fields: | Field | Type | Required | Notes | |---|---|---|---| | `from` | string | yes | Address or `Name
`. Must be an active domain. | | `to` | string or string[] | yes | Up to 50 recipients. | | `subject` | string | unless template | Max 998 chars, no CRLF. | | `text` | string | one of text/html/template | Plain body. | | `html` | string | one of text/html/template | HTML body. | | `template` | string | no | Template id or name from `/app/templates`. | | `data` | object | no | Variables for `{{name}}` in a template. | | `reply_to` | string | no | Reply address. | | `headers` | object | no | Extra headers. Reserved names and CRLF rejected. | - At most 1 MB request body. - `Idempotency-Key` replays the original message id; it does not send twice. - Failed requests are not stored and not billed. - Rate limit: 120 requests per minute per key. A `429` carries `Retry-After` seconds. ## `GET /v1/messages/{id}` and `GET /v1/messages?limit=50` Returns account-scoped messages: ```json { "id": "msg_...", "status": "delivered", "from": "hello@mail.example.com", "to": ["you@example.com"], "subject": "Hello", "created_at": "2026-11-29T14:02:11.000Z", "attempts": 1, "last_error": null } ``` `limit` is 1–100, default 50. ## Status meanings The six status words are fixed: - `queued` — accepted, waiting for delivery. - `delivered` — the relay accepted the message. This is not proof of inbox placement. - `deferred` — temporary failure; retrying. - `bounced` — permanent SMTP failure; not retried. - `expired` — the 72-hour retry window ended before acceptance. - `sandboxed` — test-key message; never sent over SMTP. Retries: transient failures retry for 72 hours on a backoff of 1, 5, 15, 60, 180, 360, 720, 1440 minutes with jitter. After 72 hours the message becomes `expired` with `window_exhausted`. ## Domains `POST /v1/domains` with `{"domain":"mail.example.com"}` returns five DNS records: ```json { "id": "dom_...", "domain": "mail.example.com", "status": "pending_dns", "records": [ {"type":"MX","name":"mail.example.com","value":" ."}, {"type":"TXT","name":"mail.example.com","value":"v=spf1 a: ~all"}, {"type":"TXT","name":"_dmarc.mail.example.com","value":"v=DMARC1; p=none; rua=mailto:"}, {"type":"TXT","name":"weir._domainkey.mail.example.com","value":"v=DKIM1; k=rsa; p="}, {"type":"TXT","name":"_weir.mail.example.com","value":"weir-verify="} ] } ``` The shape above is illustrative. Use exactly the values returned by the API; do not publish the placeholders. Lifecycle: - `pending_dns` → publish all records, then `POST /v1/domains/{id}/verify`. - `pending_activation` → DNS verified; sending still blocked. An operator adds the domain to the mail host and activates it at `/ops/domains`. - `active` → sending allowed. - `suspended` → sending blocked. Verify needs both the DKIM TXT and the verification TXT. Activation additionally checks MX, SPF, and DMARC (absent DMARC is a warning; invalid DMARC blocks). Do not claim a domain is usable until its status is `active`. ## Sender identities One relay, multiple mailboxes. Each identity has its own SMTP login, From address, and bounce address, managed at `/app/senders`. An API key alone is not enough; the account needs a default identity. ## Templates All require the same API key: - `GET /v1/templates` - `POST /v1/templates` — `{name, subject, text?, html?}` - `PATCH /v1/templates/{id}` - `DELETE /v1/templates/{id}` Send with `template` plus optional `data`. Placeholders use `{{variable}}`; unknown variables render empty. ## Webhooks Register at `/app/webhooks`. Events are one HTTPS POST with: ```json { "event": "delivered", "id": "evt_...", "messageId": "msg_...", "detail": "250 2.0.0 Ok: queued as 4F2C", "at": "2026-11-29T14:02:11Z" } ``` Events: `delivered`, `deferred`, `bounced`, `expired`, `rejected_recipient`. Verify `Weir-Signature: t=,v1=` as HMAC-SHA256 over `timestamp + "." + rawBody` using the endpoint secret. Reject requests older than five minutes. HTTPS only; private addresses are rejected. ## Errors ```json {"error":{"code":"domain_not_verified","message":"Domain not active. Add the domain, publish the records, then wait for activation."}} ``` | Code | HTTP | Meaning | |---|---|---| | `invalid_request` | 400 | Validation failed; read the message. | | `unauthorized` | 401 | Missing or invalid key. | | `domain_not_verified` | 403 | Domain not active for this account. | | `domain_pending_activation` | 403 | DNS verified; waiting for operator activation. | | `smtp_identity_missing` | 400 | Add a sender identity in the dashboard. | | `not_found` | 404 | Message, domain, or template not in this account. | | `rate_limited` | 429 | Wait `Retry-After` seconds. | ## Agent rules - Ask for an API key; never fabricate one or reuse another account's key. - Use `sk_test_` for trials. Only switch to live after the user confirms. - Poll the message id; do not assume delivery. - Do not claim a domain works before `active`. - Do not invent pricing, volumes, or delivery numbers. Pricing: $0.40 per 1,000 emails, published at /pricing.html. - Report the fixed status words and error codes exactly. - For migrations, point the base URL at `https://weir.itcass.net/v1` and keep existing payloads. ## Links - Docs: https://weir.itcass.net/docs.html - Pricing: https://weir.itcass.net/pricing.html - Status: https://weir.itcass.net/status - Dashboard: https://weir.itcass.net/app - This file: https://weir.itcass.net/llms.txt