API

API

Your own sites and programs talk to mailrust over a small JSON API: send an email from a mailbox, add a subscriber to a list, send a lead into an outreach campaign and learn what became of it. For AI agents there is a separate door, MCP.

Requests

Method and addressWhat it does
POST /api/v1/sendSend an email
GET /api/v1/listsYour newsletter lists
POST /api/v1/subscribersAdd a subscriber
DELETE /api/v1/subscribersUnsubscribe
GET /api/v1/campaignsYour outreach campaigns
POST /api/v1/prospectsAdd prospects to a campaign
GET /api/v1/prospectsWhat became of a prospect
POST /api/v1/prospects/stateReport the outcome

Keys

Create a key under Settings → Site keys:

FieldWhat it means
What the key is forA name you recognise, for example the site's domain
MailboxThe mailbox the key sends from; you must be allowed to send from it
Emails per dayThe key sends no more than this, in case the site gets hacked
May add prospects to campaignsOnly for a site with a lead form or a CRM; a key that sends "order received" does not need it

The key starts with mr_ and is shown once. mailrust keeps only its fingerprint. Send it in every request:

curl https://mail.example.com/api/v1/lists \
  -H "Authorization: Bearer mr_..."

Revoke stops a key at once.

Answers

Every answer is JSON with an ok field. On a refusal, error explains it in plain words:

{ "ok": false, "error": "`subject` is required, 300 characters at most" }
StatusMeaning
200, 202Done; 202 means the email is queued
400The request is incomplete or malformed
401The key is missing, unknown or revoked
403The key may not do this, for example campaigns without the prospects permission
404No such list, campaign or prospect
409The request does not apply right now; error says why
413The email is over one megabyte
422Nobody to write to, or a reused Idempotency-Key with a different request
429A limit is reached

Sending twice by mistake

Add an Idempotency-Key header to POST /api/v1/send. A repeat with the same key and the same body within 24 hours gets the first answer again, with the header Idempotent-Replayed: true, and nothing is sent twice. The key is 1 to 200 printable ASCII characters, for example the order number.

Limits

WhatLimit
Recipients in one email request50, each gets a copy of their own
Subject300 characters
Email body1 MB
Emails per key per daySet on the key
New subscribers per list per hour600
Prospects in one request100