---
title: "Create a domain"
method: POST
path: "/v1/domains"
tags: ["Domains"]
---

# Create a domain

`POST /v1/domains`

## Request

- Base URL: `https://console.nace.ai`
- URL: `https://console.nace.ai/v1/domains`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/nace/apis/drex-api/docs/v1/domains/post.ts> (a function with typed inputs; its response is checked against the schema)

A new draft owned by the account, empty or with the taxonomy given. Free. A draft can be edited until it is published; it can't be given to a workspace before. The slug must be new to the account and not a platform slug.

## Request body

- object
  - `slug` string, required: Lowercase letters, digits and single underscores. It can't change later.
  - `display_name` string, required
  - `taxonomy` Taxonomy
    - `classes` TaxonomyClass[], required
      - `group` string, required: The first level: lowercase letters, digits and single underscores, up to 64 characters. `group/subgroup` is the folder path, so the pair is unique. A class that breaks these rules refuses the whole create or update with `422 invalid_request`.
      - `subgroup` string, required: The second level: lowercase letters, digits and single underscores, up to 64 characters.
      - `description` string, required: Written for the classifier: this text is the prompt.
      - `aliases` string[]: Earlier names, so old folder paths still resolve. Optional: a class without it has none.
    - `allow_other` true: Always true: a document that fits no class is labelled, not forced into one.

## Response `201`

The new draft and its validation.

- DomainWrite
  - `domain` Domain, required
    - `domain_id` string, required
    - `slug` string, required
    - `display_name` string, required
    - `owner` 'platform' | 'tenant', required: `platform` for the ones every account sees, `tenant` for the account's own.
    - `version` integer, required
    - `status` 'draft' | 'published', required
    - `parent_slug` string, nullable, required: The domain this one inherits from, or null.
    - `class_count` integer, required
    - `selectable` boolean, required: True once published: only then can a new workspace pin it.
    - `taxonomy` Taxonomy, required
      - `classes` TaxonomyClass[], required
        - `group` string, required: The first level: lowercase letters, digits and single underscores, up to 64 characters. `group/subgroup` is the folder path, so the pair is unique. A class that breaks these rules refuses the whole create or update with `422 invalid_request`.
        - `subgroup` string, required: The second level: lowercase letters, digits and single underscores, up to 64 characters.
        - `description` string, required: Written for the classifier: this text is the prompt.
        - `aliases` string[]: Earlier names, so old folder paths still resolve. Optional: a class without it has none.
      - `allow_other` true: Always true: a document that fits no class is labelled, not forced into one.
    - `published_at` string, nullable, required: ISO 8601 timestamp, or null for a draft.
  - `validation` DomainValidation, required
    - `valid` boolean, required
    - `errors` object[], required
      - `code` string, required
      - `path` string, required: The taxonomy entry that failed.
      - `message` string, required
    - `effective_class_count` integer, required

## Other responses

- `401`: Missing or invalid API key (`authentication_error`, code `invalid_api_key`).
- `404`: Domains are off on this deployment (`not_found`).
- `409`: The slug is already taken in the account or is reserved (`conflict_error`, code `domain_in_use` or `reserved_domain_slug`).
- `422`: The body is invalid, or the taxonomy is malformed (`invalid_request_error`).
- `429`: Over the account's requests per minute for document routes (`rate_limit_error`).
- `500`: Something failed on Drex's side (`internal_error`).
- `502`: The document service refused Drex's own request (`upstream_error`, code `ndi_refused_drex`). Retry later.
- `503`: The document service is unavailable (`service_unavailable`).

---

[API](https://skmtc.dev/nace/apis/drex-api.md) - [All operations](https://skmtc.dev/nace/apis/drex-api/llms.txt) - [OpenAPI document](https://skmtc.dev/nace/apis/drex-api/revisions/a0e62d925a61?raw)
