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

# Create template version

> Publish a new version of a template with prompt, schema, validation, and notification settings



## OpenAPI

````yaml post /v4/templates/{templateId}/versions
openapi: 3.0.3
info:
  title: Kadoa API
  version: 3.0.0
  contact:
    name: Support
    email: support@kadoa.com
servers:
  - url: https://api.kadoa.com
security: []
paths:
  /v4/templates/{templateId}/versions:
    post:
      tags:
        - Templates
      summary: Publish template version
      description: >-
        Create a new immutable version of a template with prompt, schema, and/or
        data validation
      parameters:
        - name: templateId
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Template ID
      requestBody:
        description: Body
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTemplateVersionBody'
      responses:
        '201':
          description: '201'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TemplateVersionMutationResponse'
        '400':
          description: '400'
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: boolean
                    description: Indicates an error occurred
                  message:
                    type: string
                    description: Error message
                  details:
                    nullable: true
                    description: Additional error details (e.g., validation errors)
                required:
                  - error
                  - message
        '401':
          description: '401'
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: boolean
                    description: Indicates an error occurred
                  message:
                    type: string
                    description: Error message
                  details:
                    nullable: true
                    description: Additional error details (e.g., validation errors)
                required:
                  - error
                  - message
        '404':
          description: '404'
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: boolean
                    description: Indicates an error occurred
                  message:
                    type: string
                    description: Error message
                  details:
                    nullable: true
                    description: Additional error details (e.g., validation errors)
                required:
                  - error
                  - message
        '500':
          description: '500'
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: boolean
                    description: Indicates an error occurred
                  message:
                    type: string
                    description: Error message
                  details:
                    nullable: true
                    description: Additional error details (e.g., validation errors)
                required:
                  - error
                  - message
      security:
        - ApiKeyAuth: []
