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

# Get a state template

> One state-template document by name.



## OpenAPI

````yaml /openapi.json get /api/state-templates/{name}
openapi: 3.1.0
info:
  description: The operator HTTP surface served under /api/*.
  title: tai42-skeleton API
  version: 14.0.2
servers: []
security: []
paths:
  /api/state-templates/{name}:
    get:
      tags:
        - states
      summary: Get a state template
      description: One state-template document by name.
      operationId: get_api_state_templates_name
      parameters:
        - in: path
          name: name
          required: true
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  data:
                    $ref: '#/components/schemas/StateTemplateDocument'
                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.
      security:
        - ApiKeyAuth: []
components:
  schemas:
    StateTemplateDocument:
      additionalProperties: false
      description: >-
        A state-template document: the reusable schema fragment plus the
        parameters, write

        regimes, attach-time ``declarations`` and ``trace`` switch the platform
        owns, plus

        ``template_jq`` (named jq programs — ``input``-purpose reads and
        ``update``-purpose

        record operations) and ``reconcile`` (how a declarations edit settles
        open records)

        that give the record its meaning. A template is data end to end: the
        states API serves

        an input-purpose result for a subject and applies an update-purpose
        program to a subject

        generically, so a template is usable through the API with no other
        engine.

        ``extra="forbid"`` refuses any key outside these.


        The wire key ``schema`` is the attribute ``schema_`` (alias). The
        ``declarations``,

        ``template_jq`` and ``reconcile`` sections carry their served sub-shapes

        (:class:`StateTemplateDeclarations`, :class:`StateTemplateJq`,

        :class:`StateTemplateReconcile`); the skeleton store does the semantic
        validation (jq

        compilation, regime/record path resolution against the fragment) these
        models do not.
      properties:
        declarations:
          anyOf:
            - $ref: '#/components/schemas/StateTemplateDeclarations'
            - type: 'null'
          default: null
        description:
          default: ''
          title: Description
          type: string
        kind:
          const: state-template
          default: state-template
          title: Kind
          type: string
        name:
          title: Name
          type: string
        parameters:
          additionalProperties: true
          title: Parameters
          type: object
        reconcile:
          anyOf:
            - $ref: '#/components/schemas/StateTemplateReconcile'
            - type: 'null'
          default: null
        regimes:
          items:
            additionalProperties: true
            type: object
          title: Regimes
          type: array
        schema:
          anyOf:
            - $ref: '#/components/schemas/TemplatedText'
            - additionalProperties: true
              type: object
          title: Schema
        template_jq:
          anyOf:
            - additionalProperties:
                $ref: '#/components/schemas/StateTemplateJq'
              type: object
            - type: 'null'
          default: null
          title: Template Jq
        trace:
          additionalProperties: true
          title: Trace
          type: object
      required:
        - name
      title: StateTemplateDocument
      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
    StateTemplateDeclarations:
      additionalProperties: false
      description: >-
        The ``declarations`` section of a state-template document: the JSON
        ``schema`` (wire

        key ``schema``, attribute ``schema_``) of the static values an
        attachment stores, and an

        OPTIONAL ``check`` — a :class:`~tai42_contract.template.TemplatedText`
        carrying a jq

        predicate over those values. Structural validation (the check's jq, the
        schema's shape)

        lives at the store; this model pins the served wire shape.


        The wire key ``schema`` is the attribute ``schema_`` (alias) because a
        ``schema`` field

        would shadow ``BaseModel.schema``.
      properties:
        check:
          anyOf:
            - $ref: '#/components/schemas/TemplatedText'
            - type: 'null'
          default: null
        schema:
          additionalProperties: true
          title: Schema
          type: object
      required:
        - schema
      title: StateTemplateDeclarations
      type: object
    StateTemplateReconcile:
      additionalProperties: false
      description: >-
        The ``reconcile`` section of a state-template document: three jq
        programs the store

        runs to settle a state's OPEN records on a declarations edit —
        ``orphans`` names the items

        a record subtree orphans against the new declarations, ``resolutions``
        names the

        not-done resolutions a close may name, and ``close`` returns the op
        batch that closes one

        orphan. Each is a :class:`~tai42_contract.template.TemplatedText`
        (inline ``content`` or a

        stored ``id``).
      properties:
        close:
          $ref: '#/components/schemas/TemplatedText'
        orphans:
          $ref: '#/components/schemas/TemplatedText'
        resolutions:
          $ref: '#/components/schemas/TemplatedText'
      required:
        - orphans
        - close
        - resolutions
      title: StateTemplateReconcile
      type: object
    TemplatedText:
      additionalProperties: false
      description: >-
        A renderable text: its source plus the parameters its render takes.


        EXACTLY ONE source is set — ``content`` (the text inline) or ``id`` (the
        id of a

        stored resource holding the text); neither and both are refused at
        construction.

        ``kwargs`` are the render parameters for the TEXT and apply either way,
        so moving a

        text from inline to stored (or back) leaves its parameters untouched.
      properties:
        content:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Content
        id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Id
        kwargs:
          additionalProperties: true
          title: Kwargs
          type: object
      title: TemplatedText
      type: object
      x-tai42-templated-text:
        language: jinja
    StateTemplateJq:
      additionalProperties: false
      description: >-
        One named jq program on a state template. ``purpose`` is ``input`` — a
        read over the

        record returning a value — or ``update`` — a program over ``{record,
        input}`` returning a

        template-relative op batch. ``jq`` is the program body as a

        :class:`~tai42_contract.template.TemplatedText` (inline ``content`` or a
        stored ``id``).

        ``params`` names the keys the program takes; ``reads``/``writes`` are
        the

        template-relative record paths an ``update`` program declares and are
        absent on an

        ``input`` program. Structural checks (jq compilation, path resolution)
        live at the store;

        this model pins the served wire shape.
      properties:
        description:
          default: ''
          title: Description
          type: string
        jq:
          $ref: '#/components/schemas/TemplatedText'
        params:
          items:
            type: string
          title: Params
          type: array
        purpose:
          enum:
            - input
            - update
          title: Purpose
          type: string
        reads:
          items:
            items:
              type: string
            type: array
          title: Reads
          type: array
        writes:
          items:
            items:
              type: string
            type: array
          title: Writes
          type: array
      required:
        - purpose
        - jq
      title: StateTemplateJq
      type: object
  securitySchemes:
    ApiKeyAuth:
      in: header
      name: x-api-key
      type: apiKey

````