# Custom domains

Connect, verify, list, and remove custom domains, and publish projects to them.

## Workflow

1. **Connect** the domain with `POST /v1/custom-domains`. The response lists the DNS records to add. The same records are emailed to the account owner.
2. **Add the records** at the DNS provider.
3. **Verify** with `POST /v1/custom-domains/{domain}/verify` until `status` is `active`. This usually takes a few minutes and can take up to 72 hours. `GET /v1/custom-domains/{domain}` shows which records are already live.
4. **Publish** with [POST /v1/upload](../../reference/create-project/) and `domain` set to a hostname on the domain, such as `docs.example.com`.

To remove a domain, delete every project published on it, then call `DELETE /v1/custom-domains/{domain}`.

## Authentication and plans

Send `x-api-key: <key>`, the same key as the upload API. Requests count towards the same daily request limit.

| Plan | Custom domains |
| --- | --- |
| Free, Tiny | Not available |
| Solo | 5 |
| Pro | 15 |
| Pro Max | 25 |

Accounts with a custom limit agreed with Tiiny Host use that limit. Every connected domain counts towards the limit, whatever its status. The same limits apply in the dashboard.

## Endpoints

| Method and path | Effect |
| --- | --- |
| `POST /v1/custom-domains` | Connect a domain. JSON body: `{"domain":"docs.example.com"}`. |
| `GET /v1/custom-domains` | List the account's custom domains with the plan limit and how many are used. |
| `GET /v1/custom-domains/{domain}` | Return one domain's status, its DNS records, and which records are live. |
| `POST /v1/custom-domains/{domain}/verify` | Check the DNS records and activate the domain once they are in place. |
| `DELETE /v1/custom-domains/{domain}` | Remove the domain. Every project on it must be deleted first. |

`{domain}` can be the domain (`example.com`) or any hostname on it (`docs.example.com`). Both refer to the same custom domain.

## Subdomain or root domain

The value sent to `POST /v1/custom-domains` decides how the domain is set up. The dashboard offers the same choice.

| You send | Records to add | Result |
| --- | --- | --- |
| A subdomain, such as `docs.example.com` | 2 CNAME records: `*` and a certificate record | Projects can be published on any hostname on `example.com`. |
| The domain itself, such as `example.com` | The 2 above, plus a `www` CNAME and an `@` A record | As above, and visitors to `example.com` are redirected to `www.example.com`. |

The setup is fixed when the domain is first connected. To switch, delete the domain and connect it again.

The certificate record's host is a long name such as `_3f1c….example.com`. If the DNS provider appends the domain automatically, enter only the part before `.example.com`.

## Example

```bash
curl --fail-with-body https://ext.tiiny.host/v1/custom-domains \
  -H "x-api-key: $TIINY_API_KEY" -H 'Content-Type: application/json' \
  -d '{"domain":"docs.example.com"}'

curl --fail-with-body -X POST https://ext.tiiny.host/v1/custom-domains/example.com/verify \
  -H "x-api-key: $TIINY_API_KEY"

curl --fail-with-body https://ext.tiiny.host/v1/upload \
  -H "x-api-key: $TIINY_API_KEY" \
  -F 'domain=docs.example.com' -F 'files=@index.html'
```

## Domain object

```json
{
  "domain": "example.com",
  "subdomain": "docs",
  "rootDomain": false,
  "status": "pending",
  "purchasedThroughTiiny": false,
  "records": [
    {"type":"CNAME","host":"*","value":"d1abc.cloudfront.net"},
    {"type":"CNAME","host":"_3f1c.example.com","value":"_9a8b.acm-validations.aws"}
  ],
  "createdAt": "2026-11-04T10:00:00.000Z"
}
```

| `status` | Meaning |
| --- | --- |
| `pending` | Waiting for the DNS records. Call `verify` again later. |
| `active` | Connected. Projects can be published on it. |
| `failed` | The certificate could not be issued, usually because the records were not added within 72 hours. Delete the domain and connect it again. |
| `disconnecting` | Being removed (older domains only). Call `DELETE` again after 5–10 minutes to finish. |

`GET /v1/custom-domains/{domain}`, and `verify` while the domain is still pending, also return `dnsCheck`, which compares each record with what is live. `dnsCheck` is `null` if the check could not run.

