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

# Query records

> The typed record query: a filter, sorts, aggregates and a group over every match, text search, and an ids-only mode. The path names the type; a body naming another is refused. Without sorts, aggregates or group it pages by record id: a write between pages never moves another record across a boundary, and total_count is on the first page. A sorted or summarizing query pages by offset and is live: a write between pages can.



## OpenAPI

````yaml ontology/openapi.json POST /v1/object-model/records/{type_id}/query
openapi: 3.1.0
info:
  description: >-
    An organization's records, facts and figures.


    **Beta.** Every operation is `x-stability: beta`: paths, fields and codes
    may still change before v1 is declared stable. From then on, changes within
    v1 are additive only — new operations, optional fields, response fields,
    enum values and error codes — so a client must ignore fields and values it
    does not know. Anything else needs a new version or a six-month deprecation
    announced with Deprecation and Sunset headers.


    ## Idempotency


    Every write needs an `Idempotency-Key` header: 1–255 printable ASCII
    characters, one key per logical write, sent again unchanged on every retry
    of that write. Reads, the read-only POSTs (`/record-search`,
    `/records/{type_id}/query`, `/facts/query`, `/figures/query`,
    `/figures/explain`) and dry runs (`dry_run: true`) need none and are never
    recorded. A write without one is refused with 400
    `idempotency_key_required`.


    A key belongs to the organization and the person the API key acts for, so
    two of one person's API keys retrying one write agree; another person's
    request under the same key is their own. The API records the request — the
    method, the route, the path parameters, the body as parsed (JSON key order
    and spacing do not matter) and any `If-Match` — and its answer:


    - **The same key and the same request, finished**: the recorded answer again
    — status, body, `Object-Model-Version` and `X-Request-Id` — with
    `Idempotent-Replayed: true`. Nothing runs again, and an `If-Match` the
    original carried is not checked again (the original's own success moved the
    version it named).

    - **The same key and the same request, still running**: 409
    `request_in_progress` with `Retry-After`.

    - **The same key and a different request**: 409 `idempotency_key_reused`.
    Use a new key for a new request.


    A replay is authorized like any request first: the API key must still be
    valid and carry the route's scope, and the rate limit counts it.


    **Retention.** A finished write answers its replays for 24 hours; after that
    the key is free again and a request under it runs. A request still running
    holds its key for as long as the API waits for it plus 30 seconds. Each
    write says, under **Re-sent under the same Idempotency-Key**, what a request
    sent again after that gets — past the 24 hours, or after a 504 ("past the
    replay window"). Most writes still recognize their key then, and are not
    made twice.


    **What is recorded.** Every answer the request got, refusals included: a 422
    for an action that stopped part way replays with what it committed, so a
    retry never silently writes more. A 403 for a missing permission, a 5xx, a
    503 and a 504 are not recorded, because none says what was committed: a
    retry with the same key runs again, and the write's own key keeps it from
    being made twice. After a 504 the request may still be running, so a retry
    within its hold hears `request_in_progress`. If the record cannot be written
    or read, the write is not run: 503 `idempotency_unavailable` with
    `Retry-After`.


    **A lost response.**


    ```http

    POST /v1/object-model/records/company

    Idempotency-Key: create-acme-2026-11-12


    {"values": {"name": "Acme"}}

    ```


    The connection drops before the answer arrives. The client sends the same
    request with the same key:


    ```http

    HTTP/1.1 200 OK

    Idempotent-Replayed: true

    X-Request-Id: 7f3a…   (the original request's)


    {"written_id": "6650…", "disposition": "created", "records": […]}

    ```


    **A concurrent duplicate.** A second copy arrives while the first is still
    running:


    ```http

    HTTP/1.1 409 Conflict

    Retry-After: 2


    {"status": "failed", "code": "request_in_progress", "error": "a request with
    this Idempotency-Key is still running; retry after it finishes to get its
    answer"}

    ```


    Retried after it finishes, it gets the first copy's answer with
    `Idempotent-Replayed: true`.


    **The generic endpoint** (`POST /v1/object-model/{object_model_id}/request`,
    the older endpoint these routes replace) takes `Idempotency-Key` optionally:
    without one a request runs every time it is sent; with one it is recorded
    and replayed as above. The model create (`POST /v1/object-model`) needs
    none: an organization has one model, and a second create is refused.
  title: VectorShift Object Model API
  version: '1'
servers:
  - url: https://api.vectorshift.ai
security: []
paths:
  /v1/object-model/records/{type_id}/query:
    post:
      tags:
        - records
      summary: >-
        The typed record query: a filter, sorts, aggregates and a group over
        every match, text search, and an ids-only mode. The path names the type;
        a body naming another is refused. Without sorts, aggregates or group it
        pages by record id: a write between pages never moves another record
        across a boundary, and total_count is on the first page. A sorted or
        summarizing query pages by offset and is live: a write between pages
        can.
      description: >-
        The typed record query: a filter, sorts, aggregates and a group over
        every match, text search, and an ids-only mode. The path names the type;
        a body naming another is refused. Without sorts, aggregates or group it
        pages by record id: a write between pages never moves another record
        across a boundary, and total_count is on the first page. A sorted or
        summarizing query pages by offset and is live: a write between pages
        can.
      operationId: post_records_by_type_id_query
      parameters:
        - in: path
          name: type_id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            examples:
              deals_in_diligence_over_five_million:
                summary: >-
                  Deals in diligence with a size above 5 million (illustrative
                  ids: real ones come from GET /schema).
                value:
                  aggregates:
                    - field: size
                      op: sum
                  filter:
                    conditions:
                      - field: stage
                        op: eq
                        value: diligence
                      - field: size
                        op: gt
                        value: 5000000
                    op: all
                  limit: 20
                  select: records
                  sorts:
                    - descending: true
                      field: size
            schema:
              $ref: '#/components/schemas/object_model_RecordQuery'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/object_model_RecordsResult'
          description: Answered.
          headers:
            Object-Model-Version:
              description: The model version the request was served under.
              schema:
                type: integer
            X-Request-Id:
              description: >-
                The request's id: quote it when you contact support. Absent on a
                request refused before it ran, such as one with a bad key or a
                malformed body.
              schema:
                type: string
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Failure'
          description: >-
            Malformed JSON, an unknown field, an unknown query parameter, or one
            naming a field the route fixes.
          headers:
            X-Request-Id:
              description: >-
                The request's id: quote it when you contact support. Absent on a
                request refused before it ran, such as one with a bad key or a
                malformed body.
              schema:
                type: string
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Failure'
          description: Missing, invalid or expired API key.
          headers:
            X-Request-Id:
              description: >-
                The request's id: quote it when you contact support. Absent on a
                request refused before it ran, such as one with a bad key or a
                malformed body.
              schema:
                type: string
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Failure'
          description: >-
            The key lacks the scope (`scope_required`), the person lacks the
            permission (`forbidden`), or a feature the request needs is not
            enabled for the organization (`not_enabled`).
          headers:
            X-Request-Id:
              description: >-
                The request's id: quote it when you contact support. Absent on a
                request refused before it ran, such as one with a bad key or a
                malformed body.
              schema:
                type: string
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Failure'
          description: >-
            No such record, or one this caller cannot see — the same answer on
            purpose.
          headers:
            X-Request-Id:
              description: >-
                The request's id: quote it when you contact support. Absent on a
                request refused before it ran, such as one with a bad key or a
                malformed body.
              schema:
                type: string
        '413':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Failure'
          description: The body is over 8 MiB.
          headers:
            X-Request-Id:
              description: >-
                The request's id: quote it when you contact support. Absent on a
                request refused before it ran, such as one with a bad key or a
                malformed body.
              schema:
                type: string
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Failure'
          description: >-
            Understood and declined: a filter, cursor or parameter the read
            can't take.
          headers:
            X-Request-Id:
              description: >-
                The request's id: quote it when you contact support. Absent on a
                request refused before it ran, such as one with a bad key or a
                malformed body.
              schema:
                type: string
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Failure'
          description: Rate limited. Retry-After says when to try again.
          headers:
            Retry-After:
              description: Seconds to wait before trying again.
              schema:
                type: integer
            X-Request-Id:
              description: >-
                The request's id: quote it when you contact support. Absent on a
                request refused before it ran, such as one with a bad key or a
                malformed body.
              schema:
                type: string
        '504':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Failure'
          description: No answer in time. Retry the request.
          headers:
            X-Request-Id:
              description: >-
                The request's id: quote it when you contact support. Absent on a
                request refused before it ran, such as one with a bad key or a
                malformed body.
              schema:
                type: string
      security:
        - apiKey:
            - object_model:records:read
components:
  schemas:
    object_model_RecordQuery:
      additionalProperties: false
      description: >-
        A query names at most 64 distinct fields in all, across `filter`,
        `sorts`, `aggregates` (`field` and `fallback_field`), `group` and
        `search.fields`; a field named twice counts once. Past that it is
        refused (422 `too_many_fields`, `path` the first field past the bound).
      properties:
        aggregates:
          description: >-
            Summaries over every match, not only this page, answered in
            `summary.aggregates` in the order asked.
          items:
            $ref: '#/components/schemas/object_model_RecordAggregate'
          type: array
        cursor:
          description: >-
            The previous page's `next_cursor`. Leave it out to start at the
            first record.
          type: string
        filter:
          allOf:
            - $ref: '#/components/schemas/object_model_RecordFilter'
          description: >-
            Which records: a record filter (see its schema). Leave it out for
            every record you can read.
        group:
          allOf:
            - $ref: '#/components/schemas/object_model_RecordGroupBy'
          description: 'Group the matches by a field''s value: answered in `summary.groups`.'
        limit:
          description: >-
            Records per page: 1 to 200. Default 50. On a query, `select: ids`
            takes up to 5,000, and a text search up to 50.
          type: integer
        search:
          allOf:
            - $ref: '#/components/schemas/object_model_RecordTextSearch'
          description: 'A text search: only records whose named `fields` match `text`.'
        select:
          description: >-
            `records` (the default) answers the matching records; `ids` answers
            only their ids, up to 5,000 a page.
          enum:
            - records
            - ids
          type: string
        sorts:
          description: >-
            The order, by field, first sort first. Without sorts, records come
            in id order.
          items:
            $ref: '#/components/schemas/object_model_RecordSort'
          type: array
        type_id:
          description: 'Named by the path: leave it out, or send the same id.'
          type: string
      type: object
      x-bounds:
        max_fields: 64
    object_model_RecordsResult:
      additionalProperties: false
      properties:
        deleted_id:
          description: 'A delete''s answer: the id removed, once it is gone.'
          type: string
        disposition:
          description: >-
            A create's answer: `created`, or `existing` when `unique_by` matched
            a record, which is answered unchanged.
          type: string
        next_cursor:
          description: Send it as `cursor` for the next page. Empty on the last page.
          type: string
        records:
          description: >-
            The records: a page of a listing or query, or the one record a get
            or write answers.
          items:
            $ref: '#/components/schemas/object_model_Record'
          type: array
        summary:
          allOf:
            - $ref: '#/components/schemas/google_protobuf_Struct'
          description: >-
            With `aggregates` or `group`: `{"aggregates": [{"field", "op",
            "value", "error"}], "groups": [{"value", "count", "aggregates":
            […]}], "groups_truncated"}`. `aggregates` are in the order asked,
            over every match, not only this page. A count is 0 when nothing
            matches; a `sum`, `average`, `min` or `max` is `null` when no match
            has a value. `groups` has one entry per value of the group field, in
            ascending order (records with no value form a group whose `value` is
            `null`), at most 200, with `groups_truncated` set past that. Sent
            again on every page.
        total_count:
          description: >-
            How many records the query matched in all, as a string. An unsorted
            listing or query sends it on its first page only; a sorted or
            summarizing query sends it on every page. Absent on a get or a
            write.
          format: int64
          type:
            - string
            - integer
        written_id:
          description: >-
            A create's or update's answer: the record written. Also in
            `records`, unless the write itself took the record out of your
            sight.
          type: string
      type: object
    Failure:
      properties:
        code:
          type: string
        details:
          additionalProperties:
            type: string
          type: object
        error:
          type: string
        path:
          type: string
        request_id:
          type: string
        result:
          description: >-
            The operation's own result, when a declined operation has one: what
            it did before it stopped. An action that stopped part way
            (`partial`) carries its `instance_id`, the records it created, its
            `fact_ids` and `field_outcomes` here — the steps that committed.
            Same shape as the route's 200 body.
          type: object
        status:
          const: failed
          type: string
      required:
        - status
        - code
        - error
      type: object
    object_model_RecordAggregate:
      additionalProperties: false
      properties:
        fallback_field:
          description: >-
            A number field to use on a record whose `field` is empty. Each
            `field` and `op` pair at most once, and at most 16 aggregates.
          type: string
        field:
          description: The field to summarize.
          type: string
        op:
          description: >-
            `count_empty` and `count_filled` count records by whether the field
            has a value; `sum`, `average`, `min` and `max` take a number field.
          enum:
            - count_empty
            - count_filled
            - sum
            - average
            - min
            - max
          type: string
      type: object
    object_model_RecordFilter:
      description: >-
        One record predicate, discriminated by `op`; every member its op does
        not take must be absent. The record query, each search source and a
        figure read's record selector take this same shape, and each is checked
        against the model and what the caller may read. Every leaf but is_empty
        is false on an empty cell. Text equality is exact; contains, starts_with
        and ends_with ignore case. An omitted filter selects every record of the
        type the caller can read; an empty object is refused. Bounds: nesting
        depth 8, 100 conditions, 500 values in `in`, 1000 ids in `id_in`, 1024
        characters per string operand, and the fields it names count toward its
        query's or search source's 64 distinct fields. A refusal answers 422
        with a stable code (`filter_*`, `unknown_field`, `unqueryable_field`,
        `operator_mismatch`, `too_many_fields`) and `path`, a JSON Pointer to
        the member at fault (`/filter/conditions/1/value`).
      discriminator:
        mapping:
          all: '#/components/schemas/object_model_RecordFilter_group'
          any: '#/components/schemas/object_model_RecordFilter_group'
          contains: '#/components/schemas/object_model_RecordFilter_text'
          ends_with: '#/components/schemas/object_model_RecordFilter_text'
          eq: '#/components/schemas/object_model_RecordFilter_compare'
          gt: '#/components/schemas/object_model_RecordFilter_compare'
          gte: '#/components/schemas/object_model_RecordFilter_compare'
          has_links: '#/components/schemas/object_model_RecordFilter_has_links'
          id_in: '#/components/schemas/object_model_RecordFilter_id_in'
          in: '#/components/schemas/object_model_RecordFilter_in'
          is_empty: '#/components/schemas/object_model_RecordFilter_empty'
          is_not_empty: '#/components/schemas/object_model_RecordFilter_empty'
          lt: '#/components/schemas/object_model_RecordFilter_compare'
          lte: '#/components/schemas/object_model_RecordFilter_compare'
          ne: '#/components/schemas/object_model_RecordFilter_compare'
          not: '#/components/schemas/object_model_RecordFilter_not'
          not_contains: '#/components/schemas/object_model_RecordFilter_text'
          starts_with: '#/components/schemas/object_model_RecordFilter_text'
        propertyName: op
      oneOf:
        - $ref: '#/components/schemas/object_model_RecordFilter_compare'
        - $ref: '#/components/schemas/object_model_RecordFilter_text'
        - $ref: '#/components/schemas/object_model_RecordFilter_in'
        - $ref: '#/components/schemas/object_model_RecordFilter_id_in'
        - $ref: '#/components/schemas/object_model_RecordFilter_empty'
        - $ref: '#/components/schemas/object_model_RecordFilter_has_links'
        - $ref: '#/components/schemas/object_model_RecordFilter_group'
        - $ref: '#/components/schemas/object_model_RecordFilter_not'
      x-bounds:
        max_conditions: 100
        max_depth: 8
        max_ids: 1000
        max_string_length: 1024
        max_values: 500
    object_model_RecordGroupBy:
      additionalProperties: false
      properties:
        field:
          description: >-
            A text or yes/no field: the `summary` then has a group per value,
            each with its count and the same `aggregates`. Not with `select:
            ids`.
          type: string
      type: object
    object_model_RecordTextSearch:
      additionalProperties: false
      properties:
        fields:
          description: 'Text or list fields to search: 1 to 64.'
          items:
            type: string
          type: array
        text:
          description: 'What to search for: at most 256 characters and 8 words.'
          type: string
      type: object
    object_model_RecordSort:
      additionalProperties: false
      properties:
        descending:
          description: Largest, latest or last first.
          type: boolean
        field:
          description: The field to sort by.
          type: string
      type: object
    object_model_Record:
      additionalProperties: false
      properties:
        created_at:
          $ref: '#/components/schemas/google_protobuf_Timestamp'
        created_by:
          type: string
        id:
          type: string
        label:
          type: string
        links:
          additionalProperties:
            $ref: '#/components/schemas/object_model_RecordLinks'
          type: object
        locked:
          type: boolean
        revision:
          format: int64
          type:
            - string
            - integer
        type_id:
          type: string
        updated_at:
          $ref: '#/components/schemas/google_protobuf_Timestamp'
        updated_by:
          type: string
        values:
          allOf:
            - $ref: '#/components/schemas/google_protobuf_Struct'
          description: >-
            The record's fields, keyed by `name`, in the JSON they are written
            in (see a create's `values`), except that a timestamp reads as an
            RFC 3339 time, a `personal_name` adds `full_name`, a `location` adds
            `display` (its parts joined in one line), and an `image` reads as an
            object describing the file.
      type: object
    google_protobuf_Struct:
      additionalProperties: true
      type: object
    object_model_RecordFilter_group:
      additionalProperties: false
      description: All (AND) or any (OR) of one or more conditions.
      properties:
        conditions:
          items:
            $ref: '#/components/schemas/object_model_RecordFilter'
          minItems: 1
          type: array
        op:
          enum:
            - all
            - any
          type: string
      required:
        - op
        - conditions
      type: object
    object_model_RecordFilter_text:
      additionalProperties: false
      description: >-
        Match text, ignoring case, in a text or list field. not_contains is
        false on an empty cell; on a list it means no item contains the value.
      properties:
        field:
          description: >-
            An attribute id of the type, or a system field: `_label`, `_id`,
            `_created_by` (text), `_created_at`, `_updated_at` (dates). Never a
            display name. A field the caller cannot read is refused exactly as
            an unknown one (`unknown_field`).
          type: string
        op:
          enum:
            - contains
            - not_contains
            - starts_with
            - ends_with
          type: string
        value:
          maxLength: 1024
          type: string
      required:
        - op
        - field
        - value
      type: object
    object_model_RecordFilter_compare:
      additionalProperties: false
      description: >-
        Compare a field with a value. gt/gte/lt/lte do not apply to boolean or
        list fields. ne is false on an empty cell; on a list field it means no
        item equals the value.
      properties:
        field:
          description: >-
            An attribute id of the type, or a system field: `_label`, `_id`,
            `_created_by` (text), `_created_at`, `_updated_at` (dates). Never a
            display name. A field the caller cannot read is refused exactly as
            an unknown one (`unknown_field`).
          type: string
        op:
          enum:
            - eq
            - ne
            - gt
            - gte
            - lt
            - lte
          type: string
        value:
          description: >-
            Typed by the field: a string for text and list fields, a JSON number
            for numbers, true or false for booleans, an RFC3339 string for
            dates. Never null (use `is_empty`), and a string never stands in for
            a number or a boolean.
          maxLength: 1024
          type:
            - string
            - number
            - boolean
      required:
        - op
        - field
        - value
      type: object
    object_model_RecordFilter_has_links:
      additionalProperties: false
      description: >-
        The record links to at least one record by a relation declared from its
        type. Not in a search source's filter.
      properties:
        op:
          enum:
            - has_links
          type: string
        relationship:
          type: string
      required:
        - op
        - relationship
      type: object
    object_model_RecordFilter_id_in:
      additionalProperties: false
      description: >-
        The record is one of these, of the selector's type. An empty list
        matches no record.
      properties:
        ids:
          items:
            pattern: ^[0-9a-f]{24}$
            type: string
          maxItems: 1000
          type: array
        op:
          enum:
            - id_in
          type: string
      required:
        - op
        - ids
      type: object
    object_model_RecordFilter_in:
      additionalProperties: false
      description: >-
        The field equals one of the values (on a list field, any item does). An
        empty list matches no record. Not for date fields.
      properties:
        field:
          description: >-
            An attribute id of the type, or a system field: `_label`, `_id`,
            `_created_by` (text), `_created_at`, `_updated_at` (dates). Never a
            display name. A field the caller cannot read is refused exactly as
            an unknown one (`unknown_field`).
          type: string
        op:
          enum:
            - in
          type: string
        values:
          items:
            description: >-
              Typed by the field: a string for text and list fields, a JSON
              number for numbers, true or false for booleans, an RFC3339 string
              for dates. Never null (use `is_empty`), and a string never stands
              in for a number or a boolean.
            maxLength: 1024
            type:
              - string
              - number
              - boolean
          maxItems: 500
          type: array
      required:
        - op
        - field
        - values
      type: object
    object_model_RecordFilter_empty:
      additionalProperties: false
      description: The field holds no value (an absent cell, an empty list), or holds one.
      properties:
        field:
          description: >-
            An attribute id of the type, or a system field: `_label`, `_id`,
            `_created_by` (text), `_created_at`, `_updated_at` (dates). Never a
            display name. A field the caller cannot read is refused exactly as
            an unknown one (`unknown_field`).
          type: string
        op:
          enum:
            - is_empty
            - is_not_empty
          type: string
      required:
        - op
        - field
      type: object
    object_model_RecordFilter_not:
      additionalProperties: false
      description: >-
        The one condition does not hold. Unlike ne and not_contains, not around
        a condition is true on an empty cell.
      properties:
        conditions:
          items:
            $ref: '#/components/schemas/object_model_RecordFilter'
          maxItems: 1
          minItems: 1
          type: array
        op:
          enum:
            - not
          type: string
      required:
        - op
        - conditions
      type: object
    google_protobuf_Timestamp:
      format: date-time
      type: string
    object_model_RecordLinks:
      additionalProperties: false
      properties:
        ids:
          description: The records to link, by id.
          items:
            type: string
          type: array
      type: object
  securitySchemes:
    apiKey:
      description: >-
        An API key issued with object_model scopes: Authorization: Bearer sk_….
        The scopes: object_model:records:read, object_model:records:write,
        object_model:facts:read, object_model:facts:write,
        object_model:model:read, object_model:model:configure,
        object_model:actions:run, object_model:changes:read. An operation's
        `security` lists the scopes it needs; several entries mean any one of
        them will do. A person field (`ref(user)`, `ref_list(user)`) holds a
        user id: look people up by email or id with `GET /v1/users`, outside
        this API, with a key that also has `users:read`.
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.