Loading
Forke Mail HTTP API
Sign up
DocsForke MailForke Mail HTTP API

Forke Mail

7 min read

Forke Mail HTTP API

HTTP API

Authentication and errors

  • Send Authorization: Bearer <API key> on every request.
  • Errors are JSON: {"error":"snake_case_code"} with a matching status code. 401 means a missing or revoked key, 403 that the key's permission or your role doesn't allow it, 404 that nothing with that ID exists in this project, 409 a conflict, 422 invalid input, 402 out of credits or over a limit, 429 too many requests.
  • Send an Idempotency-Key header when sending email so retries never send twice.

Send email

POST /api/transactional

json
{
  "to": "[email protected]",
  "from_name": "Acme",
  "from_address": "[email protected]",
  "reply_to": "[email protected]",
  "subject": "Your receipt",
  "html": "<p>Thanks for your order.</p>",
  "text": "Thanks for your order.",
  "template": "receipt",
  "data": { "name": "Ada", "total": "$42" },
  "track_opens": true,
  "track_clicks": true
}

Use either html/text or template with data. GET /api/transactional/{id} returns the status: queued, sent, failed or test, plus delivered, bounced, complained, opened and clicked times.

ts
await fetch("https://mail.forke.space/api/transactional", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.FORKE_MAIL_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": `welcome-${user.id}`,
  },
  body: JSON.stringify({ to: user.email, from_address: "[email protected]", from_name: "Acme", template: "welcome", data: { name: user.name } }),
});

Templates

  • GET /api/templates, POST /api/templates, GET|PUT|DELETE /api/templates/{id} (the ID or the name).
  • Body: name, kind (transactional reaches everyone; marketing skips unsubscribed contacts), subject, html, text.
  • {{name}} inserts an escaped value, {{{html}}} inserts raw HTML, {{date}} is today's date.

Contacts and events

  • POST /api/events with email, event, optional data, tags and contact (first_name, last_name, data) creates or updates the contact, records the event and starts matching workflows.
  • GET /api/contacts?search=&status=, POST /api/contacts/import (CSV), DELETE /api/contacts/{id}, GET /api/tags.

Segments

  • GET|POST /api/segments, POST /api/segments/preview to see the size first.
  • Rules: {"field","op","value"} with fields such as email, status, tag, created_at, last_engaged_at, event and data.<field>, combined with match: all|any and one level of {"field":"group","op":"any|all","rules":[...]}.

Broadcasts

  • POST /api/forke-mail/broadcasts creates a draft: from, subject, html/text, and segment (name) or audience_id (tag), optional topic.
  • POST /api/forke-mail/broadcasts/{id}/send launches it. Through agents this always needs your approval.

Workflows

  • GET|POST /api/workflows, GET|PUT|DELETE /api/workflows/{id}, GET /api/workflows/{id}/runs.
  • A workflow has a trigger event, steps (wait and send with a template) and an optional exit event that stops it.

Domains

  • POST /api/domains with name returns the DNS records to add: three DKIM CNAMEs, SPF and DMARC.
  • POST /api/domains/{id}/verify re-checks, GET /api/domains/{id}/dns shows exactly which record is missing.

Webhooks, analytics and more

  • Webhooks: GET|POST /api/webhooks, PATCH|DELETE /api/webhooks/{id}, POST /api/webhooks/{id}/rotate, signed with HMAC.
  • Analytics: GET /api/analytics?days=1|7|30|90&stream=all|transactional|broadcast.
  • Deliveries: GET /api/deliveries?q=&status=&kind=.
  • Suppressions GET|POST /api/suppressions, topics GET /api/topics, team GET /api/team, account GET /api/me.

Building your own MCP client

  • Discovery: GET /.well-known/oauth-protected-resource and GET /.well-known/oauth-authorization-server. An unauthenticated call to /mcp returns 401 with a WWW-Authenticate header pointing at the first.
  • Register with POST /oauth/register (dynamic client registration, public clients). Redirect URIs may be https, http://127.0.0.1 or http://localhost on any port, or an app scheme such as cursor://.
  • Authorize with GET /oauth/authorize using PKCE (S256), then exchange the code at POST /oauth/token. Refresh tokens rotate on every use. Revoke with POST /oauth/revoke.
  • The MCP endpoint speaks JSON-RPC over Streamable HTTP (protocol versions 2025-06-18, 2025-03-26 and 2024-11-05) and answers with JSON.
  • Server card: GET /.well-known/mcp.json.

Troubleshooting

  • sender_not_verified: the from address isn't on a verified domain. Add the domain, add its DNS records and run check_domain. Test keys accept any from address.
  • 402 or a limit error: the project is out of credits or over its daily limit. Check get_account.
  • CONFIRMATION NEEDED keeps coming back: the arguments changed between calls. Confirm the final version.
  • APPROVAL NEEDED but nothing happens: the project owner has to open the link and press Approve while signed in to Forke Mail.
  • The app can't connect: remove the connector and add it again to sign in fresh, and check status.forke.space.