> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mixpeek.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a taxonomy from a document selection or a cluster run (one gesture)

> Promote a document selection (e.g. a lasso/cluster selection in the cluster
visualization) into a NEW flat taxonomy in one call.

Creates, in order:
1. a **node collection** mirroring the selection's vector index (same vector
   name, dimensions, and feature_uri — no re-embedding, no GPU work),
2. a **vector-search retriever** over it,
3. the **flat taxonomy** wired to both (input_mappings map an incoming
   document's stored embedding onto the retriever),
4. the **nodes**, from one of two sources:
   - `documents` + `node_label`: one node whose anchor vector is the centroid
     of the referenced documents' stored vectors;
   - `cluster_run` (`{cluster_id, run_id}`): one node per cluster in that run,
     labeled with the cluster's label and anchored on its stored centroid, so
     a whole cluster run becomes a classifier in one call. The response's
     `nodes` lists every node created.

Documents enriched through the taxonomy afterwards are labeled with the
nearest node's `label`. To add more nodes later, use
`POST /v1/taxonomies/{taxonomy_id}/nodes/from-documents`.

Resources created before a failing step are cleaned up best-effort.



## OpenAPI

````yaml post /v1/taxonomies/from-documents
openapi: 3.1.0
info:
  title: Mixpeek API
  description: >-
    This is the Mixpeek API, providing access to various endpoints for data
    processing and retrieval.
  termsOfService: https://mixpeek.com/terms
  contact:
    name: Mixpeek Support
    url: https://mixpeek.com/contact
    email: info@mixpeek.com
  version: '0.82'
servers:
  - url: https://api.mixpeek.com
    description: Production
security:
  - BearerAuth: []
paths:
  /v1/taxonomies/from-documents:
    post:
      tags:
        - Taxonomies
      summary: >-
        Create a taxonomy from a document selection or a cluster run (one
        gesture)
      description: >-
        Promote a document selection (e.g. a lasso/cluster selection in the
        cluster

        visualization) into a NEW flat taxonomy in one call.


        Creates, in order:

        1. a **node collection** mirroring the selection's vector index (same
        vector
           name, dimensions, and feature_uri — no re-embedding, no GPU work),
        2. a **vector-search retriever** over it,

        3. the **flat taxonomy** wired to both (input_mappings map an incoming
           document's stored embedding onto the retriever),
        4. the **nodes**, from one of two sources:
           - `documents` + `node_label`: one node whose anchor vector is the centroid
             of the referenced documents' stored vectors;
           - `cluster_run` (`{cluster_id, run_id}`): one node per cluster in that run,
             labeled with the cluster's label and anchored on its stored centroid, so
             a whole cluster run becomes a classifier in one call. The response's
             `nodes` lists every node created.

        Documents enriched through the taxonomy afterwards are labeled with the

        nearest node's `label`. To add more nodes later, use

        `POST /v1/taxonomies/{taxonomy_id}/nodes/from-documents`.


        Resources created before a failing step are cleaned up best-effort.
      operationId: create_taxonomy_from_documents_v1_taxonomies_from_documents_post
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTaxonomyFromDocumentsRequest'
        description: >-
          Keys this body does not declare are refused with 422 extra_forbidden
          naming the accepted keys (since 2026-11-02).
        x-unknown-keys:
          until: '2026-11-02'
          then: 422 extra_forbidden
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaxonomyNodeFromDocumentsResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
          NamespaceHeader: []
components:
  schemas:
    CreateTaxonomyFromDocumentsRequest:
      properties:
        node_label:
          anyOf:
            - type: string
              minLength: 1
            - type: 'null'
          title: Node Label
          description: >-
            Label of the node created from `documents`. Required with
            `documents`; with `cluster_run` each node takes its cluster's label.
        documents:
          anyOf:
            - items:
                $ref: '#/components/schemas/DocumentRef'
              type: array
              maxItems: 200
              minItems: 1
            - type: 'null'
          title: Documents
          description: >-
            Documents whose stored vectors are averaged into the one node's
            anchor. Give this or `cluster_run`.
        node_fields:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Node Fields
          description: >-
            Optional extra fields stored on the node document (e.g.
            `description`). Only fields listed in the taxonomy's
            enrichment_fields are copied during enrichment.
        vector_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Vector Name
          description: >-
            Optional explicit vector (index) name for the anchor. If omitted, it
            is derived from the taxonomy's node collection vector indexes.
        provenance:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Provenance
          description: >-
            Optional freeform origin context (e.g. cluster_id, run_id, selection
            type). Stored on the node document under `metadata.promotion` for
            auditability.
        cluster_run:
          anyOf:
            - $ref: '#/components/schemas/ClusterRunSource'
            - type: 'null'
          description: >-
            Promote a whole cluster run in one call: one node per cluster,
            labelled with the cluster label, anchored on the cluster's stored
            centroid vector (no re-embedding). Give this or `documents`.
        taxonomy_name:
          type: string
          minLength: 1
          title: Taxonomy Name
          description: Unique name for the new taxonomy.
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: Optional taxonomy description.
        enrichment_target_field:
          anyOf:
            - type: string
            - type: 'null'
          title: Enrichment Target Field
          description: >-
            Field name written onto enriched documents (defaults to
            '<taxonomy_name>_label').
      type: object
      required:
        - taxonomy_name
      title: CreateTaxonomyFromDocumentsRequest
      description: >-
        One-gesture promotion: create a flat taxonomy (node collection +

        vector-search retriever) AND its nodes, from a document selection or
        from

        a whole cluster run.


        The node collection mirrors the source collection's vector index (same

        vector name / dimensions / feature_uri), so classification is guaranteed

        dimension-compatible with the data the nodes came from.


        Give exactly one source: ``documents`` with ``node_label`` (one node
        whose

        anchor averages the documents), or ``cluster_run`` (one node per cluster

        in that run, labelled with the cluster's label, its stored centroid as
        the

        anchor).
    TaxonomyNodeFromDocumentsResponse:
      properties:
        taxonomy_id:
          type: string
          title: Taxonomy Id
        taxonomy_name:
          type: string
          title: Taxonomy Name
        node_document_id:
          type: string
          title: Node Document Id
          description: ID of the created node document (the taxonomy node).
        node_collection_id:
          type: string
          title: Node Collection Id
          description: The taxonomy's node (source) collection.
        node_label:
          type: string
          title: Node Label
        vector_name:
          type: string
          title: Vector Name
          description: Vector index name the anchor was stored under.
        vector_dimensions:
          type: integer
          title: Vector Dimensions
        documents_used:
          type: integer
          title: Documents Used
          description: How many referenced documents contributed to the anchor.
        documents_skipped:
          items:
            $ref: '#/components/schemas/SkippedDocumentRef'
          type: array
          title: Documents Skipped
        taxonomy_created:
          type: boolean
          title: Taxonomy Created
          description: True when this call also created the taxonomy (one-gesture mode).
          default: false
        retriever_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Retriever Id
          description: Retriever created for the taxonomy (one-gesture mode only).
        enrichment_hint:
          type: string
          title: Enrichment Hint
          description: >-
            Plain-language description of how the new node will be applied to
            future data.
        nodes:
          anyOf:
            - items:
                $ref: '#/components/schemas/PromotedNode'
              type: array
            - type: 'null'
          title: Nodes
          description: >-
            Every node created, when the source was a `cluster_run` (one per
            cluster). `node_document_id` and `node_label` name the first.
      type: object
      required:
        - taxonomy_id
        - taxonomy_name
        - node_document_id
        - node_collection_id
        - node_label
        - vector_name
        - vector_dimensions
        - documents_used
        - enrichment_hint
      title: TaxonomyNodeFromDocumentsResponse
      description: Result of promoting a document selection to a taxonomy node.
    ErrorResponse:
      properties:
        success:
          type: boolean
          title: Success
          description: Always false for error responses
          default: false
        status:
          type: integer
          title: Status
          description: HTTP status code for this error
        error:
          $ref: '#/components/schemas/ErrorDetail'
          description: Error details payload
      type: object
      required:
        - status
        - error
      title: ErrorResponse
      description: Error response model.
      examples:
        - error:
            details:
              id: ns_123
              resource: namespace
            message: Namespace not found
            type: NotFoundError
          status: 404
          success: false
    DocumentRef:
      properties:
        collection_id:
          type: string
          minLength: 1
          title: Collection Id
          description: Collection the document lives in.
        document_id:
          type: string
          minLength: 1
          title: Document Id
          description: The document's ID.
      type: object
      required:
        - collection_id
        - document_id
      title: DocumentRef
      description: A reference to one document in one collection.
    ClusterRunSource:
      properties:
        cluster_id:
          type: string
          title: Cluster Id
          description: The cluster that ran.
        run_id:
          type: string
          title: Run Id
          description: >-
            The run to promote, exactly (GET
            /v1/clusters/{cluster_id}/executions lists them). A run's own
            artifact is read; no other run is substituted.
      type: object
      required:
        - cluster_id
        - run_id
      title: ClusterRunSource
      description: A completed cluster run whose clusters become the taxonomy's nodes.
    SkippedDocumentRef:
      properties:
        collection_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Collection Id
        document_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Document Id
        reason:
          type: string
          title: Reason
      type: object
      required:
        - reason
      title: SkippedDocumentRef
      description: A document reference that could not contribute to the node anchor.
    PromotedNode:
      properties:
        node_document_id:
          type: string
          title: Node Document Id
        node_label:
          type: string
          title: Node Label
        cluster_id:
          type: string
          title: Cluster Id
        member_count:
          anyOf:
            - type: integer
            - type: 'null'
          title: Member Count
      type: object
      required:
        - node_document_id
        - node_label
        - cluster_id
      title: PromotedNode
      description: One taxonomy node created from a cluster run.
    ErrorDetail:
      properties:
        message:
          type: string
          title: Message
          description: Human-readable error message
        type:
          type: string
          title: Type
          description: Stable error type identifier (machine-readable)
        code:
          anyOf:
            - type: string
            - type: 'null'
          title: Code
          description: >-
            Fine-grained error code for programmatic handling (e.g.,
            namespace_name_taken, feature_extractor_not_found). Present only
            when consumers may need to branch on a specific error condition.
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
          description: >-
            Optional structured details to help debugging (validation errors,
            IDs, etc.)
      type: object
      required:
        - message
        - type
      title: ErrorDetail
      description: Error detail model.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Mixpeek API key, sent as `Authorization: Bearer mxp_sk_...`. Create one
        in Studio under Settings → API Keys, or with an admin key via `POST
        /v1/organizations/users/{user_email}/api-keys`. A missing, malformed,
        unknown, revoked, inactive or expired key returns 401; a key without the
        permission, scope or plan an operation needs returns 403.
    NamespaceHeader:
      type: apiKey
      in: header
      name: X-Namespace
      description: >-
        Namespace id (`ns_...`), not the namespace name. This scopes the request
        rather than authenticating it, and it is required on every operation
        marked `x-mixpeek-namespace-scoped`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.