Guides

Sending email

One endpoint sends every message. This page goes through each field, the rules the API applies to it, and the choices that make a message arrive and read well.

POST/v1/messagesneeds the send permission

Send Content-Type: application/json. The body is limited to 256 KiB (262,144 bytes).

Fields#

FieldTypeRequiredRule
toarray of addressesyesat least one
ccarray of addressesno
bccarray of addressesno
fromaddressnoone of your token's senders; the first one if left out
reply_toaddressnowhere replies go
subjectstringyes1 to 998 characters
htmlstringone of the twoup to 200,000 characters
textstringone of the twoup to 100,000 characters
tagsarray of stringsnoup to 5, each 1 to 32 of A-Z a-z 0-9 _ -
scheduled_atstringnoISO 8601 time, 1 minute to 72 hours from now
attachmentsarray of { "id": ... }no1 to 3 files uploaded first, 4,000,000 bytes together (see below)

Any other field is refused with 400 unknown_field instead of being ignored, so a misspelt replyTo is caught at once instead of silently doing nothing.

Addresses#

An address is a plain string, "guest@example.com", or a string with a display name, "Ana López <guest@example.com>". For from you may also send an object:

JSON
{ "from": { "email": "booking@madagascarhotelags.com", "name": "Hotel Madagascar" } }

Recipients. to, cc and bcc together may hold up to 10 addresses per message unless the hotel set a different limit (between 1 and 50). Every recipient counts against the shared daily allowance, so prefer one message per person over one message to many.

Sender. from must be one of the addresses in your token's senders list (see GET /v1/me); anything else is 403 sender_not_allowed. If you leave it out, the first one is used, with the display name the hotel registered for it. A display name you send is used as given, up to 100 characters, with <, > and " removed. Use the hotel's own name, never a name that could be mistaken for someone else.

The hotel can withdraw a sender at any moment. New requests from it are refused at once; a message that was already accepted ends as failed with the error "This sender is no longer allowed for the API."

Subject and content#

Control characters and line breaks in the subject are replaced by spaces, which also closes the door to header injection.

Send both html and text when you can: some people read plain text only, and spam filters trust messages that carry both.

Every message passes a content check before it is accepted:

  • The HTML is cleaned. The markup emails are made of (text, tables, images, links, inline styles) is kept; scripts, frames, forms, embedded objects, comments and event handlers are removed, and a link or image keeps only an https://, http://, mailto:, tel:, cid: or inline image address.
  • A link to a bare IP address, a link carrying a user name or password, or a link to a domain the hotel has blocked is refused with 422 content_blocked.
  • Anything that looks like a payment card number is refused the same way. Never send card numbers by email.

The cleaning is not a substitute for your own escaping:

Keep HTML simple: inline styles, tables for layout, absolute https:// links and images hosted on your own site. Email clients do not run JavaScript and ignore most external CSS.

Attachments#

A file is uploaded first, then named in the message. The body of the upload is the file itself, not JSON:

Shell
curl -X POST "https://email.madagascarhotelags.com/v1/attachments?filename=invoice-1042.pdf" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/pdf" \
  --data-binary @invoice-1042.pdf

The answer is 201 with the file's id and status: "clean". Then send the message with "attachments": [{ "id": "att_..." }]; it goes out at once.

  • Every file is checked as it arrives. Its contents must be the type its name says, and programs, scripts, macros, embedded files, active PDF content and password-protected files are refused with 422 attachment_refused; detail says why. A refused file is not stored. GET /v1/attachments/{id} shows a stored file, always clean.
  • Limits. 4,000,000 bytes for one file and for all of a message's files together; up to 3 files a message. Types: pdf, png, jpg, jpeg, gif, txt, csv, ics, doc, docx, xls, xlsx, ppt, pptx, odt, ods, rtf, zip.
  • Kept 24 hours. A file can be named in several messages within that time, only by the token that uploaded it. After that it is deleted, and a message naming it is refused with 422 attachment_not_found.
  • When files cannot be taken. If attachments are not available right now, uploads and messages that name files answer 503 attachments_unavailable with Retry-After. Messages without attachments are not affected.

Tags#

Tags label messages for your own reporting, for example ["booking", "confirmation"]. They are stored with the message and passed to the mail system; they never appear to the recipient.

Scheduling#

scheduled_at asks for the message to go out later:

JSON
{ "to": ["guest@example.com"], "subject": "See you tomorrow", "text": "Check-in opens at 9:00.", "scheduled_at": "2026-10-02T14:00:00Z" }

The time must be between 1 minute and 72 hours ahead (400 invalid_schedule otherwise). The message is handed to the mail system straight away with the requested time, so its status becomes sent before the time arrives. Limits are counted on the day you make the request. Until its time comes you can cancel it with POST /v1/messages/{id}/cancel. For anything further ahead, keep it in your own system and send it when it is due.

Suppressed recipients#

The hotel keeps one list of addresses that must not receive mail: people who unsubscribed, addresses that bounced, spam complaints and addresses the hotel added by hand. Just before sending, every recipient on that list is removed from to, cc and bcc, and the number removed is reported as suppressed on the message.

If no to recipient is left, nothing is sent and the message ends as failed with "All recipients are on the suppression list." (or "Every To recipient is on the suppression list." when only cc or bcc addresses remained). Recipients still count against your limits, because limits are counted when the message is accepted.

The answer#

HTTP
HTTP/1.1 202 Accepted
Content-Type: application/json
Location: /v1/messages/msg_01k6qzexample0000000000000
Cache-Control: no-store

{ "id": "msg_01k6qzexample0000000000000", "status": "queued", "created_at": "2026-10-01T15:04:05.000Z" }

Keep the id with your own record. It is how you ask for the status, and how the hotel finds the message if you ask for help.

Last reviewed 2026-10-01.