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

# Create template revision

> Append an immutable revision and advance the logical template pointer from a reusable `fileId`. Public SDK helpers `replace(file)` and `replaceFromFileId(fileId)` upload through the Files API when needed, then send this JSON body. Generated clients send `{ fileId }` JSON only. The HTTP route still accepts a multipart `file` for CLI/internal use; that path is not generated into the public SDKs.



## OpenAPI

````yaml /api-reference/openapi.json put /v1/templates/{id}
openapi: 3.1.0
info:
  title: Eigenpal API
  version: 1.0.0
  description: >-
    Public REST API for inspecting automations, starting and monitoring runs,
    managing files, collecting human reviews, and running evaluations.
  contact:
    name: Eigenpal
    url: https://eigenpal.com
  license:
    name: Apache-2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
servers:
  - url: https://api.eigenpal.com
    description: Production (canonical API hostname)
security:
  - bearerAuth: []
tags:
  - name: Metadata
    description: Authenticate and inspect the current API context.
  - name: Models
    description: >-
      List text, vision, and OCR models configured for the current tenant
      environment. This is a catalog inventory, not a live provider health
      probe.
  - name: Automations
    description: >-
      Inspect runnable workflow and agent automations, their versions, triggers,
      and source sync state.
  - name: Runs
    description: >-
      Start, monitor, retry, review, and debug automation runs, including
      artifacts.
  - name: Reviews
    description: >-
      Record human review verdicts, manage corrected outputs, and monitor review
      health.
  - name: Files
    description: Upload reusable files for later run or dataset use.
  - name: Templates
    description: >-
      Upload, inspect, version, download, and delete tenant-scoped DOCX and XLSX
      templates.
  - name: Email servers
    description: >-
      Create and manage outbound email servers for workflow mail. Secrets are
      encrypted at rest and never returned.
  - name: Evaluation
    description: >-
      Manage datasets, examples, evaluators, experiment batches, evaluator
      scores, and run promotion workflows.
paths:
  /v1/templates/{id}:
    put:
      tags:
        - Templates
      summary: Create template revision
      description: >-
        Append an immutable revision and advance the logical template pointer
        from a reusable `fileId`. Public SDK helpers `replace(file)` and
        `replaceFromFileId(fileId)` upload through the Files API when needed,
        then send this JSON body. Generated clients send `{ fileId }` JSON only.
        The HTTP route still accepts a multipart `file` for CLI/internal use;
        that path is not generated into the public SDKs.
      operationId: templates.replace
      parameters:
        - in: path
          name: id
          schema:
            type: string
            pattern: ^tmpl_[A-Za-z0-9_-]{21}$
            description: Logical template id (tmpl_…).
          required: true
          description: Logical template id (tmpl_…).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TemplateReplaceRequest'
      responses:
        '200':
          description: Updated template
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Template'
        '400':
          description: Validation error. Request shape did not match the spec.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
        '403':
          description: API key lacks required scope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
        '413':
          description: Payload too large. Upload exceeded the per-request size cap.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
        '422':
          description: Validation error. Request shape did not match the spec.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
        '429':
          description: Rate limit exceeded
          headers:
            Retry-After:
              description: Seconds until the next request may succeed
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
components:
  schemas:
    TemplateReplaceRequest:
      type: object
      properties:
        fileId:
          type: string
          pattern: ^file_[A-Za-z0-9_-]{21}$
          description: >-
            Reusable file id produced by the direct file upload flow. It is
            consumed as upload transport, not exposed as template identity.
      required:
        - fileId
    Template:
      type: object
      properties:
        id:
          type: string
          pattern: ^tmpl_[A-Za-z0-9_-]{21}$
          description: Stable logical template id (tmpl_…).
        name:
          type: string
        description:
          anyOf:
            - type: string
            - type: 'null'
        filename:
          type: string
        format:
          type: string
          enum:
            - docx
            - xlsx
        mimeType:
          type: string
        size:
          anyOf:
            - type: integer
              minimum: 0
              maximum: 9007199254740991
            - type: 'null'
        sha256:
          anyOf:
            - type: string
              minLength: 64
              maxLength: 64
            - type: 'null'
        tokens:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              path:
                type: array
                items:
                  type: string
              kind:
                type: string
                enum:
                  - variable
                  - loop
              type:
                type: string
                enum:
                  - string
                  - number
                  - date
                  - boolean
                  - array
                  - object
              required:
                type: boolean
              description:
                type: string
            required:
              - name
            additionalProperties: false
        grammar:
          type: object
          properties:
            syntax:
              type: string
            tokenDiscovery:
              type: boolean
            capabilities:
              type: array
              items:
                type: string
          required:
            - syntax
            - tokenDiscovery
            - capabilities
          additionalProperties: false
        currentRevision:
          anyOf:
            - $ref: '#/components/schemas/TemplateRevision'
            - type: 'null'
        createdAt:
          anyOf:
            - type: string
            - type: string
        updatedAt:
          anyOf:
            - anyOf:
                - type: string
                - type: string
            - type: 'null'
      required:
        - id
        - name
        - filename
        - format
        - mimeType
        - tokens
        - grammar
        - createdAt
      additionalProperties: false
    ApiErrorEnvelope:
      type: object
      properties:
        issues:
          type: array
          items:
            $ref: '#/components/schemas/ApiErrorIssue'
        requestId:
          type: string
          description: Request id echoed via the x-request-id header
        hint:
          description: Suggested fix for known error patterns
          type: string
        docsUrl:
          description: Link to relevant docs
          type: string
        conflictingWorkflowId:
          description: >-
            Present on 409 workflow_name_conflict responses. Id of the workflow
            that already owns the requested name.
          type: string
      required:
        - issues
        - requestId
      additionalProperties: false
    TemplateRevision:
      type: object
      properties:
        id:
          type: string
          pattern: ^tmpr_[A-Za-z0-9_-]{21}$
          description: Immutable template revision id (tmpr_…).
        number:
          type: integer
          exclusiveMinimum: 0
          maximum: 9007199254740991
        sha256:
          type: string
          minLength: 64
          maxLength: 64
        createdAt:
          anyOf:
            - type: string
            - type: string
      required:
        - id
        - number
        - sha256
        - createdAt
      additionalProperties: false
    ApiErrorIssue:
      type: object
      properties:
        field:
          type: string
          description: JSON path of the offending field, or "<root>"
        message:
          type: string
          description: Human-readable error message
        code:
          type: string
          description: >-
            Machine-readable error code (e.g. invalid_value, not_found,
            api_trigger_disabled, manual_trigger_disabled)
        severity:
          type: string
          enum:
            - error
            - warning
          description: Issue severity
      required:
        - field
        - message
        - code
        - severity
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key issued from Settings → API Keys. Pass as `Authorization: Bearer
        <key>`.

````