API Reference
All endpoints require an Authorization: Bearer <token> header.
Base URL: https://email-gateway.your-account.workers.dev
Emails
Section titled “Emails”List emails
Section titled “List emails”GET /api/emails?status=pending&limit=50&offset=0Query parameters:
| Parameter | Type | Description |
|---|---|---|
status | string | Filter by status: pending, approved, rejected, forwarded |
limit | number | Max results (default: 50) |
offset | number | Pagination offset (default: 0) |
Get email
Section titled “Get email”GET /api/emails/:idApprove email
Section titled “Approve email”POST /api/emails/:id/approveApproves the email and forwards it to the destination via Cloudflare’s send_email binding. Returns the updated email object.
Reject email
Section titled “Reject email”POST /api/emails/:id/rejectBulk action
Section titled “Bulk action”POST /api/emails/bulkBody:
{ "ids": ["uuid-1", "uuid-2"], "action": "approve" | "reject"}Get stats
Section titled “Get stats”GET /api/emails/statsResponse:
{ "total": 150, "pending": 5, "approved": 80, "rejected": 60, "forwarded": 75, "last24h": 12, "last7d": 45, "last30d": 150}Senders
Section titled “Senders”List senders
Section titled “List senders”GET /api/senders?status=allowedQuery parameters:
| Parameter | Type | Description |
|---|---|---|
status | string | Filter: allowed, blocked, unknown |
Allow sender
Section titled “Allow sender”POST /api/senders/:address/allowAllowlists the sender and approves all their pending emails.
Block sender
Section titled “Block sender”POST /api/senders/:address/blockBlocklists the sender and rejects all their pending emails.
Reset sender
Section titled “Reset sender”DELETE /api/senders/:addressResets the sender status to unknown.
Settings
Section titled “Settings”Get settings
Section titled “Get settings”GET /api/settingsResponse:
{ "destination_email": "you@example.com", "auto_forward_allowed": "true", "auto_reject_blocked": "true"}Update settings
Section titled “Update settings”PUT /api/settingsBody: Key-value pairs to upsert.
{ "destination_email": "new@example.com", "auto_forward_allowed": "false"}WebSocket
Section titled “WebSocket”GET /ws?token=YOUR_AUTH_TOKENUpgrades to a WebSocket connection for real-time updates. Messages are JSON:
{ "type": "new_email", "email": { ... } }{ "type": "email_updated", "email": { ... } }{ "type": "sender_updated", "address": "...", "status": "allowed" }