Docs
API and webhooks
Create a key, send emails, manage campaigns, and verify webhook signatures.
- 1
Create a key
Settings › API & webhooks. Copy it once.
- 2
Send the header
Authorization: Bearer or X-API-Key.
- 3
Check the key
GET /backend/v1/me returns workspace and limits.
Authentication
Every endpoint requires an API key via one of these headers:
Authorization: Bearer mw_live_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX # or X-API-Key: mw_live_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Keys are scoped to a single workspace, limited by permissions, IP allowlist, rate limit, and daily/monthly caps.
GET /v1/me
Returns workspace info, key details, usage, and limits. No special permission required — any valid key works.
curl -H "Authorization: Bearer YOUR_KEY" https://mailwright.tech/backend/v1/me
Response shape:
| Field | Type | Description |
|---|---|---|
| workspace.id | uuid | Workspace ID |
| workspace.code | string | Workspace code |
| workspace.name | string | Workspace display name |
| workspace.plan | string | Plan tier |
| key.name | string | Key name |
| key.prefix | string | Key prefix (for identification) |
| key.permissions | array | Granted permissions list |
| key.rate_limit_per_minute | number | Per-key request rate limit |
| usage.key.sends_today | number | Sends by this key today |
| usage.key.sends_month | number | Sends by this key this month |
| usage.account_month | object | Monthly usage snapshot for the account |
| usage.account_sends_today | number | Account sends today |
| limits.plan | object | Plan-level send limits |
GET /v1/senders
Permission: senders.read. Lists sender identities this key may use.
Response shape:
| Field | Type | Description |
|---|---|---|
| senders[].id | uuid | Sender identity ID |
| senders[].from_email | Verified sending address | |
| senders[].display_name | string | Display name shown in From |
| senders[].healthy | boolean | Whether the connection is active and healthy |
| senders[].daily_remaining | number | Daily send quota remaining (cap - sent_today) |
| rotation.enabled | boolean | Whether rotation is enabled for this key |
POST /v1/emails
Permission: send.plain. Queues a plain-text email. Returns 202 immediately; sends asynchronously.
Idempotency-Key: Optional header. Repeat within 24 hours returns original response with header Idempotent-Replayed: true.
Request body:
| Field | Required | Type | Description |
|---|---|---|---|
| to | yes | Recipient email address | |
| subject | yes | string | Subject line (1–300 chars) |
| body | yes | string | Email body (1–50000 chars) |
| sender_id | no | uuid | Override default sender identity |
| from_email | no | Override from address | |
| skip_validation | no | bool | Bypass recipient MX check (default false) |
Response (202):
{
"id": "log-id",
"status": "queued",
"to": "recipient@example.com",
"sender": "you@example.com"
}Errors:
- 422 recipient_suppressed — Address unsubscribed, bounced, or complained earlier.
- 422 recipient_domain_invalid — Recipient domain has no mail server. Pass
skip_validation=trueto override.
POST /v1/emails/personalized
Permission: send.personalized. Queues a personalized email using templates with merge tags.
Merge tags: Use {name}, {company}, {email} in subject_template and body_template.
AI personalization: Set ai_personalize: true to have the LLM rewrite subject/body based on brief and lead context.
Request body:
| Field | Required | Type | Description |
|---|---|---|---|
| to | yes | Recipient email address | |
| subject_template | yes | string | Subject template (1–300 chars) |
| body_template | yes | string | Body template (1–50000 chars) |
| name | no | string | Recipient name (max 200 chars) |
| company | no | string | Recipient company (max 200 chars) |
| variables | no | object | Custom merge variables (key: value) |
| ai_personalize | no | bool | Enable AI rewriting (default false) |
| brief | no | string | Context for AI (max 4000 chars) |
| sender_id | no | uuid | Override default sender |
| from_email | no | Override from address | |
| skip_validation | no | bool | Bypass recipient MX check (default false) |
Response (202):
{
"id": "log-id",
"status": "queued",
"to": "recipient@example.com",
"sender": "you@example.com",
"ai_used": true,
"subject": "Final subject after rendering"
}GET /v1/emails/{id}
Any of these permissions works: send.plain, send.personalized, campaigns.read, analytics.read.
Response shape:
| Field | Type | Description |
|---|---|---|
| id | uuid | Email log ID |
| to | Recipient address | |
| subject | string | Rendered subject |
| status | string | Email status |
| sent_at | ISO timestamp | When sent by your mail server |
| opened_at | ISO timestamp | When tracking pixel loaded |
| clicked_at | ISO timestamp | When tracked link clicked |
| bounce_class | string|null | Hard/soft bounce classification |
| events[] | array | Chronological event timeline |
| note | string | sent means your mail server accepted it; it is not proof of inbox placement. |
404 not_found if the email is not in this workspace.
POST /v1/campaigns
Permission: campaigns.create. Creates a draft campaign. It does NOT send until launched.
Request body:
| Field | Required | Type | Description |
|---|---|---|---|
| name | yes | string | Campaign name (1–120 chars) |
| subject | no | string | Template subject (1–300 chars) |
| body | no | string | Template body (1–50000 chars) |
| brief | no | string | Brief/context (max 4000 chars) |
| max_followups | no | int | Follow-up sequence length (0–5, default 2) |
| leads[].email | yes | Lead email address | |
| leads[].name | no | string | Lead name |
| leads[].company | no | string | Lead company |
| leads[].custom | no | object | Custom fields object |
Notes: Only the first 10000 leads are processed. Suppressed and duplicate emails are skipped.
Response (201):
{
"id": "campaign-id",
"name": "Campaign name",
"status": "draft",
"total_leads": 150,
"sent": 0,
"created_at": "2026-11-15T00:00:00+00:00",
"launched_at": null,
"message": "Draft created. Leads are being verified. Generate and review drafts in the app, or launch via API when ready.",
"leads_received": 160,
"leads_added": 150,
"leads_skipped": 10
}GET /v1/campaigns
Permission: campaigns.read. Lists campaigns in the workspace (excluding API-created kind).
Query parameters: limit (default 200, max 200), offset (default 0).
Response shape:
{
"campaigns": [
{
"id": "campaign-id",
"name": "Campaign name",
"status": "draft",
"total_leads": 150,
"sent": 0,
"created_at": "2026-11-15T00:00:00+00:00",
"launched_at": null
}
],
"total": 45,
"limit": 200,
"offset": 0
}GET /v1/campaigns/{id}
Permission: campaigns.read. Returns a single campaign object.
404 not_found if campaign is not in this workspace or is kind="api".
GET /v1/campaigns/{id}/analytics
Permission: analytics.read. Returns campaign metrics.
Response shape:
| Metric | Type | Description |
|---|---|---|
| sent | int | Total sends |
| opens | int | Open count (approximate) |
| clicks | int | Link click count |
| replies | int | Reply count |
| bounces | int | Bounce count |
| complaints | int | Spam complaint count |
| suspected_machine_clicks | int | Clicks filtered as bot activity |
| open_rate | percent | Opens / sends × 100 |
| reply_rate | percent | Replies / sends × 100 |
caveat field: "Opens are approximate because some mail apps load images automatically."
POST /v1/campaigns/{id}/launch
Permission: campaigns.send. Starts campaign delivery. Runs a preflight check before launching.
Response (202):
{
"campaign_id": "campaign-id",
"status": "sending",
"scheduled_drafts": 42
}Errors:
- 409 already_sending — Campaign is currently sending.
- 400 preflight_failed — Issues must be fixed before sending (returned in
issuesarray).
Error codes
| HTTP | Code | Meaning |
|---|---|---|
| 401 | invalid_api_key | Missing, revoked, expired, or invalid API key |
| 403 | ip_not_allowed | Caller IP not in key's allowlist |
| 403 | workspace_unavailable | Workspace is archived or deleted |
| 403 | account_suspended | Account has been suspended |
| 403 | permission_denied | Key lacks required permission (message specifies which) |
| 429 | rate_limited | Rate limit exceeded (Retry-After header set) |
| 429 | ai_limit | AI provider limit reached (personalized only) |
| 429 | key_daily_limit | Key daily send cap reached |
| 429 | key_monthly_limit | Key monthly send cap reached |
| 429 | plan_daily_limit | Account plan daily limit reached |
| 429 | sender_daily_cap | Selected sender hit its daily cap |
| 429 | no_sender_available | No healthy sender in rotation has capacity |
| 409 | already_sending | Campaign is already sending |
| 409 | sender_unavailable | Sender paused, disconnected, or not tested |
| 409 | api_sending_paused | API sending paused for workspace after safety check |
| 422 | recipient_suppressed | Address previously suppressed (unsubscribed/bounced/complained) |
| 422 | recipient_domain_invalid | Recipient domain has no MX record |
| 400 | preflight_failed | Campaign validation failed (check issues list) |
| 404 | not_found | Resource not found in this workspace |
Worked example
Send a single email and check its status:
# 1. Send an email
curl -s -X POST https://mailwright.tech/backend/v1/emails -H "Authorization: Bearer mw_live_YOURKEY" -H "Content-Type: application/json" -d '{"to": "recipient@example.com", "subject": "Hello there", "body": "Thanks for joining us."}'
# Response: {"id": "log-uuid", "status": "queued", "to": "recipient@example.com", "sender": "you@example.com"}
# 2. Check its status
curl -s https://mailwright.tech/backend/v1/emails/log-uuid -H "Authorization: Bearer mw_live_YOURKEY"
# Returns status, sent/opened/clicked timestamps, events, and a note about inbox placement.Rotate and revoke
On the same page, Rotate issues a new secret and Revoke stops the old key. Confirm with your password.
Outbound events
Add an HTTPS endpoint and pick events. Each delivery is JSON.
| Event | When |
|---|---|
| email.sent | The send was handed off |
| email.delivered | A delivery event was stored |
| email.opened | The tracking image loaded |
| email.clicked | A tracked link was opened |
| email.replied | A reply was stored |
| email.bounced | A bounce was stored |
| email.complained | A complaint was stored |
| email.unsubscribed | An unsubscribe was stored |
{
"id": "event-id",
"type": "email.sent",
"created_at": "2026-11-15T00:00:00+00:00",
"data": {
"email_id": null,
"campaign_id": "campaign-id",
"campaign_name": "Campaign name",
"channel": "campaign",
"recipient": "person@example.com",
"subject": "Subject",
"sender": "you@example.com",
"from_email": "you@example.com",
"bounce_class": null
}
}Retries run after 1 minute, 5 minutes, 30 minutes, 2 hours, and 12 hours. The endpoint pauses after 20 failed deliveries.
Verify the signature
Header format: t=<unix>,v1=<hex>. The hex is HMAC-SHA256 of the timestamp, a dot, and the raw body, using the endpoint secret.
Python
import hmac, hashlib
def verify(secret: str, header: str, raw_body: bytes) -> bool:
parts = dict(piece.split("=", 1) for piece in header.split(",") if "=" in piece)
signed = f"{parts['t']}.".encode() + raw_body
expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, parts.get("v1", ""))Node
const crypto = require("crypto");
function verify(secret, header, rawBody) {
const parts = Object.fromEntries(header.split(",").map((piece) => piece.split("=")));
const signed = Buffer.concat([Buffer.from(parts.t + "."), rawBody]);
const expected = crypto.createHmac("sha256", secret).update(signed).digest("hex");
const got = parts.v1 || "";
if (got.length !== expected.length) return false;
return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(got));
}