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

# Create template

> Creates a template with helm sources. Templates define the Kubernetes resources that products deploy.



## OpenAPI

````yaml /openapi.json post /v1/templates
openapi: 3.1.0
info:
  title: CNAP API
  version: 1.0.0
  description: >-
    Public API for managing CNAP workspaces, clusters, templates, products, and
    deployments.


    Authenticate with a Personal Access Token via the `Authorization: Bearer
    cnap_pat_...` header.


    Workspace-scoped endpoints require the `X-Workspace-Id` header.
servers:
  - url: https://api.cnap.tech
    description: Production
security: []
paths:
  /v1/templates:
    post:
      tags:
        - Templates
      summary: Create template
      description: >-
        Creates a template with helm sources. Templates define the Kubernetes
        resources that products deploy.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 100
                  example: PostgreSQL HA
                sources:
                  type: array
                  items:
                    type: object
                    properties:
                      chart:
                        type: object
                        properties:
                          repo_url:
                            type: string
                            minLength: 1
                            maxLength: 2048
                          chart:
                            type: string
                            minLength: 1
                            maxLength: 100
                          target_revision:
                            type: string
                            minLength: 1
                            maxLength: 100
                          path:
                            type: string
                            minLength: 1
                            maxLength: 500
                        required:
                          - repo_url
                          - target_revision
                      values:
                        type: object
                        additionalProperties: {}
                      metadata:
                        type: object
                        properties:
                          artifact_hub_helm_package:
                            type: object
                            additionalProperties: {}
                          image:
                            type: object
                            properties:
                              url:
                                type: string
                                minLength: 1
                                maxLength: 2048
                              tag:
                                type: string
                                minLength: 1
                                maxLength: 200
                              github:
                                type: object
                                properties:
                                  workflow_run_id:
                                    type: string
                                    minLength: 1
                                    maxLength: 100
                                  repository:
                                    type: object
                                    properties:
                                      id:
                                        type: number
                                      html_url:
                                        type: string
                                        minLength: 1
                                        maxLength: 2048
                                      name:
                                        type: string
                                        minLength: 1
                                        maxLength: 100
                                      full_name:
                                        type: string
                                        minLength: 1
                                        maxLength: 200
                                      owner:
                                        type: object
                                        properties:
                                          login:
                                            type: string
                                            minLength: 1
                                            maxLength: 100
                                          id:
                                            type: number
                                          type:
                                            type: string
                                            minLength: 1
                                            maxLength: 50
                                          avatar_url:
                                            type: string
                                            minLength: 1
                                            maxLength: 2048
                                          html_url:
                                            type: string
                                            minLength: 1
                                            maxLength: 2048
                                        required:
                                          - login
                                          - id
                                          - type
                                          - avatar_url
                                          - html_url
                                    required:
                                      - id
                                      - html_url
                                      - name
                                      - full_name
                                      - owner
                            required:
                              - url
                              - tag
                          auto_deploy:
                            type: boolean
                    required:
                      - chart
                  minItems: 1
                registry_proxy_mode:
                  type: string
                  enum:
                    - auto
                    - always
                    - never
              required:
                - name
                - sources
      responses:
        '201':
          description: Template created
          content:
            application/json:
              schema:
                type: object
                properties:
                  template_id:
                    type: string
                required:
                  - template_id
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Missing or invalid workspace
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - BearerAuth: []
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: not_found
            message:
              type: string
              example: Resource not found
            param:
              type: string
              description: The request field that caused the error
              example: name
            suggestion:
              type: string
              example: Run `cnap clusters list` to see available clusters
            details: {}
          required:
            - code
            - message
      required:
        - error
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Personal Access Token (cnap_pat_...) or OAuth2 JWT. Create tokens at
        https://cnap.tech/account/tokens

````