# Domains

- Page: https://bytesms.com/docs/domains (markdown: https://bytesms.com/docs/domains.md)
- API base URL: https://api.bytesms.com/api (public resources under /api/v1)
- Auth: `Authorization: Bearer tp_live_…` — an API key from Dashboard → API Keys; keep it server-side (e.g. `BYTESMS_API_KEY`)
- All docs in one file: https://bytesms.com/llms-full.txt · OpenAPI 3.1: https://bytesms.com/openapi.json

Add and verify sending domains in Bytesms: DKIM, custom return path, SPF and DMARC DNS records, statuses and regions.

You can only send from domains you have verified in your workspace. Verification proves you control the domain and sets up the DNS records receiving servers use to authenticate your mail. All domain endpoints require a `full_access` key.

## Create a domain

`POST https://api.bytesms.com/api/v1/domains`

**Body**

- `name` (string, required): The domain or subdomain, e.g. `example.com` or `mail.example.com`(3–253 characters). IP addresses, names without a TLD, Bytesms' own domains and consumer mailbox domains (gmail.com, …) are refused with `422 invalid_domain` / `reserved_domain`.
- `region` (string, optional, default `ap-southeast-7`): Sending region: `ap-southeast-7` (Thailand), `ap-southeast-1` (Singapore) or `eu-central-1` (Frankfurt). See [Regions](https://bytesms.com/docs/regions). A region without an available sending server falls back to the default region — check `region` in the response.
- `custom_return_path` (string, optional, default `send`): Label of the return-path subdomain (`<label>.<domain>`). One lowercase DNS label: a–z, 0–9 and `-`, 1–63 characters, not starting or ending with `-`. `www`, `mail`, `smtp`, `mx`, `imap`, `pop`, `pop3`, `autodiscover` and `autoconfig` are reserved.

**cURL**

```bash
# Create a domain
curl -X POST 'https://api.bytesms.com/api/v1/domains' \
  -H 'Authorization: Bearer tp_live_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{"name":"example.com","region":"ap-southeast-7"}'
```

**Node.js**

```js
// Create a domain
const res = await fetch("https://api.bytesms.com/api/v1/domains", {
  method: "POST",
  headers: {
    Authorization: "Bearer tp_live_xxxxxxxxx",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "name": "example.com",
    "region": "ap-southeast-7"
  }),
});
console.log(await res.json());
```

**Python**

```python
import requests

# Create a domain
res = requests.post(
    "https://api.bytesms.com/api/v1/domains",
    headers={"Authorization": "Bearer tp_live_xxxxxxxxx"},
    json={
        "name": "example.com",
        "region": "ap-southeast-7"
    },
)
print(res.json())
```

**Response**

```json
{
  "id": "cmg4jz1pb0000l8v9a6c3e2kf",
  "name": "example.com",
  "status": "not_started",
  "region": "ap-southeast-7",
  "created_at": "2026-09-28T08:00:00.000Z",
  "custom_return_path": "send",
  "records": [
    {
      "record": "DKIM",
      "name": "bytesms._domainkey.example.com",
      "type": "TXT",
      "ttl": "Auto",
      "status": "not_started",
      "value": "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA…"
    },
    {
      "record": "RETURN_PATH",
      "name": "send.example.com",
      "type": "CNAME",
      "ttl": "Auto",
      "status": "not_started",
      "value": "mta.bytesms.com"
    },
    {
      "record": "SPF",
      "name": "example.com",
      "type": "TXT",
      "ttl": "Auto",
      "status": "not_started",
      "value": "v=spf1 include:_spf.bytesms.com ~all"
    },
    {
      "record": "DMARC",
      "name": "_dmarc.example.com",
      "type": "TXT",
      "ttl": "Auto",
      "status": "not_started",
      "value": "v=DMARC1; p=none; rua=mailto:dmarc@reports.bytesms.com"
    }
  ]
}
```

- `409 domain_in_use` — the domain is verified in another workspace; you can [move it](https://bytesms.com/docs/domains#transfer) from the dashboard. `409 domain_pending_elsewhere`— another workspace added it less than 72 hours ago and hasn't verified it yet.
- `403 plan_limit_exceeded` (`code: domain_limit_reached`) — your plan's domain limit is reached.

## DNS records

Publish the records from the `records` array at your DNS provider exactly as returned — names and values differ per domain and region.

| record | Type | Required | Purpose |
| --- | --- | --- | --- |
| `DKIM` | TXT | Yes | Public key at `bytesms._domainkey.<domain>`. Every message is signed with the matching private key as `d=<your domain>`, which is what DMARC alignment needs. |
| `RETURN_PATH` | CNAME | Yes* | `send.<domain>` (or your custom label) → the region's bounce host, e.g. `mta.bytesms.com`. The envelope sender of your mail lives on this subdomain, so SPF passes aligned with your domain and bounces flow back to Bytesms. |
| `SPF` | TXT | Alternative | `include:_spf.bytesms.com`on the domain itself. Only needed if you can't publish the return-path CNAME; merge it into an existing SPF record instead of adding a second one. |
| `DMARC` | TXT | Recommended | `_dmarc.<domain>`. Start with `p=none` and a `rua` report address, then tighten to `quarantine`/`reject` once reports look clean. Gmail and Yahoo require a DMARC record for bulk senders. |

* A domain becomes `verified` when DKIM resolves **and**either the return-path CNAME or SPF does. Each record's `status` shows the last check result, so a verified domain can still list an optional record as `not_started`.

> **Note: Changing the return-path label**
>
> The label is chosen when you create the domain. To change it later, use **Dashboard → Domains**; the return path then has to verify again.

### One-click setup (Domain Connect)

If your DNS provider supports the Domain Connect protocol with the Bytesms template, the dashboard shows a **one-click setup** button on the domain page that publishes the records for you after you approve them at your provider. Otherwise the dashboard shows the records to copy manually.

### Verification statuses

| status | Meaning |
| --- | --- |
| `not_started` | Created; verification hasn't run yet. |
| `pending` | Checking DNS. Re-checked automatically every few minutes. |
| `verified` | Ready to send. |
| `temporary_failure` | A verified domain's records stopped resolving; it is re-checked and returns to verified once they resolve again. |
| `failed` | Records were not found within 72 hours (or stayed missing). Fix DNS and verify again. |

Status changes are sent as `domain.updated` [webhook](https://bytesms.com/docs/webhooks) events.

## Verify a domain

`POST https://api.bytesms.com/api/v1/domains/{domain_id}/verify`

Starts (or re-runs) DNS verification. Poll the domain or listen for `domain.updated` for the result.

**cURL**

```bash
# Verify a domain
curl -X POST 'https://api.bytesms.com/api/v1/domains/cmg4jz1pb0000l8v9a6c3e2kf/verify' \
  -H 'Authorization: Bearer tp_live_xxxxxxxxx'
```

**Node.js**

```js
// Verify a domain
const res = await fetch("https://api.bytesms.com/api/v1/domains/cmg4jz1pb0000l8v9a6c3e2kf/verify", {
  method: "POST",
  headers: {
    Authorization: "Bearer tp_live_xxxxxxxxx",
  },
});
console.log(await res.json());
```

**Python**

```python
import requests

# Verify a domain
res = requests.post(
    "https://api.bytesms.com/api/v1/domains/cmg4jz1pb0000l8v9a6c3e2kf/verify",
    headers={"Authorization": "Bearer tp_live_xxxxxxxxx"},
)
print(res.json())
```

**Response**

```json
{
  "object": "domain",
  "id": "cmg4jz1pb0000l8v9a6c3e2kf"
}
```

## Retrieve a domain

`GET https://api.bytesms.com/api/v1/domains/{domain_id}`

Returns the domain with its records, like the create response plus `object: "domain"`.

**cURL**

```bash
# Retrieve a domain
curl -X GET 'https://api.bytesms.com/api/v1/domains/cmg4jz1pb0000l8v9a6c3e2kf' \
  -H 'Authorization: Bearer tp_live_xxxxxxxxx'
```

**Node.js**

```js
// Retrieve a domain
const res = await fetch("https://api.bytesms.com/api/v1/domains/cmg4jz1pb0000l8v9a6c3e2kf", {
  method: "GET",
  headers: {
    Authorization: "Bearer tp_live_xxxxxxxxx",
  },
});
console.log(await res.json());
```

**Python**

```python
import requests

# Retrieve a domain
res = requests.get(
    "https://api.bytesms.com/api/v1/domains/cmg4jz1pb0000l8v9a6c3e2kf",
    headers={"Authorization": "Bearer tp_live_xxxxxxxxx"},
)
print(res.json())
```

## List domains

`GET https://api.bytesms.com/api/v1/domains`

**cURL**

```bash
# List domains
curl -X GET 'https://api.bytesms.com/api/v1/domains' \
  -H 'Authorization: Bearer tp_live_xxxxxxxxx'
```

**Node.js**

```js
// List domains
const res = await fetch("https://api.bytesms.com/api/v1/domains", {
  method: "GET",
  headers: {
    Authorization: "Bearer tp_live_xxxxxxxxx",
  },
});
console.log(await res.json());
```

**Python**

```python
import requests

# List domains
res = requests.get(
    "https://api.bytesms.com/api/v1/domains",
    headers={"Authorization": "Bearer tp_live_xxxxxxxxx"},
)
print(res.json())
```

**Response**

```json
{
  "object": "list",
  "has_more": false,
  "data": [
    {
      "id": "cmg4jz1pb0000l8v9a6c3e2kf",
      "name": "example.com",
      "status": "verified",
      "region": "ap-southeast-7",
      "created_at": "2026-09-28T08:00:00.000Z"
    }
  ]
}
```

## Delete a domain

`DELETE https://api.bytesms.com/api/v1/domains/{domain_id}`

Removes the domain from the workspace and from its sending server, including its DKIM key (adding it again later creates a new key, so the DKIM record must be updated). If the sending server can't be reached, nothing is deleted and the call fails with `503` — retry it.

**cURL**

```bash
# Delete a domain
curl -X DELETE 'https://api.bytesms.com/api/v1/domains/cmg4jz1pb0000l8v9a6c3e2kf' \
  -H 'Authorization: Bearer tp_live_xxxxxxxxx'
```

**Node.js**

```js
// Delete a domain
const res = await fetch("https://api.bytesms.com/api/v1/domains/cmg4jz1pb0000l8v9a6c3e2kf", {
  method: "DELETE",
  headers: {
    Authorization: "Bearer tp_live_xxxxxxxxx",
  },
});
console.log(await res.json());
```

**Python**

```python
import requests

# Delete a domain
res = requests.delete(
    "https://api.bytesms.com/api/v1/domains/cmg4jz1pb0000l8v9a6c3e2kf",
    headers={"Authorization": "Bearer tp_live_xxxxxxxxx"},
)
print(res.json())
```

**Response**

```json
{
  "object": "domain",
  "id": "cmg4jz1pb0000l8v9a6c3e2kf",
  "deleted": true
}
```

## Moving a domain between workspaces

A domain belongs to one workspace. If it is already verified in another workspace, adding it in the dashboard (Domains → Add domain) offers to move it instead. The domain keeps its DKIM key, sending region and return path, so the DNS records you published keep working and nothing changes at your DNS provider.

- **You are an owner or admin of both workspaces:** review what the move affects and confirm. No DNS change is needed.
- **Otherwise:** prove you control the domain's DNS by publishing a TXT record `_bytesms-claim.<domain>` with the value `bytesms-claim=<token>` shown in the dashboard (valid for 72 hours), click Verify, then confirm.

Before you confirm you see counts only of what changes in the other workspace. On the move, its queued and scheduled emails from that exact domain (subdomains are separate domains) are canceled with `domain_transferred`and don't count toward its quota, its scheduled broadcasts from the domain are canceled, and API keys restricted to the domain are suspended. Emails already being sent, draft broadcasts and templates are kept. Its owners and admins are emailed that the domain moved, without naming the new workspace. A move is refused while either workspace is suspended, under review or paused, while the domain is flagged by abuse protection, or when your plan's domain limit is reached — contact support in those cases. The move is a dashboard action; the `/v1` API has no transfer endpoint.
