> ## 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 (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 **first node**: a document whose anchor vector is the centroid of the
   referenced documents' stored vectors, labeled `node_label`.

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 (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 **first node**: a document whose anchor vector is the centroid of
        the
           referenced documents' stored vectors, labeled `node_label`.

        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'
      responses:
        '201':
          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: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
          NamespaceHeader: []
components:
  schemas:
    CreateTaxonomyFromDocumentsRequest:
      properties:
        node_label:
          type: string
          minLength: 1
          title: Node Label
          description: >-
            Label for the new node — the value copied onto documents that
            classify under it (canonical `label` field).
        documents:
          items:
            $ref: '#/components/schemas/DocumentRef'
          type: array
          maxItems: 200
          minItems: 1
          title: Documents
          description: >-
            Documents whose stored vectors define the node's anchor (centroid).
            1-200 refs; for large selections send a sample — the centroid
            converges quickly.
        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.
        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:
        - node_label
        - documents
        - taxonomy_name
      title: CreateTaxonomyFromDocumentsRequest
      description: >-
        One-gesture promotion: create a flat taxonomy (node collection +

        vector-search retriever) AND its first node from a document selection.


        The node collection mirrors the referenced documents' collection vector

        index (same vector name / dimensions / feature_uri), so classification
        is

        guaranteed dimension-compatible with the data the selection came from.
    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.
      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
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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.
    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.
    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.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  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 header returns
        403; an invalid or revoked key returns 401.
    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`.

````