components:
  schemas:
    CreateTemplateVersionBody:
      type: object
      properties:
        prompt:
          type: string
          description: User prompt to copy into workflow config
        schemaId:
          type: string
          format: uuid
          description: data_schemas ID to reference (mutually exclusive with schemaFields)
        schemaFields:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
                description: Field name
              description:
                type: string
                description: Field description
              fieldType:
                type: string
                description: Field type (SCHEMA, CLASSIFICATION, etc.)
              example:
                nullable: true
                description: >-
                  Example value (string, array, or object for OBJECT/ARRAY
                  dataTypes)
              dataType:
                type: string
                description: Data type (STRING, NUMBER, DATE, LINK, etc.)
              isKey:
                type: boolean
                description: >-
                  Marks this field as part of the record's primary key. Key
                  fields define row identity across runs and enable data linking
                  (records with the same key values are treated as the same
                  record over time, used for dedupe and change detection). Set
                  true ONLY when the field is (1) unique per record on the
                  source, (2) stable across runs (does not change for the same
                  logical record), and (3) reliably present (not
                  nullable/missing). Key fields should be scalar STRING, NUMBER,
                  or LINK fields; avoid structured, semantic, boolean, image,
                  and timestamp/date fields as keys. Good candidates: external
                  IDs, SKUs, canonical URLs, posting IDs. Bad candidates:
                  prices, counts, timestamps, free-text titles/descriptions, or
                  anything that can change between runs. Multiple fields may be
                  marked isKey to form a composite key (all parts must hold the
                  same guarantees). If no field satisfies these guarantees,
                  leave isKey unset on every field — data linking will simply be
                  disabled, which is preferable to a wrong key. Choosing a
                  non-stable or non-unique key causes duplicate rows and missed
                  updates.
              categories:
                type: array
                items:
                  type: object
                  properties:
                    title:
                      type: string
                      description: Short title/label of the category
                    definition:
                      type: string
                      description: Full definition/description of the category
                  required:
                    - title
                    - definition
                description: Predefined categories for CLASSIFICATION fields
            required:
              - name
          description: Schema fields to create a new schema inline
        schemaEntity:
          type: string
          description: Entity name for the inline schema
        schemaValidationRules:
          type: object
          additionalProperties:
            type: object
            additionalProperties:
              nullable: true
          description: Schema validation rules to include in this version
        notifications:
          type: array
          items:
            type: object
            properties:
              eventType:
                type: string
              eventConfiguration:
                type: object
                additionalProperties:
                  nullable: true
              enabled:
                type: boolean
              channelIds:
                type: array
                items:
                  type: string
                  format: uuid
              channels:
                type: array
                items:
                  type: object
                  properties:
                    channelId:
                      type: string
                      format: uuid
                  required:
                    - channelId
            required:
              - eventType
          description: Notification configuration for this version
        frequency:
          type: object
          properties:
            interval:
              type: string
              enum:
                - ONLY_ONCE
                - EVERY_10_MINUTES
                - HALF_HOURLY
                - HOURLY
                - THREE_HOURLY
                - SIX_HOURLY
                - TWELVE_HOURLY
                - EIGHTEEN_HOURLY
                - DAILY
                - TWO_DAY
                - THREE_DAY
                - WEEKLY
                - BIWEEKLY
                - TRIWEEKLY
                - FOUR_WEEKS
                - MONTHLY
                - REAL_TIME
                - CUSTOM
              description: >-
                Update interval enum (HOURLY/DAILY/REAL_TIME/CUSTOM/...). When
                CUSTOM, schedules must be provided.
            schedules:
              type: array
              items:
                type: object
                properties:
                  type:
                    type: string
                    enum:
                      - repeat
                      - cron
                    description: Schedule type
                  interval:
                    type: string
                    description: Repeat token (e.g., '1h', '1d') when type=repeat
                  expressions:
                    type: array
                    items:
                      type: string
                    description: Cron expressions when type=cron
                required:
                  - type
              description: Cron/repeat schedule specs. Required when interval=CUSTOM.
      title: CreateTemplateVersionBody
      description: Request body for publishing a new template version
    TemplateVersionMutationResponse:
      type: object
      properties:
        error:
          type: boolean
          enum:
            - false
          description: Error flag (always false on success)
        success:
          type: boolean
          enum:
            - true
          description: Success flag
        data:
          type: object
          properties:
            id:
              type: string
              format: uuid
              description: Version row ID
            templateId:
              type: string
              format: uuid
              description: Parent template ID
            version:
              type: number
              description: Version number
            name:
              type: string
              description: Custom display name (null = default 'v.N')
              nullable: true
            prompt:
              type: string
              description: User prompt
              nullable: true
            schemaId:
              type: string
              format: uuid
              description: Referenced data_schemas ID
              nullable: true
            schemaFields:
              type: array
              items:
                type: object
                properties:
                  name:
                    type: string
                    description: Field name
                  description:
                    type: string
                    description: Field description
                  fieldType:
                    type: string
                    description: Field type (SCHEMA, CLASSIFICATION, etc.)
                  example:
                    nullable: true
                    description: >-
                      Example value (string, array, or object for OBJECT/ARRAY
                      dataTypes)
                  dataType:
                    type: string
                    description: Data type (STRING, NUMBER, DATE, LINK, etc.)
                  isKey:
                    type: boolean
                    description: >-
                      Marks this field as part of the record's primary key. Key
                      fields define row identity across runs and enable data
                      linking (records with the same key values are treated as
                      the same record over time, used for dedupe and change
                      detection). Set true ONLY when the field is (1) unique per
                      record on the source, (2) stable across runs (does not
                      change for the same logical record), and (3) reliably
                      present (not nullable/missing). Key fields should be
                      scalar STRING, NUMBER, or LINK fields; avoid structured,
                      semantic, boolean, image, and timestamp/date fields as
                      keys. Good candidates: external IDs, SKUs, canonical URLs,
                      posting IDs. Bad candidates: prices, counts, timestamps,
                      free-text titles/descriptions, or anything that can change
                      between runs. Multiple fields may be marked isKey to form
                      a composite key (all parts must hold the same guarantees).
                      If no field satisfies these guarantees, leave isKey unset
                      on every field — data linking will simply be disabled,
                      which is preferable to a wrong key. Choosing a non-stable
                      or non-unique key causes duplicate rows and missed
                      updates.
                  categories:
                    type: array
                    items:
                      type: object
                      properties:
                        title:
                          type: string
                          description: Short title/label of the category
                        definition:
                          type: string
                          description: Full definition/description of the category
                      required:
                        - title
                        - definition
                    description: Predefined categories for CLASSIFICATION fields
                required:
                  - name
              nullable: true
              description: Resolved schema fields from data_schemas
            schemaValidationRules:
              type: object
              additionalProperties:
                type: object
                additionalProperties:
                  nullable: true
              description: Schema validation rules for this version
              nullable: true
            notifications:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: Notification configuration ID
                  eventType:
                    type: string
                    description: Event type (e.g., workflow_finished, error)
                  eventConfiguration:
                    type: object
                    additionalProperties:
                      nullable: true
                    description: Event-specific config
                  enabled:
                    type: boolean
                    description: Whether this notification is enabled
                  channels:
                    type: array
                    items:
                      type: object
                      properties:
                        channelId:
                          type: string
                          format: uuid
                        channelName:
                          type: string
                        channelType:
                          type: string
                      required:
                        - channelId
                        - channelName
                        - channelType
                    description: Linked notification channels
                required:
                  - id
                  - eventType
                  - eventConfiguration
                  - enabled
                  - channels
            frequency:
              type: object
              properties:
                interval:
                  type: string
                  enum:
                    - ONLY_ONCE
                    - EVERY_10_MINUTES
                    - HALF_HOURLY
                    - HOURLY
                    - THREE_HOURLY
                    - SIX_HOURLY
                    - TWELVE_HOURLY
                    - EIGHTEEN_HOURLY
                    - DAILY
                    - TWO_DAY
                    - THREE_DAY
                    - WEEKLY
                    - BIWEEKLY
                    - TRIWEEKLY
                    - FOUR_WEEKS
                    - MONTHLY
                    - REAL_TIME
                    - CUSTOM
                  description: >-
                    Update interval enum (HOURLY/DAILY/REAL_TIME/CUSTOM/...).
                    When CUSTOM, schedules must be provided.
                schedules:
                  type: array
                  items:
                    type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - repeat
                          - cron
                        description: Schedule type
                      interval:
                        type: string
                        description: Repeat token (e.g., '1h', '1d') when type=repeat
                      expressions:
                        type: array
                        items:
                          type: string
                        description: Cron expressions when type=cron
                    required:
                      - type
                  description: Cron/repeat schedule specs. Required when interval=CUSTOM.
              description: Frequency configuration for this version
              nullable: true
            createdAt:
              type: string
              description: Creation timestamp
          required:
            - id
            - templateId
            - version
            - name
            - prompt
            - schemaId
            - frequency
            - createdAt
          description: Template version
      required:
        - error
        - success
        - data
      title: TemplateVersionMutationResponse
      description: Response for template version create/update
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for authentication

````