# POST /v1/tracking-domains

Add a tracking domain

Claims a host under one of the account’s verified sending domains and answers the CNAME record to add. A host whose records are not right within 7 days goes. An account key manages tracking domains; a server key cannot.

Takes an account key (`ak_…`) as a bearer token. TypeScript: `account.trackingDomains.create({ host })`. Python: `account.tracking_domains.create(host=...)`. PHP: `$account->trackingDomains->create(host: $host)`. Java: `account.trackingDomains().create(host)`.

## Request body

- `host` (string, required): The host tracked links and the open pixel use, such as links.example.se: a subdomain of a verified sending domain of the account. Lower-cased and IDNA-encoded.

Example:

```json
{
  "host": "links.example.se"
}
```

## Responses

### 201 A tracking domain, the record it needs and what the last check found.

- `trackingDomainId` (string (uuid), required)
- `host` (string, required): The host, lower-cased and IDNA-encoded.
- `sendingDomainId` (string (uuid) or null, required): The sending domain whose new mail will use the host; null once that domain is deleted.
- `state` ("pending" | "waiting_for_certificate" | "ready" | "failing" | "stopped" | "sending_domain_lost", required): pending: the records have not been right yet, and the host goes at expiresAt. waiting_for_certificate: the records are right. ready: new mail from the sending domain uses the host. failing: a check found the records wrong, and new mail keeps using a host that was ready until 24 hours after failingSince. stopped: those 24 hours have passed. sending_domain_lost: the sending domain is deleted or has lost its verification, so new mail does not use the host.
- `createdAt` (string (date-time), required)
- `lastCheckedAt` (string (date-time) or null, required): When the records were last looked up.
- `certificateReadyAt` (string (date-time) or null, required): When the certificate was proved to work; null before that.
- `failingSince` (string (date-time) or null, required): When a check first found the records wrong on a host whose records have been right. Null unless it is in that warning or past it.
- `expiresAt` (string (date-time) or null, required): When a host whose records have never been right goes; null once they have been.
- `cname` (object, required): The CNAME record to add.
  - `type` ("CNAME", required)
  - `host` (string, required): The name to create the record under.
  - `value` (string, required): The value the record must hold.
  - `check` ("ok" | "missing" | "mismatch" | "proxied" | "dns_error" or null, required): What the last check found; null before the first. mismatch is a record that points elsewhere, an A record included. proxied is a proxy in front of the name, such as Cloudflare’s, which must be switched off. dns_error is a resolver failure, not an absent record, and changes nothing.
- `caa` (object, required): Whether CAA records let Let’s Encrypt issue the certificate.
  - `check` ("ok" | "no_lets_encrypt" | "other_account" | "no_http_01" | "dns_error" or null, required): What the last check of the CAA records on the host and its parents found; null before the first. dns_error is a resolver failure and changes nothing.
  - `record` (object or null, required): What lets the certificate be issued; null unless the check found a problem.
    - `type` ("CAA", required)
    - `host` (string, required): The name that holds the CAA records in the way.
    - `value` (string, required): The record to add beside them.

Example:

```json
{
  "trackingDomainId": "3f2b8c1e-6a7d-4e9f-8b10-5c4d3e2f1a09",
  "host": "links.example.se",
  "sendingDomainId": "0d7f6a1e-4c0b-4b7e-9d3c-2a1f5e8b9c01",
  "state": "pending",
  "createdAt": "2026-11-05T12:00:00.000Z",
  "lastCheckedAt": null,
  "certificateReadyAt": null,
  "failingSince": null,
  "expiresAt": "2026-11-12T12:00:00.000Z",
  "cname": {
    "type": "CNAME",
    "host": "links.example.se",
    "value": "track.sendora.se",
    "check": null
  },
  "caa": {
    "check": null,
    "record": null
  }
}
```

## Errors

Every error answers `error`, the code, and `message`, a sentence for a person. A code that adds fields is shown in full below the table.

| Code | Status | Meaning |
| --- | --- | --- |
| `invalid_request` | 400 | The body, the query or a header does not match what the route takes. |
| `domain_reserved` | 400 | The name is Sendora’s own, or holds a domain’s return path. |
| `unauthorized` | 401 | The key is missing, malformed or revoked. |
| `wrong_token_kind` | 403 | The key is of the other kind: a server key (sk_) where an account key (ak_) is needed, or the reverse. The message names the kind the operation takes. |
| `not_for_connections` | 403 | A connected app called an operation that no tool of the MCP server calls. An API key can. |
| `read_only_connection` | 403 | A connected app may only read here: the account is read only through a connection, and a live server takes changes only if the person allowed them when connecting. |
| `test_server_only` | 403 | A connected app may create a secret, or do what cannot be undone, on a test server only. |
| `tracking_domain_exists` | 409 | The account already has that host, or a host on that sending domain. |
| `tracking_host_taken` | 409 | Another account holds the host, and its sending domain is still verified. |
| `tracking_domain_limit` | 409 | The account has as many tracking domains as it may have. |
| `tracking_host_is_sending_domain` | 422 | The host is a sending domain itself. A tracking domain is a subdomain of one. |
| `tracking_host_not_verified` | 422 | The host is not under a verified sending domain of this account. |

Headers sent with an error:

- `WWW-Authenticate` ("Bearer") on 401: Always Bearer: send the key as Authorization: Bearer <key>.

### `invalid_request`

- `issues` (array of object): One entry per invalid field; absent when a header is wrong.
  - `path` (string, required): The field, dotted, such as to.0.email; empty when the whole body is wrong.
  - `message` (string, required)

Example:

```json
{
  "error": "invalid_request",
  "message": "The request is invalid: to.0: Invalid email address",
  "issues": [
    {
      "path": "to.0",
      "message": "Invalid email address"
    }
  ]
}
```

### `tracking_domain_exists`

- `trackingDomainId` (string (uuid), required): The id of the tracking domain the account already has.

Example:

```json
{
  "error": "tracking_domain_exists",
  "message": "The account already has that host, or a host on that sending domain.",
  "trackingDomainId": "7c9e6679-7425-40de-944b-e07fc1f90ae7"
}
```
