Rodmena Mail API v0.1

Multi-tenant outbound email API with templates, campaigns, webhooks, scheduling, and MCP server.

Quick Start

curl -X POST https://mailserver.rodmena.co.uk/api/v1/emails \
  -H "Authorization: Bearer <your-api-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "to": ["recipient@example.com"],
    "subject": "Hello from Rodmena Mail API",
    "html": "<h1>It works!</h1><p>Sent via the API.</p>",
    "type": "transactional"
  }'

Returns: {"track_id": "01H...", "status": "accepted", "eligible_start": "..."}

Authentication

All endpoints require Authorization: Bearer <uuid4-api-key>. API keys are UUIDv4 tokens issued via the admin CLI and registered in auth.rodmena.app.

Endpoints

MethodPathDescription
POST/api/v1/emailsSend a transactional email
GET/api/v1/emails/{track_id}Get email status
GET/api/v1/emailsList emails
GET/api/v1/emails/{track_id}/eventsFull event history
POST/api/v1/campaignsCreate a bulk campaign
GET/api/v1/campaigns/{campaign_id}Get campaign status
POST/api/v1/campaigns/{campaign_id}/cancelCancel a campaign
POST/GET/PATCH/DELETE/api/v1/templatesTemplate CRUD
POST/api/v1/templates/{id}/previewPreview a template
GET/PUT/api/v1/tenant/quotasManage quotas
GET/PUT/api/v1/tenant/configManage tenant config
GET/DELETE/api/v1/suppressionSuppression list
POST/GET/PATCH/DELETE/api/v1/webhooksWebhook endpoint CRUD
POST/api/v1/webhooks/{id}/testTest a webhook
POST/api/v1/webhooks/{id}/rotate-secretRotate webhook secret
GET/api/v1/webhooks/{id}/deliveriesDelivery history
POST/api/v1/webhooks/deliveries/{id}/redeliverRedeliver
GET/api/v1/auditAudit log
GET/healthHealth check
GET/metricsPrometheus metrics

Webhook Events

EventDescription
email.acceptedEmail accepted into the system
email.renderedTemplate rendered
email.scheduledEmail scheduled for future dispatch
email.sendingSMTP send in progress
email.sentSMTP accepted the message
email.deliveredDelivery confirmed
email.bouncedBounce received
email.complainedSpam complaint received
email.failedDispatch failed
email.cancelledEmail cancelled
email.suppressedRecipient on suppression list
campaign.*Campaign lifecycle events

Aliases: email.terminal, campaign.terminal. Wildcards: email.*, campaign.*, *.

Webhook Signature Verification

import hmac, hashlib

def verify(signature_header, timestamp, body, secret):
    expected = "sha256=" + hmac.new(
        secret.encode(),
        f"{timestamp}.".encode() + body,
        hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(signature_header, expected)

MCP Server

Register the MCP server at https://mailserver.rodmena.co.uk/mcp with your API key as the Bearer token.

Templates

Templates use Jinja2 in a SandboxedEnvironment. All client templates are untrusted — no import, no dunder access, no OS paths.

Calendar Rules

TypeAllowed Window
transactionalAny time
notificationAny time
marketingMon-Fri 09:00-17:00, excluding UK holidays
legalMon-Fri 09:00-17:00, excluding UK holidays