DocsSend email via the API

Send email via the API

Send with a single POST to /v1/email, authenticated with a Bearer API key. The from address must be on a verified domain.

Request

POST https://api.mailhuset.com/v1/email
Authorization: Bearer $MAILHUSET_API_KEY
Content-Type: application/json

{
  "from": "Acme <hello@yourdomain.com>",
  "to": ["customer@example.com"],
  "subject": "Your receipt",
  "html": "<p>Thanks for your order.</p>",
  "text": "Thanks for your order."
}

Fields

FieldTypeNotes
fromstringName <address>; address must be on a verified domain. Required.
tostring[]One or more recipients. Required.
cc, bcc, replyTostring[]Optional.
subjectstringRequired unless a template supplies it.
html, textstringThe body. Send both when you can (better deliverability).
templateAlias, templateModelstring, objectRender a stored template with a data model; subject/html/text override the rendered output.
streamstringtransactional (default) or broadcast.
headersobjectCustom headers.
tagsobjectKey/value tags for filtering in Activity.
trackingobject{ "opens": true, "clicks": true }.
idempotencyKeystringA repeat with the same key returns the original message instead of sending twice.

Response

A 2xx returns the accepted message (with its id). The message is then queued and delivered; track its state in Activity or via webhooks.

Templates

Store reusable content and send it by alias:

{
  "from": "Acme <hello@yourdomain.com>",
  "to": ["customer@example.com"],
  "templateAlias": "welcome",
  "templateModel": { "name": "Sam", "plan": "Pro" }
}

Idempotency

Network retries can double-send. Pass a unique idempotencyKey per logical email and Mailhuset returns the original result on a repeat, safe to retry.

Errors

401 = bad/missing key; 403 = from domain not verified or sending not approved; 422 = validation error (the response says which field). See Troubleshooting.


Need help? Email support@mailhuset.com.