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

# Save Version

> Save a new immutable version. Never touches what's published — see
POST .../publish. Any field left unset carries over from the current
latest_version_id, matching the old content-bearing PATCH's ergonomics.



## OpenAPI

````yaml /api/openapi.json post /v1/templates/{template_id}/versions
openapi: 3.1.0
info:
  title: MeshAPI
  description: One key, all AI models.
  version: 0.1.0
servers:
  - url: https://api.meshapi.ai
security:
  - BearerAuth: []
paths:
  /v1/templates/{template_id}/versions:
    post:
      tags:
        - Templates
      summary: Save Version
      description: |-
        Save a new immutable version. Never touches what's published — see
        POST .../publish. Any field left unset carries over from the current
        latest_version_id, matching the old content-bearing PATCH's ergonomics.
      operationId: save_version
      parameters:
        - name: template_id
          in: path
          required: true
          schema:
            type: string
            title: Template Id
        - in: header
          name: X-Mesh-Version
          required: false
          schema:
            type: string
            enum:
              - 2026-08
              - 2026-09
            default: 2026-08
          example: 2026-09
          description: >-
            Dated version of the API contract to pin this request to. Omit it
            and the request is served under `2026-08` — the oldest supported
            version, so an existing integration is never moved by a release. A
            malformed or unsupported value is rejected with `400
            invalid_api_version` rather than falling back silently. The version
            actually served is echoed as `X-Mesh-Version` on every response,
            including errors.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SaveVersionRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TemplateVersionSummary'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    SaveVersionRequest:
      properties:
        system:
          anyOf:
            - type: string
            - type: 'null'
          title: System
        messages:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          title: Messages
        model:
          anyOf:
            - type: string
            - type: 'null'
          title: Model
        params:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Params
        variables:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Variables
      type: object
      title: SaveVersionRequest
      description: >-
        A new immutable snapshot of a template's behavioral content. A field

        left unset carries over from `latest_version_id` — changing just
        `system`

        doesn't require resending `messages`.
    TemplateVersionSummary:
      properties:
        id:
          type: string
          title: Id
        template_id:
          type: string
          title: Template Id
        version_number:
          type: integer
          title: Version Number
        system:
          anyOf:
            - type: string
            - type: 'null'
          title: System
        messages:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          title: Messages
        model:
          anyOf:
            - type: string
            - type: 'null'
          title: Model
        params:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Params
        variables:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Variables
        reverted_from_version_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Reverted From Version Id
        created_by:
          anyOf:
            - type: string
            - type: 'null'
          title: Created By
        created_at:
          type: string
          title: Created At
        is_published:
          type: boolean
          title: Is Published
        published_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Published At
      type: object
      required:
        - id
        - template_id
        - version_number
        - system
        - messages
        - model
        - params
        - variables
        - reverted_from_version_id
        - created_by
        - created_at
        - is_published
        - published_at
      title: TemplateVersionSummary
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Enter your MeshAPI key (`rsk_...`) or, for the admin-keys endpoints, a
        dashboard session token — sent as `Authorization: Bearer <token>`.

````