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.401means a missing or revoked key,403that the key's permission or your role doesn't allow it,404that nothing with that ID exists in this project,409a conflict,422invalid input,402out of credits or over a limit,429too many requests. - Send an
Idempotency-Keyheader 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(transactionalreaches everyone;marketingskips unsubscribed contacts),subject,html,text. {{name}}inserts an escaped value,{{{html}}}inserts raw HTML,{{date}}is today's date.
Contacts and events
POST /api/eventswithemail,event, optionaldata,tagsandcontact(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/previewto see the size first.- Rules:
{"field","op","value"}with fields such asemail,status,tag,created_at,last_engaged_at,eventanddata.<field>, combined withmatch: all|anyand one level of{"field":"group","op":"any|all","rules":[...]}.
Broadcasts
POST /api/forke-mail/broadcastscreates a draft:from,subject,html/text, andsegment(name) oraudience_id(tag), optionaltopic.POST /api/forke-mail/broadcasts/{id}/sendlaunches 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 (
waitandsendwith a template) and an optional exit event that stops it.
Domains
POST /api/domainswithnamereturns the DNS records to add: three DKIM CNAMEs, SPF and DMARC.POST /api/domains/{id}/verifyre-checks,GET /api/domains/{id}/dnsshows 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, topicsGET /api/topics, teamGET /api/team, accountGET /api/me.
Building your own MCP client
- Discovery:
GET /.well-known/oauth-protected-resourceandGET /.well-known/oauth-authorization-server. An unauthenticated call to/mcpreturns401with aWWW-Authenticateheader pointing at the first. - Register with
POST /oauth/register(dynamic client registration, public clients). Redirect URIs may behttps,http://127.0.0.1orhttp://localhoston any port, or an app scheme such ascursor://. - Authorize with
GET /oauth/authorizeusing PKCE (S256), then exchange the code atPOST /oauth/token. Refresh tokens rotate on every use. Revoke withPOST /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.