> ## 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.

# Add a taxonomy node derived from a document selection

> Add a node to an existing **flat** taxonomy from a document selection.

The node is an ordinary document in the taxonomy's node (source) collection:
its anchor vector is the **centroid of the referenced documents' stored
vectors** and its `label` is `node_label`. Future documents enriched through
this taxonomy are labeled with the nearest node's `label`.

Only stored vectors are read — no re-embedding or GPU work. Documents that
can't contribute (missing, no matching vector) are skipped and reported in
`documents_skipped`; the call fails only when NO document contributes.

Hierarchical taxonomies are not supported here (their nodes are whole
collections) — the error points you to the flat-taxonomy path.



## OpenAPI

````yaml post /v1/taxonomies/{taxonomy_identifier}/nodes/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/{taxonomy_identifier}/nodes/from-documents:
    post:
      tags:
        - Taxonomies
      summary: Add a taxonomy node derived from a document selection
      description: >-
        Add a node to an existing **flat** taxonomy from a document selection.


        The node is an ordinary document in the taxonomy's node (source)
        collection:

        its anchor vector is the **centroid of the referenced documents' stored

        vectors** and its `label` is `node_label`. Future documents enriched
        through

        this taxonomy are labeled with the nearest node's `label`.


        Only stored vectors are read — no re-embedding or GPU work. Documents
        that

        can't contribute (missing, no matching vector) are skipped and reported
        in

        `documents_skipped`; the call fails only when NO document contributes.


        Hierarchical taxonomies are not supported here (their nodes are whole

        collections) — the error points you to the flat-taxonomy path.
      operationId: >-
        create_taxonomy_node_from_documents_v1_taxonomies__taxonomy_identifier__nodes_from_documents_post
      parameters:
        - name: taxonomy_identifier
          in: path
          required: true
          schema:
            type: string
            description: Taxonomy ID or name
            title: Taxonomy Identifier
          description: Taxonomy ID or name
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateNodeFromDocumentsRequest'
        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:
    CreateNodeFromDocumentsRequest:
      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.
      type: object
      required:
        - node_label
        - documents
      title: CreateNodeFromDocumentsRequest
      description: >-
        Create a taxonomy node whose classification anchor derives from
        documents.


        Mixpeek taxonomy nodes are documents in the taxonomy's source (node)

        collection: at enrichment time, an incoming document's embedding queries

        that collection through the taxonomy's retriever and the best-matching

        node's fields (canonically `label`) are copied onto it.


        This endpoint computes the CENTROID of the referenced documents' stored

        vectors and inserts it as a new node document — so future documents
        whose

        embeddings land near the referenced selection are classified under

        `node_label`. No re-embedding or GPU work happens; only stored vectors
        are

        read.
    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.
    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.