> ## Documentation Index
> Fetch the complete documentation index at: https://weights.fyi/run/llms.txt

# POST /v1/workspaces/domains

```text
POST https://weights.fyi/run/v1/workspaces/domains
Authorization: Bearer <token>                    scope: manage
Content-Type: application/json
```

**Available since:** 2026-11-15 workspace domains: included in this build; see [What is live](/run/docs/what-is-live.md) for deployment status.

**Answer time:** synchronous: one database write.

Claims an organisation email domain for the calling workspace and returns the DNS TXT record to publish before calling [POST /v1/workspaces/domains/{domain}/verify](/run/docs/reference/workspaces-domains-verify.md). Public mailbox domains and special-use names are refused.

Sending the same domain again is safe: it keeps the issued challenge token so a record already published in DNS stays valid, updates `join_mode` if changed, and answers `200`.

## Request

| Name | Where | Required | Meaning |
|---|---|---|---|
| `Authorization` | header | yes | `Bearer` and a token with `manage` on the workspace. |
| `domain` | body | yes | The organisation's email domain, such as `awow.io`. |
| `join_mode` | body | no | `invite_only` (default), `discoverable` or `auto_join`. |

## Return value

**201 Created** when newly claimed, **200 OK** when already claimed:

| Field | Meaning |
|---|---|
| `domain`, `status`, `join_mode` | Lower-case domain, `pending` or `verified`, and the chosen admission mode. |
| `created_at`, `verified_at`, `last_checked_at` | Timestamps in UTC (`null` before verification). |
| `dns_record` | Canonical TXT record (`name`, `type`, `value`) to publish at `_zyxio-domain-challenge.<domain>`. |
| `accepted_records` | Every TXT name and value accepted, including shared `_weights-challenge` and `_rattle-challenge` labels. |

## Errors

| Status | Code | When it happens | What to do |
|---|---|---|---|
| `400` | `invalid_request`, `invalid_json`, `invalid_domain`, `public_email_domain_refused` | Malformed body, invalid hostname, or a public mailbox domain. | Pass an organisation DNS domain you control. |
| `401` | `unauthorized`, `invalid_token`, `token_revoked`, `token_expired` | No token, or one that does not work. | Use a valid token. |
| `403` | `scope_required`, `workspace_role_required`, `operator_workspace_domain` | Token lacks `manage`, caller is not an owner or admin, or workspace is restricted to `invite_only`. | Use an owner or admin `manage` token on a team workspace. |

## Examples

```sh
curl -s -X POST https://weights.fyi/run/v1/workspaces/domains \
  -H "Authorization: Bearer $WEIGHTS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"domain": "awow.io", "join_mode": "discoverable"}'
```

```json
{"domain": "awow.io", "status": "pending", "join_mode": "discoverable", "created_at": "2026-11-15T10:00:00Z", "verified_at": null, "last_checked_at": null, "dns_record": {"name": "_zyxio-domain-challenge.awow.io", "type": "TXT", "value": "zyxio-domain-verify=a1b2c3d4a1b2c3d4a1b2c3d4a1b2c3d4a1b2c3d4a1b2c3d4a1b2c3d4a1b2c3d4"}}
```

## History

- 2026-11-15 workspace domains: added.

## See also

- [POST /v1/workspaces/domains/{domain}/verify](/run/docs/reference/workspaces-domains-verify.md) to check DNS and complete verification.
- [Teams and workspaces](/run/docs/teams.md#verify-your-domain), the topic.
