> ## 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 Interactions Bulk

> Record up to 1000 interactions in one call — for backfilling history.

Each interaction is enriched (reward_value, feature_uri/context promotion)
exactly like the single-create path, then written. Reward config is resolved
ONCE per distinct retriever (not per interaction). Dedup and the real-time
session cache are skipped — bulk writes are for historical backfill, not
live in-session adaptation. Set each interaction's ``occurred_at`` to its
true timestamp so temporal decay weights it by real age.



## OpenAPI

````yaml post /v1/retrievers/interactions/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:
  - BearerAuth: []
paths:
  /v1/retrievers/interactions/batch:
    post:
      tags:
        - Retriever Interactions
      summary: Create Interactions Bulk
      description: >-
        Record up to 1000 interactions in one call — for backfilling history.


        Each interaction is enriched (reward_value, feature_uri/context
        promotion)

        exactly like the single-create path, then written. Reward config is
        resolved

        ONCE per distinct retriever (not per interaction). Dedup and the
        real-time

        session cache are skipped — bulk writes are for historical backfill, not

        live in-session adaptation. Set each interaction's ``occurred_at`` to
        its

        true timestamp so temporal decay weights it by real age.
      operationId: create_interactions_bulk_v1_retrievers_interactions_batch_post
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BulkInteractionsRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkInteractionsResponse'
        '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:
    BulkInteractionsRequest:
      properties:
        interactions:
          items:
            $ref: '#/components/schemas/SearchInteraction'
          type: array
          maxItems: 1000
          minItems: 1
          title: Interactions
          description: >-
            Interactions to record (1-1000). For historical backfill, set each
            interaction's `occurred_at` to its true time.
      type: object
      required:
        - interactions
      title: BulkInteractionsRequest
      description: >-
        Record many interactions in one call — for backfilling historical logs.


        The intended use is migrating an existing click/purchase history into

        Mixpeek: send the interactions in chunks (≤ 1000 per call) with each
        one's

        ``occurred_at`` set to its true timestamp, so learned-fusion temporal
        decay

        weights them correctly. Backfilled events bypass the real-time session
        cache.
    BulkInteractionsResponse:
      properties:
        created:
          type: integer
          title: Created
          description: Number of interactions accepted for write.
        failed:
          type: integer
          title: Failed
          description: Number that could not be processed (see errors).
          default: 0
        errors:
          items:
            type: string
          type: array
          title: Errors
          description: Per-interaction error messages (indexed), if any failed.
        results:
          items:
            $ref: '#/components/schemas/BulkInteractionItemResult'
          type: array
          title: Results
          description: Per-item results with assigned interaction IDs.
      type: object
      required:
        - created
      title: BulkInteractionsResponse
      description: Result of a bulk interaction write.
    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
    SearchInteraction:
      properties:
        feature_id:
          type: string
          title: Feature Id
          description: >-
            ID of the document/feature that was interacted with. REQUIRED. This
            is the SAME value as the `document_id` returned in retriever execute
            results — you can pass it as either `feature_id` or `document_id`
            (the latter is accepted as an alias). Used to track which specific
            items users engage with.
          examples:
            - doc_abc123
            - prod_xyz789
            - feat_12345
        interaction_type:
          items:
            $ref: '#/components/schemas/InteractionType'
          type: array
          minItems: 1
          title: Interaction Type
          description: >-
            List of interaction types that occurred. REQUIRED. Multiple types
            can be recorded simultaneously (e.g., VIEW + CLICK + LONG_VIEW for a
            result the user engaged with). Use the InteractionType enum values.
          examples:
            - - click
            - - positive_feedback
              - click
              - long_view
            - - negative_feedback
            - - purchase
              - click
        position:
          type: integer
          minimum: 0
          title: Position
          description: >-
            Position in search results where interaction occurred (0-indexed).
            REQUIRED. Critical for Learning to Rank - helps identify position
            bias. E.g., position=0 means first result, position=9 means 10th
            result. Higher engagement at lower positions suggests higher
            quality.
          examples:
            - 0
            - 1
            - 5
            - 15
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: >-
            Additional context about the interaction. NOT REQUIRED. Can include
            device, duration, viewport info, etc. Use this to enrich interaction
            data with application-specific context.
          examples:
            - device: mobile
              duration_ms: 5000
              page: search_results
              viewport_position: 0.75
            - interaction_reason: not_relevant
              page_number: 2
              results_count: 50
              search_latency_ms: 150
        user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: User Id
          description: >-
            Customer's authenticated user identifier. NOT REQUIRED. Persists
            across sessions for long-term tracking. Enables personalization and
            user-specific metrics. Use your application's user ID format.
          examples:
            - user_abc123
            - customer_456
            - usr_xyz789
        session_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Session Id
          description: >-
            Temporary identifier for a single search session. NOT REQUIRED.
            Typically 30min-1hr duration. Tracks anonymous and authenticated
            users within a session. Use to group related queries and understand
            search journeys. Also used by learned fusion (auto-tune) for
            within-session real-time adaptation: interactions sharing a
            session_id allow the bandit to update feature weights mid-session
            without waiting for batch aggregation.
          examples:
            - sess_abc123
            - session_xyz789_1234567890
        execution_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Execution Id
          description: >-
            ID of the retriever execution that generated these results. NOT
            REQUIRED but HIGHLY RECOMMENDED for training and optimization. Links
            the interaction back to the exact search query, pipeline
            configuration, and stage execution that produced the results the
            user saw. Essential for: fine-tuning embeddings, training rerankers,
            query understanding, and tracing which pipeline configs produce
            better user engagement. Retrieve from the retriever execution
            response and pass to interactions.
          examples:
            - exec_abc123xyz
            - exec_550e8400e29b41d4
        retriever_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Retriever Id
          description: >-
            ID of the retriever that was executed. NOT REQUIRED but RECOMMENDED
            for multi-retriever analytics. Enables comparing performance across
            different retriever configurations. If execution_id is provided,
            retriever_id can be inferred from the execution record.
          examples:
            - ret_abc123
            - ret_product_search_v2
        query_snapshot:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Query Snapshot
          description: >-
            Snapshot of the query input that generated these results. HIGHLY
            RECOMMENDED for training optimization. Storing the query directly
            enables 10-100x faster training data extraction by avoiding
            expensive joins to execution records. Use the same format as
            retriever query input (e.g., {'text': '...', 'filters': {...}}).
            Essential for: embedding fine-tuning (query-document pairs), query
            expansion learning, and analyzing which query patterns lead to
            better engagement. NOT REQUIRED but strongly recommended for
            production use cases involving model training.
          examples:
            - text: wireless headphones
            - filters:
                price:
                  lte: 1000
              text: laptop
            - context: summer collection
              text: red shoes
        document_score:
          anyOf:
            - type: number
            - type: 'null'
          title: Document Score
          description: >-
            Initial retrieval score of this document when shown to the user.
            HIGHLY RECOMMENDED for Learning to Rank (LTR). This is a critical
            feature for reranker training - helps the model learn how to adjust
            initial scores based on user engagement. Should match the score from
            the retriever execution results. NOT REQUIRED but strongly
            recommended for LTR and reranker training.
          examples:
            - 0.95
            - 0.87
            - 0.62
        result_set_size:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Result Set Size
          description: >-
            Total number of results shown to the user in this search. NOT
            REQUIRED but useful for context. Helps understand interaction
            patterns - clicking position 5 of 10 results is different from
            position 5 of 100 results. Useful for position bias correction and
            CTR analysis.
          examples:
            - 10
            - 20
            - 50
            - 100
        feature_uri:
          anyOf:
            - type: string
            - type: 'null'
          title: Feature Uri
          description: >-
            Feature URI that produced the clicked result (e.g.
            'mixpeek://text_extractor@v1/embedding'). Required for learned
            fusion — interactions without this field do not contribute to weight
            learning.
          examples:
            - mixpeek://text_extractor@v1/multilingual_e5_large_instruct_v1
            - mixpeek://clip_extractor@v1/image_embedding
        occurred_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Occurred At
          description: >-
            When the interaction actually happened (ISO 8601). OPTIONAL. Omit
            for live interactions — the server stamps 'now'. Supply this ONLY to
            backfill historical interactions (e.g. migrating existing click
            logs) so learned-fusion temporal decay weights them by their TRUE
            age. A naive datetime is interpreted as UTC; a future value is
            clamped to now. Backfilled events bypass the real-time session
            cache.
          examples:
            - '2026-01-15T10:30:00Z'
            - '2025-12-01T00:00:00+00:00'
      type: object
      required:
        - feature_id
        - interaction_type
        - position
      title: SearchInteraction
      description: >-
        Records a user interaction with a search result.


        This model captures user behavior signals that can be used to improve
        retrieval quality.

        Each interaction represents a user action (click, view, feedback) on a
        specific document

        returned by a retriever.


        Use Cases:
            - Track which search results users actually click on
            - Collect explicit feedback (thumbs up/down) on result quality
            - Monitor engagement metrics (time spent viewing, sharing)
            - Identify problematic queries (zero results, immediate refinements)
            - Power Learning to Rank models with real user behavior

        Requirements:
            - feature_id: REQUIRED - The document/feature that was interacted with
            - interaction_type: REQUIRED - Type(s) of interaction that occurred
            - position: REQUIRED - Where in results list the interaction occurred (for LTR)
            - query_snapshot: HIGHLY RECOMMENDED - Query input for training optimization
            - document_score: HIGHLY RECOMMENDED - Initial score for LTR training
            - result_set_size: OPTIONAL - Total results shown (for context)
            - metadata: OPTIONAL - Additional context about the interaction
            - user_id: OPTIONAL - For personalization and user-specific metrics
            - session_id: OPTIONAL - For tracking multi-query sessions
            - execution_id: OPTIONAL - Link to full execution context
            - retriever_id: OPTIONAL - For multi-retriever analytics

        Related Concepts:
            - Retrievers: Interactions measure retriever performance
            - Evaluations: Interactions provide real-world complement to offline evaluation
            - Learning to Rank: Interactions train ranking models
      examples:
        - description: >-
            Minimal click interaction (query_snapshot and document_score
            optional)
          execution_id: exec_minimal_123
          feature_id: doc_abc123
          interaction_type:
            - click
          position: 2
          session_id: sess_minimal
        - description: Simple click interaction with recommended fields for training
          document_score: 0.85
          feature_id: doc_abc123
          interaction_type:
            - click
          position: 2
          query_snapshot:
            text: machine learning tutorials
        - description: Engaged view with metadata and execution tracking
          document_score: 0.92
          execution_id: exec_abc123xyz
          feature_id: prod_xyz789
          interaction_type:
            - view
            - click
            - long_view
          metadata:
            device: mobile
            duration_ms: 12000
            viewport_position: 0.85
          position: 0
          query_snapshot:
            filters:
              price:
                lte: 100
            text: wireless headphones
          result_set_size: 20
          retriever_id: ret_product_search
          session_id: sess_abc
          user_id: user_123
        - description: Negative feedback
          document_score: 0.78
          feature_id: doc_bad456
          interaction_type:
            - negative_feedback
            - return_to_results
          metadata:
            interaction_reason: not_relevant
          position: 5
          query_snapshot:
            text: python tutorial
          result_set_size: 50
          session_id: sess_xyz
        - description: >-
            Purchase conversion with full tracking (high-value signal for
            training)
          document_score: 0.88
          execution_id: exec_purchase_789
          feature_id: prod_789
          interaction_type:
            - purchase
          metadata:
            conversion_time_seconds: 120
            purchase_amount: 199.99
          position: 1
          query_snapshot:
            text: noise cancelling headphones
          result_set_size: 50
          retriever_id: ret_product_search
          session_id: sess_purchase_001
          user_id: user_456
    BulkInteractionItemResult:
      properties:
        index:
          type: integer
          title: Index
          description: 0-based index of this item in the request.
        interaction_id:
          type: string
          title: Interaction Id
          description: Assigned interaction ID.
        status:
          type: string
          title: Status
          description: 'Item status: ''created'' or ''failed''.'
          default: created
      type: object
      required:
        - index
        - interaction_id
      title: BulkInteractionItemResult
      description: Per-item result from a bulk interaction write.
    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
    InteractionType:
      type: string
      enum:
        - impression
        - view
        - click
        - dwell
        - positive_feedback
        - negative_feedback
        - purchase
        - add_to_cart
        - wishlist
        - long_view
        - share
        - bookmark
        - query_refinement
        - zero_results
        - filter_toggle
        - skip
        - return_to_results
        - play
        - download
        - save
        - add_to_project
        - rating
      title: InteractionType
      description: >-
        Types of user interactions with search results.


        These interaction types are used to track user behavior and improve
        retrieval quality

        through Learning to Rank (LTR), collaborative filtering, and embedding
        fine-tuning.


        Values:
            IMPRESSION: Result was rendered on screen (passive signal, no user action)
            VIEW: User viewed a search result
            CLICK: User clicked on a search result
            DWELL: User lingered on a result (weaker than long_view, stronger than view)
            POSITIVE_FEEDBACK: User explicitly marked result as relevant/helpful
            NEGATIVE_FEEDBACK: User explicitly marked result as not relevant
            PURCHASE: User purchased the item (high-value conversion signal)
            ADD_TO_CART: User added item to cart (mid-funnel signal)
            WISHLIST: User saved item for later (engagement signal)
            LONG_VIEW: User spent significant time viewing (dwell time)
            SHARE: User shared the result (strong engagement signal)
            BOOKMARK: User bookmarked the result
            QUERY_REFINEMENT: User modified their search query
            ZERO_RESULTS: Query yielded no results (helps identify gaps)
            FILTER_TOGGLE: User modified filters (helps understand intent)
            SKIP: User skipped over result to click something lower (negative signal)
            RETURN_TO_RESULTS: User quickly returned to results (negative signal)

        Usage in Retrieval Optimization:
            - LTR (Learning to Rank): Train models to predict click-through rates
            - Collaborative Filtering: Find similar users/items based on interactions
            - Embedding Fine-tuning: Adjust embeddings based on what users actually click
            - Query Understanding: Analyze refinements and zero-result queries
            - Result Quality: Identify poorly-performing results via skip/return patterns
  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`.

````