# Email API

> Add and verify sending domains, manage destination addresses, and read what your Workers sent.

Source: https://docs.fortly.com/api/email

The settings behind a Worker's `send_email` binding. They belong to the account and serve every project it owns. See [Email](https://docs.fortly.com/email) for how sending works.

- `GET /email` — Domains, destinations, sending Workers and this month's count
- `POST /email/domains` — Add a sending domain
- `POST /email/domains/{domain}/verify` — Check its DNS records now
- `DELETE /email/domains/{domain}` — Remove a sending domain
- `POST /email/destinations` — Add a destination and mail it a confirmation link
- `DELETE /email/destinations/{address}` — Remove a destination
- `GET /email/activity` — The last 100 messages

## Add a sending domain

```bash
curl -X POST https://api.fortly.com/email/domains \
  -H "Authorization: Bearer $FORTLY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"domain": "mail.example.com"}'
```

Answers `201` with the domain and the records to publish:

```json
{
  "domain": "mail.example.com",
  "state": "pending",
  "records": [
    { "purpose": "ownership", "type": "TXT", "name": "mailjet._1a2b3c4d.mail.example.com", "value": "1a2b3c4d…", "status": "pending", "required": true },
    { "purpose": "dkim", "type": "TXT", "name": "mailjet._domainkey.mail.example.com", "value": "k=rsa; p=…", "status": "pending", "required": true },
    { "purpose": "spf", "type": "TXT", "name": "mail.example.com", "value": "v=spf1 include:spf.mailjet.com ~all", "status": "pending", "required": false }
  ],
  "created_at": 1792303200,
  "checked_at": null,
  "verified_at": null,
  "last_error": null
}
```

A domain becomes `verified` once its required records check out. Fortly re-checks a pending domain every five minutes for three days after it is added; `verify` checks at once, at any time. A domain verified by another account answers `409`.

## Add a destination

```bash
curl -X POST https://api.fortly.com/email/destinations \
  -H "Authorization: Bearer $FORTLY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"address": "me@example.com"}'
```

Answers `201` with `{ "address": "me@example.com", "confirmed": false }` and mails the address a confirmation link. Calling it again for an address still waiting sends the link again. An address that is already confirmed answers `200` with `"confirmed": true`.

## Activity

`GET /email/activity` takes an optional `?project=`. Each message has `sender`, `recipients`, `subject` (the MIME Subject header for a raw message when readable; otherwise null), `bytes`, `result` (`sent`, `refused` or `failed`), `detail` (the reason, when it was not sent) and `at`.

The response wraps the newest 100 entries in `messages`. These routes configure outbound sending; they do not provision incoming routing or a Worker’s `email()` handler. See [Email](https://docs.fortly.com/email) for setup, binding restrictions and monthly allowances.
