Get started

Quickstart

Four requests take you from a new token to a sent email. Use the language tabs to see each step in the language you work in; your choice is remembered on every page.

  1. Keep the token where your server can read it#

    The hotel gives you a token that looks like ems_ followed by 12 characters, an underscore and 40 more. It is shown once. Store it as a secret on the server that will send email, never in a browser, a mobile app or a repository.

    Shell
    # macOS and Linux (add it to your secret manager for production)
    export EMAIL_API_TOKEN="ems_..."
    PowerShell
    # Windows PowerShell, for this session
    $env:EMAIL_API_TOKEN = "ems_..."
  2. Check what the token can do#

    GET /v1/me answers with the token's permissions, the sender addresses it may use, its limits and today's usage. It needs no particular permission, so it is the safest first call.

    Shell
    curl -sS https://email.madagascarhotelags.com/v1/me \
      -H "Authorization: Bearer $EMAIL_API_TOKEN"

    A 200 with your token's name means you are ready. A 401 means the token is missing, mistyped or no longer valid: the request builder can check its shape without sending it anywhere.

  3. Send a message#

    Post the message as JSON. The Idempotency-Key makes the request safe to repeat: if your code retries after a timeout, the API returns the first answer instead of sending a second email.

    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>"
      }'

    The answer is 202 Accepted with the message id. "Accepted" means the API has the message and has queued it; delivery happens a moment later.

    Response 202
    {
      "id": "msg_01k6qzexample0000000000000",
      "status": "queued",
      "created_at": "2026-10-01T15:04:05.000Z"
    }
  4. Follow it#

    Ask for the message by id (this needs the token's read permission). Within a few seconds the status moves from queued to sent.

    Shell
    curl -sS https://email.madagascarhotelags.com/v1/messages/msg_01k6qzexample0000000000000 \
      -H "Authorization: Bearer $EMAIL_API_TOKEN"

    Poll no more often than every 10 seconds, and stop when the status is sent, failed or dead. Message status explains each one.

Where to go next#

  • Building a real integration? Add it to your code has ready client modules with retries and timeouts.
  • Need a field the example did not use (cc, bcc, reply-to, tags, scheduling)? See Sending email.
  • Something answered with an error? Every code is explained in Errors.

Last reviewed 2026-10-01.