> ## Documentation Index
> Fetch the complete documentation index at: https://runpod-b18f5ded-lg-apiv2-new.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a template



## OpenAPI

````yaml post /v2/templates
openapi: 3.0.3
info:
  title: RunPod REST API
  version: 2.0.0
  description: RunPod public REST API — v2
servers:
  - url: /
    description: Current server
security:
  - bearerAuth: []
paths:
  /v2/templates:
    post:
      tags:
        - Templates
      summary: Create a template
      operationId: createTemplate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTemplateRequest'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Template'
        default:
          description: Error
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    CreateTemplateRequest:
      allOf:
        - $ref: '#/components/schemas/ContainerConfig'
        - type: object
          required:
            - name
            - image
            - category
          properties:
            name:
              type: string
              minLength: 1
              example: My PyTorch Template
            mounts:
              $ref: '#/components/schemas/TemplateMounts'
            serverless:
              type: boolean
              default: false
            public:
              type: boolean
              default: false
            category:
              $ref: '#/components/schemas/TemplateCategory'
    Template:
      allOf:
        - $ref: '#/components/schemas/ContainerConfig'
        - type: object
          required:
            - id
            - name
            - image
            - args
            - disk
            - mounts
            - ports
            - env
            - registry
            - serverless
            - public
            - category
          properties:
            id:
              type: string
              example: tpl_abc
            name:
              type: string
              example: My PyTorch Template
            mounts:
              $ref: '#/components/schemas/TemplateMounts'
            serverless:
              type: boolean
              description: >-
                Whether this template is for serverless workers (true) or pods
                (false)
              example: false
            public:
              type: boolean
              description: Whether this template is visible to other RunPod users
              example: false
            category:
              $ref: '#/components/schemas/TemplateCategory'
    ErrorResponse:
      type: object
      properties:
        title:
          type: string
          description: Short human-readable summary
          example: Not Found
        status:
          type: integer
          description: HTTP status code
          example: 404
        detail:
          type: string
          description: Human-readable explanation
          example: pod not found
    ContainerConfig:
      type: object
      description: >
        Reusable container configuration shared across templates, pods, and
        serverless endpoints. Adding a field here automatically propagates to
        all three resources.
      properties:
        image:
          type: string
          description: Docker image reference
          example: runpod/pytorch:2.8.0-py3.11-cuda12.8.1
        args:
          type: string
          description: Arguments passed to the container entrypoint
          example: ''
        disk:
          type: integer
          minimum: 1
          description: Container disk in GB (ephemeral, wiped on restart)
          example: 50
        ports:
          type: array
          description: Exposed ports, formatted as port/protocol
          items:
            type: string
          example:
            - 8888/http
            - 22/tcp
        env:
          type: object
          additionalProperties:
            type: string
          description: Environment variables as key-value pairs
          example:
            JUPYTER_PASSWORD: hunter2
        registry:
          type: string
          nullable: true
          description: Container registry credential ID (for private images)
          example: null
    TemplateMounts:
      type: object
      additionalProperties: false
      description: |
        Storage mounts attached to a template. Templates support only a
        single persistent mount today; any `network` property is rejected
        with 422 by the schema validator.

        PATCH semantics: omitting `mounts` or sending `{}` leaves the
        existing mount unchanged.
      properties:
        persistent:
          $ref: '#/components/schemas/PersistentMount'
    TemplateCategory:
      type: string
      description: |
        Hardware family this template targets.
        - `CPU`    — CPU-only workloads
        - `NVIDIA` — NVIDIA GPU workloads
        - `AMD`    — AMD GPU workloads
      enum:
        - CPU
        - NVIDIA
        - AMD
    PersistentMount:
      type: object
      required:
        - size
        - path
      additionalProperties: false
      description: |
        Host-local persistent storage. Pinned to the pod's host machine — data
        does not survive a host failure. Disallowed on CPU pods. Mutually
        exclusive with NetworkMount. Deprecated: prefer NetworkMount for any
        data you cannot recreate.
      properties:
        size:
          type: integer
          minimum: 10
          description: >-
            Host-local persistent storage in GB. Upstream enforces a 10 GB
            floor.
          example: 20
        path:
          type: string
          description: Mount path inside the container. May be changed via PATCH.
          example: /workspace
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: RunPod API Key

````