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

# Sync Collection Schema

> Sample documents from Qdrant and automatically discover new fields to add to the collection's output_schema.

    This endpoint:
    - Samples N documents from the collection (default: 1000)
    - Discovers all fields present in actual documents
    - Merges discovered fields into the collection's output_schema (additive only)
    - Optionally cascades schema updates to downstream collections
    - Respects debounce window (max once per 5 minutes, unless force=true)

    The sync operation is additive only - it never removes or changes existing field types.

    Use this endpoint to:
    - Manually trigger schema discovery after data ingestion
    - Force an immediate schema sync (bypassing debounce)
    - Update schemas with new fields discovered in documents



## OpenAPI

````yaml post /v1/collections/{collection_id}/sync-schema
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: []
paths:
  /v1/collections/{collection_id}/sync-schema:
    post:
      tags:
        - Collection Schema
      summary: Sync Collection Schema
      description: >-
        Sample documents from Qdrant and automatically discover new fields to
        add to the collection's output_schema.

            This endpoint:
            - Samples N documents from the collection (default: 1000)
            - Discovers all fields present in actual documents
            - Merges discovered fields into the collection's output_schema (additive only)
            - Optionally cascades schema updates to downstream collections
            - Respects debounce window (max once per 5 minutes, unless force=true)

            The sync operation is additive only - it never removes or changes existing field types.

            Use this endpoint to:
            - Manually trigger schema discovery after data ingestion
            - Force an immediate schema sync (bypassing debounce)
            - Update schemas with new fields discovered in documents
      operationId: sync_collection_schema_v1_collections__collection_id__sync_schema_post
      parameters:
        - name: collection_id
          in: path
          required: true
          schema:
            type: string
            description: Collection ID to sync schema for
            title: Collection Id
          description: Collection ID to sync schema for
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SchemaSyncRequest'
              default:
                sample_size: 1000
                force: false
                cascade_to_downstream: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/SchemaSyncResponse'
                  - $ref: '#/components/schemas/SchemaSyncSkippedResponse'
                title: >-
                  Response Sync Collection Schema V1 Collections  Collection Id 
                  Sync Schema Post
        '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'
components:
  schemas:
    SchemaSyncRequest:
      properties:
        sample_size:
          type: integer
          maximum: 10000
          minimum: 1
          title: Sample Size
          description: Number of documents to sample for schema discovery
          default: 1000
        force:
          type: boolean
          title: Force
          description: >-
            Force schema sync even if within debounce window. Default: false
            (respects 5-minute debounce)
          default: false
        cascade_to_downstream:
          type: boolean
          title: Cascade To Downstream
          description: >-
            Automatically update downstream collections that use this collection
            as source. Default: true
          default: true
      type: object
      title: SchemaSyncRequest
      description: |-
        Request to sync a collection's schema by sampling documents.

        Used by:
        - Manual API calls from users
        - Automatic triggers from BatchJobPoller
    SchemaSyncResponse:
      properties:
        success:
          type: boolean
          title: Success
          description: Whether schema sync succeeded
        collection_id:
          type: string
          title: Collection Id
          description: Collection that was synced
        schema_version:
          type: integer
          title: Schema Version
          description: New schema version
        previous_version:
          type: integer
          title: Previous Version
          description: Previous schema version
        fields_added:
          items:
            type: string
          type: array
          title: Fields Added
          description: List of new fields discovered
        fields_total:
          type: integer
          title: Fields Total
          description: Total fields in output_schema
        documents_sampled:
          type: integer
          title: Documents Sampled
          description: Number of documents sampled
        downstream_collections_updated:
          items:
            type: string
          type: array
          title: Downstream Collections Updated
          description: Downstream collections that were updated
        message:
          anyOf:
            - type: string
            - type: 'null'
          title: Message
          description: Additional message or error
      type: object
      required:
        - success
        - collection_id
        - schema_version
        - previous_version
        - fields_total
        - documents_sampled
      title: SchemaSyncResponse
      description: Response from schema sync operation.
    SchemaSyncSkippedResponse:
      properties:
        success:
          type: boolean
          title: Success
          description: Request succeeded
          default: true
        skipped:
          type: boolean
          title: Skipped
          description: Schema sync was skipped
          default: true
        reason:
          type: string
          title: Reason
          description: Why sync was skipped
        collection_id:
          type: string
          title: Collection Id
          description: Collection ID
        schema_version:
          type: integer
          title: Schema Version
          description: Current schema version
        last_sync:
          anyOf:
            - type: string
            - type: 'null'
          title: Last Sync
          description: Last sync timestamp
      type: object
      required:
        - reason
        - collection_id
        - schema_version
      title: SchemaSyncSkippedResponse
      description: Response when schema sync was skipped (debounce or disabled).
    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
    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
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````