Reference

API reference

The complete contract of version 1. The same information is available as an OpenAPI 3.1 document for code generators and API tools.

Basics#

Base URLhttps://email.madagascarhotelags.com
Versionv1, in the path
AuthenticationAuthorization: Bearer <token> (all endpoints except /v1/health)
Request bodyapplication/json, UTF-8, at most 256 KiB
Responsesapplication/json; errors application/problem+json
TimesISO 8601 in UTC, millisecond precision
Cachingevery response is Cache-Control: no-store
Machine-readable/openapi.json (OpenAPI 3.1)

Headers#

HeaderDirectionMeaning
AuthorizationrequestBearer and your token.
Content-Typerequestapplication/json on POST. Anything else is 415.
Idempotency-KeyrequestOptional on POST /v1/messages; 1 to 128 of A-Z a-z 0-9 . _ : - (at most 124 on POST /v1/messages/batch).
LocationresponseOn 202: the path of the new message.
Idempotent-Replayedresponsetrue when a 202 repeats an earlier answer for the same key.
Retry-AfterresponseSeconds to wait, on 429 and 503.
WWW-AuthenticateresponseBearer, on 401 invalid_token.
AllowresponseThe accepted methods, on 405.

GET /v1/health#

GET/v1/healthno token

Answers whether the API is up. Use it for uptime monitors; it does not touch the database.

Response 200
{ "ok": true, "service": "cf-email-api", "time": "2026-10-01T15:04:05.000Z" }

GET /v1/me#

GET/v1/meany valid token

The token's identity, mode, client, permissions, current senders, templates, limits and its usage today and this month.

Shell
curl -sS https://email.madagascarhotelags.com/v1/me \
  -H "Authorization: Bearer $EMAIL_API_TOKEN"
FieldTypeMeaning
token.idstringThe public id (12 characters).
token.namestringThe name the hotel gave the token.
token.modestringlive, or test: checked and recorded, never sent.
token.clientstring or nullThe app or service the token belongs to.
token.scopesstring[]send and/or read.
token.sendersstring[]Addresses usable as from right now.
token.templatesstring[] or nullThe templates it may send; null for any published one.
token.templates_onlybooleantrue when it may send templates only.
token.rate_per_minintegerMessages per minute.
token.daily_capintegerMessages per UTC day.
token.monthly_capinteger or nullMessages per UTC month; null for no limit.
token.expires_atstring or nullWhen the token stops working.
usage.sent_todayintegerMessages accepted today (UTC).
usage.remaining_todayintegerdaily_cap minus sent_today. The shared allowance may run out sooner.
usage.sent_this_monthintegerMessages accepted this month (UTC).
usage.remaining_this_monthinteger or nullmonthly_cap minus sent_this_month; null for no limit.
api.enabledbooleanAlways true in a successful answer.

POST /v1/messages#

POST/v1/messagessend permission

Accepts a message for delivery.

Shell
curl -sS https://email.madagascarhotelags.com/v1/messages \
  -H "Authorization: Bearer $EMAIL_API_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: booking-4821-confirmation" \
  -d '{
    "to": ["guest@example.com"],
    "subject": "Your stay is confirmed",
    "text": "Luna checks in on Friday at 10:00. Reply to this email if anything changes.",
    "html": "<p>Luna checks in on <strong>Friday at 10:00</strong>.</p><p>Reply to this email if anything changes.</p>"
  }'

Body#

FieldTypeRequiredRules
toaddress[]yes1 or more
ccaddress[]no
bccaddress[]noto + cc + bcc at most 10 unless the hotel set otherwise (1 to 50)
fromaddress or { email, name? }noone of token.senders; default: the first
reply_toaddressno
subjectstringyes, without a template1 to 998 characters after control characters become spaces
htmlstringhtml or text1 to 200,000 characters
textstringhtml or text1 to 100,000 characters
tagsstring[]noat most 5, each [A-Za-z0-9_-]{1,32}
scheduled_atstringnoISO 8601, 1 minute to 72 hours ahead
template_idstringinstead of subject, html, texta published template, tpl_ then 2 to 60 of a-z, 0-9, _ (Templates)
variablesobjectwith a templatethe template's variables by name, each checked against its type
localestringnoes or en; default Spanish, else the language the template has

An address is "user@example.com" or "Name <user@example.com>" (at most 254 characters for the address part). Unknown fields are refused.

