---
title: "Add a custom domain, bound to a site XOR a client space."
method: POST
path: "/custom-domains"
tags: ["Custom domains"]
---

# Add a custom domain, bound to a site XOR a client space.

`POST /custom-domains`

## Request

- Base URL: `https://api.stacktr.ee`
- URL: `https://api.stacktr.ee/custom-domains`
- Auth: one of:
  - HTTP bearer
  - OAuth 2 (authorization code, authorization URL `https://api.stacktr.ee/oauth/authorize`, token URL `https://api.stacktr.ee/oauth/token`, scopes: `sites:write`, `sites:read`)

site_id keeps today’s behaviour (the hostname serves one page). space_id binds the hostname to a client space instead: the portal at /, member pages at /{space_path} — the client-spaces plan unit (Solo 1, Studio 10, Firm unlimited). Under a verified parent-domain claim the per-hostname TXT step is skipped and the response carries covered_by_claim.

## Request body

- object
  - `hostname` string, required
  - `site_id` string, nullable
  - `space_id` string, nullable: Mutually exclusive with site_id.

## Response `201`

Created.

- CustomDomain
  - `hostname` string, required
  - `site_id` string, required
  - `status` 'pending' | 'verified' | 'failed', required
  - `cname_target` string: CNAME value the user must add to their DNS.
  - `verified_at` integer, nullable

## Other responses

- `402`: A plan ceiling was hit. The feature or the quota is not on this plan; the caller needs a different plan or an x402 unlock.
- `403`: Hostname sits under a domain another account has verified.

---

[API](https://skmtc.dev/stacktr/apis/stacktree-api.md) · [All operations](https://skmtc.dev/stacktr/apis/stacktree-api/llms.txt) · [OpenAPI document](https://skmtc.dev/stacktr/apis/stacktree-api/revisions/5878cce46977?raw)
