> ## 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 jq policy condition

> Fail-closed guard: compile — and optionally sample-evaluate — a jq policy
condition WITHOUT persisting it.

A syntactically broken condition raises at enforcement and DENIES the key (a
lock-out), so authoring flows validate here before saving. The condition is
rendered exactly as enforcement renders it, compiled with ``get_compiled_jq``, and —
when a ``sample_context`` is supplied — evaluated against a ``JqAuthContext``-shaped
sample. This ONLY compiles/evaluates; it never writes any store. Returns ``{"ok":
true, "result": <bool|null>}`` (``result`` is ``null`` when no sample was evaluated).
An AUTHOR error is a loud ``BadRequestError`` (400); a server-side fault (an
unconfigured resource manager, a redis/storage outage rendering a stored
``condition_id``) is NOT an author error and propagates as a loud 500.



## OpenAPI

````yaml /openapi.json post /api/auth/validate-condition
openapi: 3.1.0
info:
  description: The operator HTTP surface served under /api/*.
  title: tai42-skeleton API
  version: 0.1.1
servers: []
security: []
paths:
  /api/auth/validate-condition:
    post:
      tags:
        - access-control
      summary: Validate a jq policy condition
      description: >-
        Fail-closed guard: compile — and optionally sample-evaluate — a jq
        policy

        condition WITHOUT persisting it.


        A syntactically broken condition raises at enforcement and DENIES the
        key (a

        lock-out), so authoring flows validate here before saving. The condition
        is

        rendered exactly as enforcement renders it, compiled with
        ``get_compiled_jq``, and —

        when a ``sample_context`` is supplied — evaluated against a
        ``JqAuthContext``-shaped

        sample. This ONLY compiles/evaluates; it never writes any store. Returns
        ``{"ok":

        true, "result": <bool|null>}`` (``result`` is ``null`` when no sample
        was evaluated).

        An AUTHOR error is a loud ``BadRequestError`` (400); a server-side fault
        (an

        unconfigured resource manager, a redis/storage outage rendering a stored

        ``condition_id``) is NOT an author error and propagates as a loud 500.
      operationId: post_api_auth_validate_condition
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConditionValidation'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  data: {}
                required:
                  - data
                type: object
          description: Success.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Malformed request.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Missing or invalid api key.
      security:
        - ApiKeyAuth: []
components:
  schemas:
    ConditionValidation:
      description: |-
        A fail-closed jq policy-condition check — compile and (with a
        ``sample_context``) sample-evaluate a condition without persisting it.
      properties:
        condition:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Condition
        condition_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Condition Id
        condition_kwargs:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          default: null
          title: Condition Kwargs
        sample_context:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          default: null
          title: Sample Context
      title: ConditionValidation
      type: object
    Error:
      properties:
        error:
          type: string
      required:
        - error
      type: object
  securitySchemes:
    ApiKeyAuth:
      in: header
      name: x-api-key
      type: apiKey

````