Send an email (EmailJS-compatible alias)
const url = 'https://api.frontmail.dev/api/v1.0/email/send';const options = { method: 'POST', headers: { 'Idempotency-Key': '7f0b6c1e-3a57-4a0e-9d0c-5d3f2d1b2a10', 'X-Frontmail-Public-Key': '<X-Frontmail-Public-Key>', 'Content-Type': 'application/json' }, body: '{"service_id":"svc_01j9z3k8q4w5e6r7t8y9u0i1o2","template_id":"tpl_01j9z3k8q4w5e6r7t8y9u0i1o2","user_id":"example","accessToken":"example","template_params":{"name":"Jan","email":"jan@example.com","message":"Hello!"},"turnstile_token":"example","turnstile_key":"org","attachments":[{"filename":"example","content_type":"example","content_base64":"example"}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.frontmail.dev/api/v1.0/email/send \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: 7f0b6c1e-3a57-4a0e-9d0c-5d3f2d1b2a10' \ --header 'X-Frontmail-Public-Key: <X-Frontmail-Public-Key>' \ --data '{ "service_id": "svc_01j9z3k8q4w5e6r7t8y9u0i1o2", "template_id": "tpl_01j9z3k8q4w5e6r7t8y9u0i1o2", "user_id": "example", "accessToken": "example", "template_params": { "name": "Jan", "email": "jan@example.com", "message": "Hello!" }, "turnstile_token": "example", "turnstile_key": "org", "attachments": [ { "filename": "example", "content_type": "example", "content_base64": "example" } ] }'Validates template_params against the template schema and queues the message. Returns status: "held" instead of failing when the organization has no credits (hold mode); 402 in reject mode.
Authorizations
Section titled “Authorizations”Parameters
Section titled “ Parameters ”Header Parameters
Section titled “Header Parameters”Unique key per logical send (≤ 255 chars of [A-Za-z0-9_-:.]). Retries with the same key and body return the original response.
Example
7f0b6c1e-3a57-4a0e-9d0c-5d3f2d1b2a10Unique key per logical send (≤ 255 chars of [A-Za-z0-9_-:.]). Retries with the same key and body return the original response.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Service id; omitted or default_service → the template’s / organization’s default service.
Example
svc_01j9z3k8q4w5e6r7t8y9u0i1o2Example
tpl_01j9z3k8q4w5e6r7t8y9u0i1o2Public key pk_… (EmailJS-compatible). Alternatively the X-Frontmail-Public-Key header.
Private key sk_… (EmailJS-compatible). Prefer Authorization: Bearer.
Values for the template’s parameters (validated against its schema).
object
Example
{ "name": "Jan", "email": "jan@example.com", "message": "Hello!"}Cloudflare Turnstile token; required when the template has CAPTCHA enabled and no private key is used.
Which Turnstile widget issued the token for requests without an Origin header (native apps): frontmail (default, Frontmail’s shared mobile key) or org (the organization’s own key). Requests with an Origin always use the organization’s key.
Responses
Section titled “ Responses ”Accepted. Frontmail clients (X-Frontmail-Client header or Accept: application/json) get the JSON body; EmailJS-style clients get 200 text/plain "OK". Message id and status are always in X-Frontmail-Message-Id / X-Frontmail-Status.
object
held = accepted but waiting for credits; it is sent automatically once credits are added.
Pass as ?token= to GET /v1/messages/{id} with a public key.
Example
{ "message_id": "msg_01j9z3m2c7v8b9n0m1q2w3e4r5", "status": "queued"}Example
OKInvalid request body, query or Idempotency-Key (invalid_body, bad_request, invalid_idempotency_key).
object
object
Stable error code. See https://docs.frontmail.dev/reference/errors/.
Example
{ "error": { "code": "invalid_template_params", "message": "Invalid template parameters. email: Enter a valid e-mail address.", "docs_url": "https://docs.frontmail.dev/reference/errors/#invalid-template-params", "details": { "issues": [ { "param": "email", "code": "invalid_email", "message": "Enter a valid e-mail address." } ] } }}Missing or invalid key (unauthorized, invalid_public_key, invalid_private_key).
object
object
Stable error code. See https://docs.frontmail.dev/reference/errors/.
Example
{ "error": { "code": "invalid_template_params", "message": "Invalid template parameters. email: Enter a valid e-mail address.", "docs_url": "https://docs.frontmail.dev/reference/errors/#invalid-template-params", "details": { "issues": [ { "param": "email", "code": "invalid_email", "message": "Enter a valid e-mail address." } ] } }}No credits left and the organization uses reject mode (insufficient_credits).
object
object
Stable error code. See https://docs.frontmail.dev/reference/errors/.
Example
{ "error": { "code": "invalid_template_params", "message": "Invalid template parameters. email: Enter a valid e-mail address.", "docs_url": "https://docs.frontmail.dev/reference/errors/#invalid-template-params", "details": { "issues": [ { "param": "email", "code": "invalid_email", "message": "Enter a valid e-mail address." } ] } }}Forbidden: origin, CAPTCHA (required, failed, not configured), headless, block list, private key required, suspended, unverified owner e-mail, plan limit, dynamic recipient, attachments.
object
object
Stable error code. See https://docs.frontmail.dev/reference/errors/.
Example
{ "error": { "code": "invalid_template_params", "message": "Invalid template parameters. email: Enter a valid e-mail address.", "docs_url": "https://docs.frontmail.dev/reference/errors/#invalid-template-params", "details": { "issues": [ { "param": "email", "code": "invalid_email", "message": "Enter a valid e-mail address." } ] } }}Template, service or message not found.
object
object
Stable error code. See https://docs.frontmail.dev/reference/errors/.
Example
{ "error": { "code": "invalid_template_params", "message": "Invalid template parameters. email: Enter a valid e-mail address.", "docs_url": "https://docs.frontmail.dev/reference/errors/#invalid-template-params", "details": { "issues": [ { "param": "email", "code": "invalid_email", "message": "Enter a valid e-mail address." } ] } }}Idempotency-Key reused with a different body, or still in progress (idempotency_conflict).
object
object
Stable error code. See https://docs.frontmail.dev/reference/errors/.
Example
{ "error": { "code": "invalid_template_params", "message": "Invalid template parameters. email: Enter a valid e-mail address.", "docs_url": "https://docs.frontmail.dev/reference/errors/#invalid-template-params", "details": { "issues": [ { "param": "email", "code": "invalid_email", "message": "Enter a valid e-mail address." } ] } }}Request or attachments too large (payload_too_large, attachment_too_large).
object
object
Stable error code. See https://docs.frontmail.dev/reference/errors/.
Example
{ "error": { "code": "invalid_template_params", "message": "Invalid template parameters. email: Enter a valid e-mail address.", "docs_url": "https://docs.frontmail.dev/reference/errors/#invalid-template-params", "details": { "issues": [ { "param": "email", "code": "invalid_email", "message": "Enter a valid e-mail address." } ] } }}Invalid template params, recipient or rendering error.
object
object
Stable error code. See https://docs.frontmail.dev/reference/errors/.
Example
{ "error": { "code": "invalid_template_params", "message": "Invalid template parameters. email: Enter a valid e-mail address.", "docs_url": "https://docs.frontmail.dev/reference/errors/#invalid-template-params", "details": { "issues": [ { "param": "email", "code": "invalid_email", "message": "Enter a valid e-mail address." } ] } }}Rate limited – see Retry-After (seconds).
object
object
Stable error code. See https://docs.frontmail.dev/reference/errors/.
Example
{ "error": { "code": "invalid_template_params", "message": "Invalid template parameters. email: Enter a valid e-mail address.", "docs_url": "https://docs.frontmail.dev/reference/errors/#invalid-template-params", "details": { "issues": [ { "param": "email", "code": "invalid_email", "message": "Enter a valid e-mail address." } ] } }}Headers
Section titled “Headers”Seconds to wait before retrying.
Seconds to wait before retrying.
A recipient is on the suppression list (recipient_suppressed).
object
object
Stable error code. See https://docs.frontmail.dev/reference/errors/.
Example
{ "error": { "code": "invalid_template_params", "message": "Invalid template parameters. email: Enter a valid e-mail address.", "docs_url": "https://docs.frontmail.dev/reference/errors/#invalid-template-params", "details": { "issues": [ { "param": "email", "code": "invalid_email", "message": "Enter a valid e-mail address." } ] } }}Unexpected error; details.request_id identifies the request.
object
object
Stable error code. See https://docs.frontmail.dev/reference/errors/.
Example
{ "error": { "code": "invalid_template_params", "message": "Invalid template parameters. email: Enter a valid e-mail address.", "docs_url": "https://docs.frontmail.dev/reference/errors/#invalid-template-params", "details": { "issues": [ { "param": "email", "code": "invalid_email", "message": "Enter a valid e-mail address." } ] } }}