> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prisme.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Bulk-insert records (large imports)

> Batch-inserts up to 5,000 records in a single call, built for large CSV
imports (the client streams the file and posts batches). A batch is a
single database flush and is all-or-nothing: if one record violates a
column type or constraint the whole batch is rejected with `422` and no
per-row error list, so validate and coerce types client-side before
posting. Provide `upsert_key` (a column with a unique constraint) for an
idempotent re-import that updates instead of duplicating.
Rate limit: 120 requests/min per user.




## OpenAPI

````yaml /api-reference/ai-collection/swagger.yml post /v1/collections/{collection_id}/data/bulk
openapi: 3.0.3
info:
  version: 1.0.0
  title: Collections API
  description: |
    Public REST API for the Prisme.ai Collections workspace: named collections
    of structured records with typed schemas, MongoDB-style querying,
    aggregations, and an MCP (JSON-RPC 2.0) endpoint for AI agents.

    Records are isolated per owner (user or agent); a collection can be shared
    with additional agents through its `agent_ids` list. Every write emits an
    audit event.
  contact:
    name: Prisme.ai
    url: https://prisme.ai
servers:
  - url: https://{host}/v2/workspaces/slug:ai-collection-v3/webhooks
    description: Prisme.ai workspace webhooks
    variables:
      host:
        default: api.studio.prisme.ai
        description: API host (override for self-hosted or sandbox)
security:
  - BearerAuth: []
  - OrgApiKeyAuth: []
tags:
  - name: Collections
    description: Create, list, read, update, and delete collections (metadata and schema).
  - name: Records
    description: Insert, query, read, update, upsert, and delete records in a collection.
  - name: Analytics
    description: Count, distinct values, and aggregations (sum, avg, count with grouping).
  - name: Schema
    description: >-
      Evolve a collection after creation (add columns, apply indexes and unique
      constraints).
  - name: AI
    description: >-
      LLM-assisted helpers (schema suggestion, plain-language question
      answering).
  - name: Sharing
    description: >-
      Grant, list, update, and revoke access bindings on a collection (user,
      group, org).
  - name: API Keys
    description: Mint, list, rotate, and revoke org API keys scoped to a collection.
  - name: MCP
    description: >-
      JSON-RPC 2.0 endpoint exposing the collection tools to AI agents and MCP
      clients.
paths:
  /v1/collections/{collection_id}/data/bulk:
    parameters:
      - $ref: '#/components/parameters/CollectionId'
    post:
      tags:
        - Records
      summary: Bulk-insert records (large imports)
      description: |
        Batch-inserts up to 5,000 records in a single call, built for large CSV
        imports (the client streams the file and posts batches). A batch is a
        single database flush and is all-or-nothing: if one record violates a
        column type or constraint the whole batch is rejected with `422` and no
        per-row error list, so validate and coerce types client-side before
        posting. Provide `upsert_key` (a column with a unique constraint) for an
        idempotent re-import that updates instead of duplicating.
        Rate limit: 120 requests/min per user.
      operationId: bulkInsertRecords
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - records
              properties:
                records:
                  type: array
                  maxItems: 5000
                  items:
                    $ref: '#/components/schemas/RecordInput'
                upsert_key:
                  type: string
                  description: Unique column used as the conflict key (idempotent upsert).
                  example: sku
      responses:
        '201':
          description: Batch inserted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  inserted:
                    type: integer
                  mode:
                    type: string
                    enum:
                      - append
                      - upsert
                  collection_id:
                    type: string
        '400':
          description: Validation error (empty batch, or more than 5,000 records).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: >-
            Batch rejected (all-or-nothing) due to a type or constraint
            violation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  parameters:
    CollectionId:
      name: collection_id
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Collection identifier returned at creation.
  schemas:
    RecordInput:
      type: object
      description: |
        Record fields matching the collection schema. Unknown fields are
        accepted (flexible schema); system fields are ignored.
      additionalProperties: true
      example:
        product_name: Laptop Pro 16
        price: 2199.9
        stock: 42
        active: true
    Error:
      type: object
      properties:
        error:
          type: string
          example: InvalidArguments
        message:
          type: string
  responses:
    RateLimited:
      description: Rate limit exceeded.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'User session JWT. Send as `Authorization: Bearer <token>`.'
    OrgApiKeyAuth:
      type: apiKey
      in: header
      name: x-prismeai-api-key
      description: Organization-scoped API key.

````