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

# Batch Update Documents

> Batch update multiple documents by explicit IDs or filters.

Supports TWO modes:
1. Explicit IDs mode: Provide 'updates' array with document_id + update_data for each document
   - Each document can have DIFFERENT update_data
   - Returns detailed per-document results

2. Filter mode: Provide 'filters' + 'update_data' to update all matching documents
   - All documents receive the SAME update_data
   - Returns total count only

Key Features:
- Update any document field except vectors (metadata, internal_metadata, source_blobs, etc.)
- Maximum 1000 documents per batch in explicit mode
- Per-document success/failure reporting in explicit mode
- Validates documents exist in the specified collection

Examples:
    Explicit IDs mode:
    ```json
    {
        "updates": [
            {"document_id": "doc_123", "update_data": {"metadata": {"status": "processed"}}},
            {"document_id": "doc_456", "update_data": {"metadata": {"status": "archived"}}}
        ]
    }
    ```

    Filter mode (logical AND/OR/NOT shape — NOT MVS-native must/key):
    ```json
    {
        "filters": {"AND": [{"field": "metadata.status", "operator": "eq", "value": "pending"}]},
        "update_data": {"metadata": {"status": "processed"}}
    }
    ```



## OpenAPI

````yaml post /v1/collections/{collection_identifier}/documents/batch
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_identifier}/documents/batch:
    post:
      tags:
        - Collection Documents
      summary: Batch Update Documents
      description: >-
        Batch update multiple documents by explicit IDs or filters.


        Supports TWO modes:

        1. Explicit IDs mode: Provide 'updates' array with document_id +
        update_data for each document
           - Each document can have DIFFERENT update_data
           - Returns detailed per-document results

        2. Filter mode: Provide 'filters' + 'update_data' to update all matching
        documents
           - All documents receive the SAME update_data
           - Returns total count only

        Key Features:

        - Update any document field except vectors (metadata, internal_metadata,
        source_blobs, etc.)

        - Maximum 1000 documents per batch in explicit mode

        - Per-document success/failure reporting in explicit mode

        - Validates documents exist in the specified collection


        Examples:
            Explicit IDs mode:
            ```json
            {
                "updates": [
                    {"document_id": "doc_123", "update_data": {"metadata": {"status": "processed"}}},
                    {"document_id": "doc_456", "update_data": {"metadata": {"status": "archived"}}}
                ]
            }
            ```

            Filter mode (logical AND/OR/NOT shape — NOT MVS-native must/key):
            ```json
            {
                "filters": {"AND": [{"field": "metadata.status", "operator": "eq", "value": "pending"}]},
                "update_data": {"metadata": {"status": "processed"}}
            }
            ```
      operationId: >-
        batch_update_documents_v1_collections__collection_identifier__documents_batch_post
      parameters:
        - name: collection_identifier
          in: path
          required: true
          schema:
            type: string
            description: The ID of the collection to update documents in.
            title: Collection Identifier
          description: The ID of the collection to update documents in.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BatchUpdateDocumentsRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BatchUpdateDocumentsResponse'
        '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:
    BatchUpdateDocumentsRequest:
      properties:
        updates:
          anyOf:
            - items:
                $ref: '#/components/schemas/BatchDocumentUpdate'
              type: array
              maxItems: 1000
              minItems: 1
            - type: 'null'
          title: Updates
          description: >-
            OPTIONAL. List of document updates with explicit document IDs. Each
            entry specifies document_id and update_data. Use this mode when you
            know exact document IDs and want per-document control. Mutually
            exclusive with filters + update_data mode. Maximum 1000 documents
            per batch request.
          examples:
            - - document_id: doc_123
                update_data:
                  metadata:
                    status: processed
              - document_id: doc_456
                update_data:
                  metadata:
                    status: archived
        filters:
          anyOf:
            - $ref: '#/components/schemas/LogicalOperator-Input'
            - type: 'null'
          description: >-
            OPTIONAL. Filter conditions to match documents for update. Must be
            used with 'update_data' field. Mutually exclusive with 'updates'
            array. If provided, applies same update_data to all matching
            documents.
        update_data:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Update Data
          description: >-
            OPTIONAL. Update data to apply when using filters mode. Must be used
            with 'filters' field. All matched documents receive the same
            updates. Can update any document field except vectors.
      type: object
      title: BatchUpdateDocumentsRequest
      description: >-
        Request model for batch updating multiple documents by explicit IDs or
        filters.


        Supports TWO modes:

        1. Explicit IDs mode: Provide 'updates' array with document_id +
        update_data for each

        2. Filter mode: Provide 'filters' + 'update_data' to update all matching
        documents


        Key difference from BulkUpdateDocumentsRequest:

        - Batch (this): Can apply DIFFERENT updates to SPECIFIC documents by ID

        - Bulk: Applies SAME update to ALL documents matching filters


        Use Cases:
            - Update 5 specific documents with different metadata values
            - Update documents by IDs with per-document update control
            - Combine with filters for targeted batch updates

        Requirements:
            - EITHER 'updates' (explicit mode) OR 'filters' + 'update_data' (filter mode)
            - NOT BOTH modes simultaneously
      examples:
        - description: 'Explicit IDs mode: Update 3 documents with different values'
          updates:
            - document_id: doc_frame_001
              update_data:
                metadata:
                  quality_score: 0.95
                  reviewed: true
            - document_id: doc_frame_002
              update_data:
                metadata:
                  flagged: true
                  quality_score: 0.87
            - document_id: doc_frame_003
              update_data:
                metadata:
                  discarded: true
                  quality_score: 0.72
        - description: 'Filter mode: Update all pending documents'
          filters:
            AND:
              - field: metadata.status
                operator: eq
                value: pending
          update_data:
            metadata:
              status: processed
    BatchUpdateDocumentsResponse:
      properties:
        updated_count:
          type: integer
          title: Updated Count
          description: Total number of documents successfully updated
        failed_count:
          type: integer
          title: Failed Count
          description: Total number of documents that failed to update
          default: 0
        results:
          items:
            $ref: '#/components/schemas/BatchDocumentUpdateResult'
          type: array
          title: Results
          description: >-
            Detailed per-document results. Each entry shows document_id, success
            status, and error message (if failed). Empty list when using filter
            mode (only counts returned).
        message:
          type: string
          title: Message
          description: Summary message of the operation
          default: Batch update completed
      type: object
      required:
        - updated_count
      title: BatchUpdateDocumentsResponse
      description: >-
        Response model for batch document update operation.


        Provides detailed per-document results showing success/failure for each
        update.
      examples:
        - failed_count: 0
          message: Successfully updated 3 document(s)
          results:
            - document_id: doc_123
              success: true
            - document_id: doc_456
              success: true
            - document_id: doc_789
              success: true
          updated_count: 3
    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
    BatchDocumentUpdate:
      properties:
        document_id:
          type: string
          title: Document Id
          description: >-
            REQUIRED. Document ID to update. Must exist in the collection.
            Format: 'doc_' prefix + alphanumeric characters.
          examples:
            - doc_abc123
            - doc_frame_001
        update_data:
          additionalProperties: true
          type: object
          title: Update Data
          description: >-
            REQUIRED. Fields to update for this specific document. Can update
            any document field except vectors. Supported fields: metadata,
            source_blobs, document_blobs, lineage fields (root_object_id,
            source_type, etc.), and any custom fields. Each document in the
            batch can have different update_data.
          examples:
            - metadata:
                score: 0.95
                status: processed
            - metadata:
                reviewed: true
                reviewer: John
      type: object
      required:
        - document_id
        - update_data
      title: BatchDocumentUpdate
      description: |-
        Single document update specification for batch operations.

        Represents one document's update within a batch request.
      examples:
        - document_id: doc_abc123
          update_data:
            metadata:
              status: processed
    LogicalOperator-Input:
      properties:
        AND:
          anyOf:
            - items:
                anyOf:
                  - $ref: '#/components/schemas/LogicalOperator-Input'
                  - $ref: '#/components/schemas/FilterCondition'
              type: array
            - type: 'null'
          title: And
          description: Logical AND operation - all conditions must be true
          example:
            - field: name
              operator: eq
              value: John
            - field: age
              operator: gte
              value: 30
        OR:
          anyOf:
            - items:
                anyOf:
                  - $ref: '#/components/schemas/LogicalOperator-Input'
                  - $ref: '#/components/schemas/FilterCondition'
              type: array
            - type: 'null'
          title: Or
          description: Logical OR operation - at least one condition must be true
          example:
            - field: status
              operator: eq
              value: active
            - field: role
              operator: eq
              value: admin
        NOT:
          anyOf:
            - items:
                anyOf:
                  - $ref: '#/components/schemas/LogicalOperator-Input'
                  - $ref: '#/components/schemas/FilterCondition'
              type: array
            - type: 'null'
          title: Not
          description: Logical NOT operation - all conditions must be false
          example:
            - field: department
              operator: eq
              value: HR
            - field: location
              operator: eq
              value: remote
        case_sensitive:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Case Sensitive
          description: Whether to perform case-sensitive matching
          default: false
          example: true
      additionalProperties: true
      type: object
      title: LogicalOperator
      description: >-
        Represents a logical operation (AND, OR, NOT) on filter conditions.


        Allows nesting with a defined depth limit.


        Also supports shorthand syntax where field names can be passed directly

        as key-value pairs for equality filtering (e.g., {"metadata.title":
        "value"}).
    BatchDocumentUpdateResult:
      properties:
        document_id:
          type: string
          title: Document Id
          description: Document ID that was updated
        success:
          type: boolean
          title: Success
          description: Whether the update succeeded
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
          description: Error message if update failed
      type: object
      required:
        - document_id
        - success
      title: BatchDocumentUpdateResult
      description: Result of a single document update in a batch operation.
    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
    FilterCondition:
      properties:
        field:
          type: string
          title: Field
          description: Field name to filter on
        operator:
          $ref: '#/components/schemas/FilterOperator'
          description: Comparison operator
          default: eq
        value:
          anyOf:
            - $ref: '#/components/schemas/DynamicValue'
            - {}
          title: Value
          description: Value to compare against
      type: object
      required:
        - field
        - value
      title: FilterCondition
      description: |-
        Represents a single filter condition.

        Attributes:
            field: The field to filter on
            operator: The comparison operator
            value: The value to compare against
    FilterOperator:
      type: string
      enum:
        - eq
        - ne
        - gt
        - lt
        - gte
        - lte
        - in
        - nin
        - contains
        - starts_with
        - ends_with
        - regex
        - exists
        - is_null
        - text
        - phrase
      title: FilterOperator
      description: Supported filter operators across database implementations.
    DynamicValue:
      properties:
        type:
          type: string
          const: dynamic
          title: Type
          default: dynamic
        field:
          type: string
          title: Field
          description: >-
            The dot-notation path to the value in the runtime query request,
            e.g., 'inputs.user_id'
          examples:
            - inputs.query_text
            - filters.AND[0].value
      type: object
      required:
        - field
      title: DynamicValue
      description: A value that should be dynamically resolved from the query request.

````