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

# Query records

> Returns records matching a MongoDB-style filter, with sorting,
pagination, and field projection. Operators executing code or
cross-referencing data (`$where`, `$function`, `$expr`, `$lookup`,
`$merge`, `$accumulator`, `$out`) are rejected.
Rate limit: 100 requests/min per user.




## OpenAPI

````yaml /api-reference/ai-collection/swagger.yml get /v1/collections/{collection_id}/data
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/{collection_id}/data:
    parameters:
      - $ref: '#/components/parameters/CollectionId'
    get:
      tags:
        - Records
      summary: Query records
      description: |
        Returns records matching a MongoDB-style filter, with sorting,
        pagination, and field projection. Operators executing code or
        cross-referencing data (`$where`, `$function`, `$expr`, `$lookup`,
        `$merge`, `$accumulator`, `$out`) are rejected.
        Rate limit: 100 requests/min per user.
      operationId: queryRecords
      parameters:
        - name: filter
          in: query
          required: false
          description: JSON-encoded MongoDB-style filter.
          schema:
            type: string
          example: '{"status":"active","deal_value":{"$gte":50000}}'
        - name: sort
          in: query
          required: false
          description: JSON-encoded sort specification.
          schema:
            type: string
          example: '{"created_at":-1}'
        - $ref: '#/components/parameters/Limit'
        - $ref: '#/components/parameters/Page'
        - name: fields
          in: query
          required: false
          description: JSON-encoded field projection.
          schema:
            type: string
          example: '{"name":1,"email":1}'
      responses:
        '200':
          description: Matching records.
          content:
            application/json:
              schema:
                type: object
                properties:
                  count:
                    type: integer
                    description: Number of records in this page.
                  records:
                    type: array
                    items:
                      $ref: '#/components/schemas/Record'
        '400':
          $ref: '#/components/responses/BadRequest'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  parameters:
    CollectionId:
      name: collection_id
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Collection identifier returned at creation.
    Limit:
      name: limit
      in: query
      required: false
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 20
      description: Page size (max 100).
    Page:
      name: page
      in: query
      required: false
      schema:
        type: integer
        minimum: 1
        default: 1
      description: Page number.
  schemas:
    Record:
      type: object
      description: A stored record, including system fields.
      properties:
        _id:
          type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      additionalProperties: true
    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'
    NotFound:
      description: Collection or record not found, or the caller has no access to it.
      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.

````