Responses#

StatusWhen
202Accepted: { id, status: "queued", created_at } and Location. Also a replay of a known Idempotency-Key (with Idempotent-Replayed: true and the message's current status).
400invalid_json, invalid_request, unknown_field, invalid_address, too_many_recipients, invalid_schedule, invalid_idempotency_key
401invalid_token, token_expired
403token_blocked, insufficient_scope, sender_not_allowed
405method_not_allowed
413payload_too_large
415unsupported_media_type
422idempotency_key_reuse, unknown_template, invalid_variables, content_blocked
429rate_limited, daily_cap_reached, api_budget_reached
500internal
503api_disabled, unavailable

GET /v1/templates#

GET/v1/templatessend permission

The templates the hotel has published, with what each one needs. Only published, active templates are listed; a send always uses the version published at that moment.

JSON
{ "templates": [ { "id": "tpl_booking_confirmed", "name": "Booking confirmed", "description": "", "version": 3, "locales": ["es", "en"], "variables": [ { "name": "guest_name", "type": "string", "required": true }, { "name": "check_in", "type": "date", "required": true } ] } ] }
StatusWhen
200The templates.
401invalid_token, token_expired
403token_blocked, insufficient_scope

GET /v1/messages/{id}#

GET/v1/messages/{id}read permission

One message sent with the same token. id is msg_ followed by 26 lowercase letters and digits.

Shell
curl -sS https://email.madagascarhotelags.com/v1/messages/msg_01k6qzexample0000000000000 \
  -H "Authorization: Bearer $EMAIL_API_TOKEN"
FieldTypeMeaning
idstringThe message id.
statusstringqueued, retrying, sent, failed or dead
fromstringThe sender address used.
tostring[]The To addresses.
cc_count, bcc_countintegerHow many Cc and Bcc addresses.
subjectstring
scheduled_atstring or nullThe requested send time.
created_atstringWhen it was accepted.
sent_atstring or nullWhen the mail system accepted it.
attemptintegerHand-off attempts so far.
errorstring or nullWhy, for failed and dead. Text for people, not a code.
deliverystring or nullThe latest verdict after sending: delivered, deferred, bounced, blocked, complained or unsubscribed. null means not known yet, not failed. A deferral never replaces a final verdict.
delivery_atstring or nullWhen delivery was last set.
suppressedintegerRecipients removed by the suppression list.
testbooleantrue for a message a test token sent: recorded, never sent.
canceled_atstring or nullWhen it was cancelled.
StatusWhen
200The message.
401invalid_token, token_expired
403token_blocked, insufficient_scope
404not_found: no such message for this token, or a malformed id.

POST /v1/messages/batch#

POST/v1/messages/batchsend permission

Accepts up to 50 messages in one request: { "messages": [ ... ] }, each exactly the body of POST /v1/messages. Each message is checked and counted against every limit as if it were sent alone, and is accepted or refused on its own: one bad message does not stop the others.

JSON
{ "accepted": 2, "refused": 1, "results": [
  { "index": 0, "id": "msg_01j9z8x7w6v5t4s3r2q1p0n9m8", "status": "queued", "created_at": "2026-10-10T14:00:00.000Z" },
  { "index": 1, "error": { "code": "invalid_address", "detail": "to[0] is not a valid address." } },
  { "index": 2, "id": "msg_01j9z8x7w6v5t4s3r2q1p0n9m9", "status": "queued", "created_at": "2026-10-10T14:00:00.000Z" } ] }

With an Idempotency-Key, message i of the batch uses the key <key>:<i>, so repeating the whole request accepts nothing twice; the repeated results carry "replayed": true. A test token's results carry "test": true.

StatusWhen
202At least one message was accepted. Check every result.
400invalid_json, invalid_request (no messages, or more than 50), invalid_idempotency_key
401invalid_token, token_expired
403token_blocked, insufficient_scope
413payload_too_large: the whole batch counts against the body limit.
422No message was accepted; each result says why.
429rate_limited

GET /v1/messages#

GET/v1/messagesread permission

The token's own messages, newest first.

QueryMeaning
limit1 to 100, default 20.
statusOnly this status: queued, retrying, sent, failed or dead.
beforeThe next_before of the previous page.

The answer is { "data": [ ... ], "next_before": "msg_..." }, each message as GET /v1/messages/{id} shows it. next_before is null on the last page.

GET /v1/messages/{id}/events#

GET/v1/messages/{id}/eventsread permission

What happened to a message after it was sent, oldest first, at most 100 events.

JSON
{ "data": [ { "id": "evt_01j9z8x7w6v5t4s3r2q1p0n9m8", "type": "message.delivered", "at": "2026-10-10T14:00:03.000Z", "recipient": "guest@example.com", "reason": null } ] }
typeMeaning
message.deliveredThe recipient's mail server accepted it.
message.deferredThe mail server put it off for now (a soft bounce); the mail system keeps trying.
message.bouncedThe address does not exist or refuses mail for good. It goes on the do-not-mail list.
message.blockedThe mail system or the receiving server blocked it.
message.complainedThe recipient marked it as spam. The address goes on the do-not-mail list.
message.unsubscribedThe recipient unsubscribed. The address goes on the do-not-mail list.
message.openedIt was opened (mail apps that load images in advance count too).
message.clickedA link in it was clicked.
message.canceledIt was cancelled before its scheduled time.
message.cancel_failedA cancel came too late: it had already gone out.

A token whose mail keeps bouncing is blocked automatically: once a UTC day has at least 5 bounced or complained messages from it and they are at least 10% of what it sent that day, it answers 403 token_blocked until the hotel unblocks it.

POST /v1/messages/{id}/cancel#

POST/v1/messages/{id}/cancelsend permission

Cancels a message sent with scheduled_at whose time has not come. No body.

StatusWhen
200{ id, status: "failed", canceled_at, cancel: "done" }: it will never be sent. Its error reads "Cancelled before its scheduled time."
202cancel: "requested": the mail system already holds it. It is withdrawn within about a minute and then turns failed; if it had already gone out it stays sent with a message.cancel_failed event.
401invalid_token, token_expired
403token_blocked, insufficient_scope
404not_found
409not_cancelable: not scheduled, its time has come, already sent or cancelled, or sent by a test token.

Webhooks#

The hotel can give your app a webhook address (https://, on a public host name) and choose which delivery events it receives (all of them by default, except the cancel ones). Each event is a POST with a JSON body:

JSON
{ "type": "message.bounced", "timestamp": "2026-10-10T14:00:03.000Z", "data": { "message_id": "msg_01j9z8x7w6v5t4s3r2q1p0n9m8", "recipient": "guest@example.com", "reason": "mailbox does not exist" } }

It is signed the Standard Webhooks way, so any of their libraries can check it.

HeaderValue
webhook-idThe event id. The same on every retry of the same event: use it to ignore a repeat.
webhook-timestampSeconds since 1970. Reject one more than 5 minutes old.
webhook-signaturev1, then base64 of HMAC-SHA256 over <webhook-id>.<webhook-timestamp>.<body>, keyed with the base64-decoded bytes after whsec_ in your secret.

The secret (whsec_...) is shown once, when the hotel sets the address or makes a new secret. Answer with any 2xx within 5 seconds. Anything else, a redirect or a timeout is tried again over about six hours; after the last try the event is marked as failed on the message. The hotel can send a message.test event to check your endpoint.

For recipients: About this email#

GET/v1/about/{id}no token
POST/v1/about/{id}/reportno token

Every message sent through the API ends with a short footer linking to About this email (/about/?m=<message id>), a page for the person who received it. That page uses these two endpoints; integrations do not need them.

  • GET /v1/about/{id} answers id, status, from, created_at and sent_at: only what the email itself shows, never the recipients, the subject or the body.
  • POST /v1/about/{id}/report takes {"reason": "unexpected" | "unwanted" | "fraud"} and answers 202. The hotel sees the report next to your token in its activity trail; nothing about the person reporting is kept.
  • Both are limited per address at the edge (429 rate_limited), and an unknown id answers 404 not_found.

The footer is added when the message is sent, after your content, in both the HTML and the text part. GET /v1/messages/{id} and your stored copy do not include it.

Errors#

Every error is a problem document. Switch on code; show detail to a person; quote request_id when you ask for help.

application/problem+json
{
  "type": "about:blank",
  "title": "Unprocessable request",
  "status": 422,
  "detail": "This Idempotency-Key was already used with a different request body.",
  "code": "idempotency_key_reuse",
  "request_id": "a4389ca6781df288"
}

The full list, with what to do for each, is on the Errors page.

Last reviewed 2026-10-01.