---
title: "generate_domain"
method: POST
path: "/v1/domains/generate"
tags: ["domains"]
---

# generate_domain

`POST /v1/domains/generate`

## Request

- Base URL: `https://ndi-api.nace.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://ndi-api.nace.ai/v1/domains/generate`
- Auth: API key in header `X-API-Key`
- TypeScript: <https://skmtc.dev/nace/apis/ndi-service/docs/v1/domains/generate/post.ts> (a function with typed inputs; its response is checked against the schema)

Draft a taxonomy from a description or Parse job. Cost class: slow.

Synchronous and **non-persisting**: the model proposes a taxonomy the author
edits, then posts to ``POST /v1/domains``. Nothing is written to the
database and no job is created. Kept off MCP because authoring is a reviewed
human act, not an agent-loop step.

Args:
    session: Database session used only to resolve a caller-owned Parse job.
    caller: The authenticated tenant (authorization only — no domain row is owned yet).
    request: The description or Parse-result source and optional identity hints.

Returns:
    Normalized taxonomy, suggested identity fields, and publish-gate validation
    for the draft.

Raises:
    PlatformError: ``upstream_unavailable`` when the model call fails, or
        ``job_timeout`` when it times out (both retryable).

## Request body

- GenerateDomainRequest: Ask the model for an unsaved taxonomy draft. Nothing is persisted: the caller edits the draft, then posts it to ``POST /v1/domains``. Optional ``display_name`` / ``slug`` seed the suggested identity fields returned alongside the taxonomy. Exactly one input is required: a written description, or a succeeded Parse job.
  - `description` string, nullable: What kinds of files belong in this domain — the classifier-facing brief.
  - `source` ParseResultSource: A prior Parse job whose parsed artifact can be reused by downstream methods.
    - `type` 'parse_result'
    - `job_id` string, uuid, required: Succeeded parse job whose artifact should be reused.
  - `sheet_name` string, nullable: Workbook worksheet to extract. Required when the Parse result contains multiple sheets.
  - `display_name` string, nullable: Optional name hint used when suggesting a display name and slug.
  - `slug` string, nullable: Optional slug hint. When omitted, the model derives one from the input.

## Response `200`

Successful Response

- GenerateDomainResponse: An unsaved draft ready for the authoring UI to edit and then create.
  - `taxonomy` TaxonomyOutput, required: The classification vocabulary.
    - `classes` TaxonomyClass[]
      - `group` string, required
      - `subgroup` string, required
      - `description` string, required: Written for the classifier — it IS the prompt.
      - `aliases` string[]: Renames land here so old folder paths stay resolvable.
    - `allow_other` true: Cannot be disabled: a document that fits nothing is labelled 'other', never force-fitted.
  - `suggested_slug` string, required
  - `suggested_display_name` string, required
  - `validation` DomainValidation, required: Returned on every domain write, so a caller never has to guess whether a publish will succeed.
    - `valid` boolean, required
    - `errors` DomainValidationError[]
      - `code` string, required
      - `path` string, required
      - `message` string, required
    - `effective_class_count` integer, required

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `402`: Payment Required
- `403`: Forbidden
- `404`: Not Found
- `409`: Conflict
- `410`: Gone
- `413`: Request Entity Too Large
- `422`: Unprocessable Entity
- `424`: Failed Dependency
- `429`: Too Many Requests
- `500`: Internal Server Error
- `501`: Not Implemented
- `503`: Service Unavailable
- `504`: Gateway Timeout

---

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