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

# Validate a candidate record against a state's schema

> Check a candidate document against the state's effective schema without storing it.

The request body IS the document (any JSON). A document that does not fit is answered with a
``200`` body ``{fits: false, reasons: [...]}`` naming every misfit; a non-object body or an
effective schema with a broken ``$ref`` is a ``422``, and an undeclared state a ``404``.



## OpenAPI

````yaml /openapi.json post /api/states/{name}/records/validate
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/validate:
    post:
      tags:
        - states
      summary: Validate a candidate record against a state's schema
      description: >-
        Check a candidate document against the state's effective schema without
        storing it.


        The request body IS the document (any JSON). A document that does not
        fit is answered with a

        ``200`` body ``{fits: false, reasons: [...]}`` naming every misfit; a
        non-object body or an

        effective schema with a broken ``$ref`` is a ``422``, and an undeclared
        state a ``404``.
      operationId: post_api_states_name_records_validate
      parameters:
        - in: path
          name: name
          required: true
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  data:
                    $ref: '#/components/schemas/RecordValidation'
                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.
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Request failed validation.
        '501':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Error.
      security:
        - ApiKeyAuth: []
components:
  schemas:
    RecordValidation:
      additionalProperties: false
      description: >-
        Whether a candidate document fits a state's effective schema, with every
        reason it does not.


        ``fits`` is true exactly when ``reasons`` is empty; ``reasons`` lists
        EVERY way the document

        fails, ordered by JSON path, so a misfit is one answer rather than
        one-failure-at-a-time.
      properties:
        fits:
          title: Fits
          type: boolean
        reasons:
          items:
            $ref: '#/components/schemas/ValidationReason'
          title: Reasons
          type: array
      required:
        - fits
      title: RecordValidation
      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
    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.