> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.mailercloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send transactional email

> Send order confirmations, OTPs, and notifications with the Mailercloud Email API from PHP, Node.js, or any HTTP client.

Transactional emails (order confirmations, password resets, OTPs) use the dedicated **Email API** at `https://email-api.mailercloud.com` — separate from the campaign API.

Set `version` to `"1.0"` when sending `html` only, or `"2.0"` when including `amp_html`.

<CodeGroup>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://email-api.mailercloud.com/email \
    --header 'Authorization: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
      "version": "1.0",
      "email": {
        "from": "orders@yourdomain.com",
        "fromName": "Acme Store",
        "subject": "Your order is confirmed",
        "html": "<html><body><p>Thanks for your order!</p></body></html>",
        "text": "Thanks for your order!",
        "recipients": {
          "to": [{ "name": "Jane", "email": "jane@example.com" }]
        }
      }
    }'
  ```

  ```php PHP theme={null}
  <?php
  $payload = [
    'version' => '1.0',
    'email' => [
      'from' => 'orders@yourdomain.com',
      'fromName' => 'Acme Store',
      'subject' => 'Your order is confirmed',
      'html' => '<html><body><p>Thanks for your order!</p></body></html>',
      'text' => 'Thanks for your order!',
      'recipients' => [
        'to' => [['name' => 'Jane', 'email' => 'jane@example.com']],
      ],
    ],
  ];

  $ch = curl_init('https://email-api.mailercloud.com/email');
  curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
      'Authorization: YOUR_API_KEY',
      'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode($payload),
  ]);
  $response = curl_exec($ch);
  curl_close($ch);
  echo $response;
  ```

  ```javascript Node.js theme={null}
  const response = await fetch("https://email-api.mailercloud.com/email", {
    method: "POST",
    headers: {
      Authorization: "YOUR_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      version: "1.0",
      email: {
        from: "orders@yourdomain.com",
        fromName: "Acme Store",
        subject: "Your order is confirmed",
        html: "<html><body><p>Thanks for your order!</p></body></html>",
        text: "Thanks for your order!",
        recipients: {
          to: [{ name: "Jane", email: "jane@example.com" }],
        },
      },
    }),
  });
  console.log(await response.json());
  ```
</CodeGroup>

## Per-recipient personalization (mail merge)

To personalize each recipient's email in a single request — `Hi {{first_name}}, your order {{order.id}} shipped` — use the [mail merge endpoint](/api-reference/email/send-personalized-email): same request structure at `POST /email-api`, plus a `merge_vars` object on each `recipients.to[]` entry.

## Attachments

Pass an `attachments` array with a `name` and a publicly fetchable `url` per file — see the [full reference](/api-reference/email/send-email).
