Email API

/

HTTP

Email API with HTTP

This is a complete email API example over plain HTTP. Copy the curl examples below, point them at the Flowmails API, and send or receive email in under five minutes — no SDK, no SMTP relay, no per-email bill. Every request is bearer-authenticated against the hosted API, and the inbox and outbox land in Flowmails' own storage, scoped to your domain.

Read the mailbox back

There is no schema to apply — the mailbox is hosted and already scoped to your account. A search returns hits (addressing, subject, preview) and the same rows the dashboard shows; the body is fetched per message with the id a hit names.

list.shbash
# domainId is the domain's id (GET /api/agent/domains lists them),
# not the domain name.
curl "https://sdk.flowmails.net/api/agent/emails/search?domainId=<domain-id>&q=invoice&limit=10" \
  -H "Authorization: Bearer fm_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

{
  "messages": [
    {
      "id": 8421,
      "messageId": "<CAF8…@stripe.com>",
      "from": "no-reply@stripe.com",
      "to": "support@yourdomain.com",
      "subject": "Order #8421 confirmed",
      "receivedAt": "2026-07-06T12:34:56.000Z",
      "preview": "Your order is confirmed…"
    }
  ],
  "total": 1,
  "domainId": "<domain-id>"
}

# The body is fetched per message, never returned by a search:
curl "https://sdk.flowmails.net/api/agent/messages/<Message-ID>" \
  -H "Authorization: Bearer fm_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Send your first message

POST /api/v1/messages on the SDK host with a JSON body. The from address must land on the domain the API key is bound to — a cross-domain send is rejected with a 422 from_domain_mismatch.

send.shbash
curl -X POST https://sdk.flowmails.net/api/v1/messages \
  -H "Authorization: Bearer fm_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "hello@yourdomain.com",
    "to": "customer@example.com",
    "subject": "Order #1234 confirmed",
    "text": "Thanks for your order — we will ship it tomorrow.",
    "idempotencyKey": "order-1234"
  }'

# 201 Created
{
  "id": "8421",
  "status": "sent",
  "messageId": "<CAF8…@yourdomain.com>",
  "sendFeedback": null,
  "error": null,
  "recipients": [{ "address": "customer@example.com", "status": "sent" }]
}

Receive inbound webhooks

Register an endpoint in the dashboard and Flowmails posts a signed JSON event to it when a message arrives for one of your mailboxes. Verify the HMAC, then read the message through the API and forward it to whatever your product cares about — a CRM, a ticket queue, or a Slack channel.

webhooks.tsts
# your-app/webhooks/flowmails.ts
// Flowmails posts a signed JSON event to the endpoint you
// register in the dashboard. Verify the HMAC, then read the
// message through the API.
export default async function handler(request: Request) {
  const raw = await request.text();
  const signature = request.headers.get("x-flowmails-signature");
  const timestamp = request.headers.get("x-flowmails-timestamp");

  // Verify the signature against your endpoint's secret before
  // trusting anything in the body. The signed material is
  // `<timestamp>.<raw body>` — the timestamp is inside it, so a
  // captured request cannot be replayed with a fresh header. Use a
  // constant-time compare; see the Python or JavaScript page for a
  // full `signatureIsValid` implementation.
  if (!signatureIsValid(timestamp, raw, signature, process.env.WEBHOOK_SECRET)) {
    return new Response("bad signature", { status: 401 });
  }

  const event = JSON.parse(raw);
  // event.event === "message.received"
  const message = await fetchMessage(event.messageId);
  await routeToTicketQueue(message);
  return new Response("ok", { status: 200 });
}

Send your first email from the Flowmails API in under five minutes.

Start free