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

# Check a state's stored records against its schema

> A keyset page of the stored records that do NOT fit the state's current effective schema.

``checked`` reports how many records the page read; ``items`` are only the misfits, each with
every reason. Pages like the subjects listing (optionally one ``kind``); ``held`` names the
saves held by a failed pending save that the page skipped.



## OpenAPI

````yaml /openapi.json get /api/states/{name}/records/check
openapi: 3.1.0
info:
  description: >-
    The operator HTTP surface served under /api/*. The platform's core routes.
    Plugin routes are published by each plugin.
  title: tai42-skeleton API
  version: 26.5.1
servers: []
security: []
paths:
  /api/states/{name}/records/check:
    get:
      tags:
        - states
      summary: Check a state's stored records against its schema
      description: >-
        A keyset page of the stored records that do NOT fit the state's current
        effective schema.


        ``checked`` reports how many records the page read; ``items`` are only
        the misfits, each with

        every reason. Pages like the subjects listing (optionally one ``kind``);
        ``held`` names the

        saves held by a failed pending save that the page skipped.
      operationId: get_api_states_name_records_check
      parameters:
        - in: path
          name: name
          required: true
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  data:
                    $ref: '#/components/schemas/RecordCheckPage'
                required:
                  - data
                type: object
          description: Success.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Missing or invalid api key.
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Resource not found.
        '501':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Error.
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: >-
            A dependency this route needs is temporarily unavailable; retry
            shortly.
      security:
        - ApiKeyAuth: []
components:
  schemas:
    RecordCheckPage:
      additionalProperties: false
      description: >-
        One keyset page of a state's records checked against its current
        effective schema.


        ``checked`` is how many records the page read; ``items`` are ONLY the
        records that do not fit

        (each a :class:`~tai42_contract.states.RecordCheckItem`), so a
        fully-fitting page has an empty

        ``items`` and a non-zero ``checked``. ``next_cursor`` is the cursor the
        next page reads from

        (``None`` on the last page), paging like ``list_subjects``/``search``;
        ``held`` names the saves

        held by a failed pending save whose subjects the page did not read over
        their uncommitted

        writes. Beside :class:`PruneResult` and :class:`StateDeclarationSaved`:
        a scan answer that

        names the held saves it skipped.
      properties:
        checked:
          title: Checked
          type: integer
        held:
          items:
            $ref: '#/components/schemas/HeldPendingSave'
          title: Held
          type: array
        items:
          items:
            $ref: '#/components/schemas/RecordCheckItem'
          title: Items
          type: array
        next_cursor:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Next Cursor
      required:
        - checked
      title: RecordCheckPage
      type: object
    Error:
      properties:
        code:
          description: >-
            Stable machine-readable reason a client keys a dedicated error state
            on, present on refusals that opt in (e.g. a 501 not-configured
            refusal). Optional: absent when the error carries only a
            human-readable message.
          type: string
        error:
          type: string
      required:
        - error
      type: object
    HeldPendingSave:
      additionalProperties: false
      description: >-
        One outstanding save whose subjects are held by a failed save.


        ``save_id`` names the held save, ``held_by`` the failed save holding it
        (equal to ``save_id``

        for the failed save itself), and ``subjects`` the subjects it writes.
        Frozen.
      properties:
        held_by:
          title: Held By
          type: string
        save_id:
          title: Save Id
          type: string
        subjects:
          items:
            $ref: '#/components/schemas/StateSubject'
          title: Subjects
          type: array
      required:
        - save_id
        - held_by
      title: HeldPendingSave
      type: object
    RecordCheckItem:
      additionalProperties: false
      description: >-
        One stored record that does not fit its state's current effective
        schema.


        The ``subject`` it belongs to, the ``updated_at`` epoch seconds of its
        last write, and every

        ``reasons`` entry it fails on (ordered by JSON path). Frozen.
      properties:
        reasons:
          items:
            $ref: '#/components/schemas/ValidationReason'
          title: Reasons
          type: array
        subject:
          $ref: '#/components/schemas/StateSubject'
        updated_at:
          title: Updated At
          type: number
      required:
        - subject
        - updated_at
      title: RecordCheckItem
      type: object
    StateSubject:
      additionalProperties: false
      description: >-
        One addressed subject: a scope ``(target_kind, target_name)`` plus
        ``(kind, key)`` within it.


        Equality (and identity across every store method) is all four fields.
        ``key`` is

        stripped and must be 1..512 characters; ``kind`` matches
        :data:`SUBJECT_KIND_RE`.

        Frozen so a validated subject cannot be mutated after it is read back.
      properties:
        key:
          title: Key
          type: string
        kind:
          title: Kind
          type: string
        target_kind:
          enum:
            - agent
            - tool
          title: Target Kind
          type: string
        target_name:
          minLength: 1
          title: Target Name
          type: string
      required:
        - target_kind
        - target_name
        - kind
        - key
      title: StateSubject
      type: object
    ValidationReason:
      additionalProperties: false
      description: >-
        One way a record document does not fit a state's effective schema.


        ``path`` is the JSON path of the offending node (``$`` for the document
        root) and

        ``message`` the schema validator's reason. A document that fits has
        none. Frozen.
      properties:
        message:
          title: Message
          type: string
        path:
          title: Path
          type: string
      required:
        - path
        - message
      title: ValidationReason
      type: object
  securitySchemes:
    ApiKeyAuth:
      in: header
      name: x-api-key
      type: apiKey

````

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