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

# Create a collection

> Creates a named collection, optionally with a typed schema
(`properties`). Collection names are unique per owner.
Rate limit: 100 requests/min per user.




## OpenAPI

````yaml /api-reference/ai-collection/swagger.yml post /v1/collections
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: MCP
    description: >-
      JSON-RPC 2.0 endpoint exposing the `data_*` tools to AI agents and MCP
      clients.
paths:
  /v1/collections:
    post:
      tags:
        - Collections
      summary: Create a collection
      description: |
        Creates a named collection, optionally with a typed schema
        (`properties`). Collection names are unique per owner.
        Rate limit: 100 requests/min per user.
      operationId: createCollection
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  maxLength: 64
                  pattern: ^[a-zA-Z0-9_-]+$
                  description: Collection name (alphanumeric, `-`, `_`). Unique per owner.
                  example: products
                description:
                  type: string
                  description: Human-readable description, also visible to agents.
                  example: Product catalog, one row per SKU, prices in EUR
                settings:
                  $ref: '#/components/schemas/CollectionSettings'
                properties:
                  $ref: '#/components/schemas/SchemaProperties'
      responses:
        '200':
          description: Collection created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  collection_id:
                    type: string
                    format: uuid
                  name:
                    type: string
                  owner_id:
                    type: string
                  owner_type:
                    type: string
                    enum:
                      - user
                      - agent
                  status:
                    type: string
                    example: ready
                  schema_applied:
                    type: boolean
        '400':
          $ref: '#/components/responses/BadRequest'
        '409':
          description: A collection with this name already exists for this owner.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CollectionSettings:
      type: object
      properties:
        ttl_days:
          type: integer
          minimum: 0
          description: Default record expiration in days (0 = never).
        max_records:
          type: integer
          description: Collection size limit (default 10,000).
    SchemaProperties:
      type: object
      description: 'Column definitions: field name → type descriptor.'
      additionalProperties:
        type: object
        required:
          - type
        properties:
          type:
            type: string
            enum:
              - text
              - integer
              - double
              - boolean
              - date
              - datetime
              - json
              - array
          nullable:
            type: boolean
      example:
        product_name:
          type: text
        price:
          type: double
        stock:
          type: integer
          nullable: true
        active:
          type: boolean
        released_at:
          type: date
        specs:
          type: json
    Error:
      type: object
      properties:
        error:
          type: string
          example: InvalidArguments
        message:
          type: string
  responses:
    BadRequest:
      description: Invalid arguments (bad filter operator, batch too large, name invalid…).
      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.

````