# Domains

A domain is where your mail comes from. It can send once its DNS records are published and checked.

## Add a domain

Give the name of the domain. A subdomain such as `mail.example.com` keeps the reputation of your sending apart from your main domain. `region` picks where mail is sent from: `us-east-1`, `eu-west-1` or `ap-northeast-1`.

cURL:

```bash
curl -X POST "$OPENSEND_API_URL/v1/domains" \
  -H "Authorization: Bearer $OPENSEND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "updates.example.com",
  "region": "us-east-1"
}'
```

TypeScript:

```ts
await opensend.domains.create({
  name: 'updates.example.com',
  region: 'us-east-1',
})
```

CLI:

```bash
opensend domains create --name updates.example.com --region us-east-1
```

MCP:

```json
{
  "name": "domains_create",
  "arguments": {
    "name": "updates.example.com",
    "region": "us-east-1"
  }
}
```

The answer holds the records to publish.

domains.create:

```json
{
  "object": "domain",
  "id": "dom_04",
  "name": "updates.example.com",
  "status": "pending",
  "region": "us-east-1",
  "openTracking": true,
  "clickTracking": false,
  "records": [
    {
      "id": "mx-0",
      "type": "MX",
      "host": "send",
      "value": "feedback.platform.test",
      "priority": 10,
      "ttl": "Auto",
      "status": "pending"
    },
    {
      "id": "txt-1",
      "type": "TXT",
      "host": "@",
      "value": "v=spf1 include:platform.test ~all",
      "priority": null,
      "ttl": "Auto",
      "status": "pending"
    }
  ],
  "events": [
    {
      "id": "evt_1795771800000",
      "title": "Domain added",
      "at": "2026-11-27T09:30:00.000Z",
      "status": "pending",
      "detail": ""
    }
  ],
  "createdAt": "2026-11-27T09:30:00.000Z"
}
```

> The record values in this example are placeholders. Publish the values in your own answer.

## Publish the records and verify

1. Add each record at your DNS provider, with the type, host and value from the answer.
2. Ask for the records to be checked. DNS can take a while to spread, so a first check may still find nothing.
3. When every record is found, the domain is `verified` and can send.

cURL:

```bash
curl -X POST "$OPENSEND_API_URL/v1/domains/dom_02/verify" \
  -H "Authorization: Bearer $OPENSEND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

TypeScript:

```ts
await opensend.domains.verify('dom_02')
```

CLI:

```bash
opensend domains verify dom_02
```

MCP:

```json
{
  "name": "domains_verify",
  "arguments": {
    "id": "dom_02"
  }
}
```

- `pending`: not every record has been found yet.
- `verified`: every record is in place.
- `failed`: a record is there but wrong. Each record has its own `status`, so you can see which one.

The domain is also checked again by itself when the platform reports a change, and `events` keeps the history.

## Open and click tracking

Tracking is set per domain. With `openTracking` on, opens are counted and the event `email.opened` is sent. With `clickTracking` on, links are counted and `email.clicked` is sent.

cURL:

```bash
curl -X PATCH "$OPENSEND_API_URL/v1/domains/dom_02" \
  -H "Authorization: Bearer $OPENSEND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "clickTracking": true
}'
```

TypeScript:

```ts
await opensend.domains.update('dom_02', {
  clickTracking: true,
})
```

CLI:

```bash
opensend domains update dom_02 --click-tracking
```

MCP:

```json
{
  "name": "domains_update",
  "arguments": {
    "id": "dom_02",
    "clickTracking": true
  }
}
```

## Limits and errors

- A plan allows a number of domains. One more is refused with `domain_limit`. [Limits](https://opensend.sh/docs/limits) has the numbers.
- `domain_taken`: the workspace already has that domain.
- `domain_refused`: the platform would not take the domain, for example because another account holds it.
- `domain_no_provider`: sending is not connected on this server, so there are no records to check.