```json
"dnsCheck": {
  "allRecordsFound": false,
  "records": [
    {"type":"CNAME","host":"*","expected":"d1abc.cloudfront.net","found":["d1abc.cloudfront.net"],"matches":true},
    {"type":"CNAME","host":"_3f1c.example.com","expected":"_9a8b.acm-validations.aws","found":[],"matches":false}
  ]
}
```

## Success responses

| Request | Response |
| --- | --- |
| Connect a new domain | `201 {"success":true,"data":<domain object>}` |
| Connect a domain already connected to your account | `200 {"success":true,"data":<domain object>}`. Safe to repeat; no new records are created. |
| List | `200 {"success":true,"data":{"domains":[<domain object>…],"limit":5,"used":1}}` |
| Get one, verify | `200 {"success":true,"data":<domain object>}` |
| Delete | `200 {"success":true,"data":{"domain":"example.com","status":"deleted"}}`, or `"disconnecting"` on older domains |

## Remove a domain

1. Delete each project on the domain with [DELETE /v1/delete](../../reference/delete-project/) and `-F 'domain=docs.example.com'`.
2. Call `DELETE /v1/custom-domains/{domain}`. It returns `status: "deleted"`. On older domains it returns `"disconnecting"`; call it again after 5–10 minutes to finish.

If any projects are still on the domain, step 2 returns `DOMAIN_HAS_SITES` and nothing is removed. The error lists the remaining projects in `sites`.

Domains bought through Tiiny Host cannot be removed through the API. Manage them in the dashboard.

## Errors

Validation problems return `400` with this shape:

```json
{
  "success": false,
  "code": "INVALID_CUSTOM_DOMAIN_REQUEST",
  "message": "This custom domain request couldn't be completed.",
  "errors": [
    {"field":"domain","code":"CUSTOM_DOMAIN_LIMIT_REACHED","message":"Your plan allows up to 5 custom domains."}
  ]
}
```

| `errors[].code` | Meaning |
| --- | --- |
| `INVALID_DOMAIN` | Not a valid domain name (send `example.com`, not `https://example.com/`), or a Tiiny Host domain. |
| `FEATURE_NOT_IN_PLAN` | The plan does not include custom domains. |
| `CUSTOM_DOMAIN_LIMIT_REACHED` | The plan's limit is reached. Delete a domain or upgrade. |
| `DOMAIN_ALREADY_CONNECTED` | Another Tiiny Host account has connected this domain. |
| `PHP_DOMAIN_MANAGED_IN_DASHBOARD` | The domain is used by a PHP project. Manage it in the dashboard. |
| `DOMAIN_PURCHASED_THROUGH_TIINY` | `DELETE` only. The domain was bought through Tiiny Host. Manage it in the dashboard. |
| `DOMAIN_HAS_SITES` | `DELETE` only. Projects are still published on the domain; `sites` lists them. |

```json
{
  "success": false,
  "code": "INVALID_CUSTOM_DOMAIN_REQUEST",
  "message": "This custom domain request couldn't be completed.",
  "errors": [
    {
      "field": "domain",
      "code": "DOMAIN_HAS_SITES",
      "message": "example.com still has 2 live sites. Delete them first, then delete the domain.",
      "sites": ["blog.example.com", "docs.example.com"]
    }
  ]
}
```

A domain that is not connected to your account, including one connected to another account, returns `404 {"success":false,"code":"DOMAIN_DOES_NOT_EXIST","message":"No custom domain with this name is connected to your account."}`.

## Publish on a custom domain

Upload with `domain` set to a hostname on a connected domain, with no scheme or path. If that hostname already belongs to one of your projects, the upload replaces the project's files, so send the complete file set.

Uploading to a custom domain that is not connected to your account returns `403`, from both the API and the dashboard:

```json
{"success":false,"code":"CUSTOM_DOMAIN_NOT_OWNED","error":"CUSTOM_DOMAIN_NOT_OWNED","message":"This domain isn't connected to your account. Connect it with POST /v1/custom-domains first."}
```

[Fetch profile](../../reference/fetch-profile/) also lists configured domains in `data.customDomains` and project hostnames in `data.links[].subdomain`.

[Connect a domain you own](https://helpdesk.tiiny.host/en/article/how-to-connect-a-domain-you-already-own-1sfq7hh/) · [Publish to a custom domain](https://helpdesk.tiiny.host/en/article/publishing-to-your-custom-domain-10u30u9/)
