# Source: https://docs.runpod.io/sdks/graphql/manage-pod-templates.md

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

# Manage Templates

Required arguments:

* `containerDiskInGb`
* `dockerArgs`
* `env`
* `imageName`
* `name`
* `volumeInGb`

All other arguments are optional.

If your container image is private, you can also specify Docker login credentials with a `containerRegistryAuthId` argument, which takes the ID (*not* the name) of the container registry credentials you saved in your Runpod user settings as a string.

<Info>
  Template names must be unique as well; if you try to create a new template with the same name as an existing one, your call will fail.
</Info>

## Create a Pod Template

### Create GPU Template

<Tabs>
  <Tab title="cURL">
    ```bash  theme={"theme":{"light":"github-light","dark":"github-dark"}}
    curl --request POST \
      --header 'content-type: application/json' \
      --url 'https://api.runpod.io/graphql?api_key=${YOUR_API_KEY}' \
      --data '{"query": "mutation { saveTemplate(input: { containerDiskInGb: 5, dockerArgs: \"sleep infinity\", env: [ { key: \"key1\", value: \"value1\" }, { key: \"key2\", value: \"value2\" } ], imageName: \"ubuntu:latest\", name: \"Generated Template\", ports: \"8888/http,22/tcp\", readme: \"## Hello, World!\", volumeInGb: 15, volumeMountPath: \"/workspace\" }) { containerDiskInGb dockerArgs env { key value } id imageName name ports readme volumeInGb volumeMountPath } }"}'
    ```
  </Tab>

  <Tab title="GraphQL">
    ```GraphQL  theme={"theme":{"light":"github-light","dark":"github-dark"}}
    mutation {
      saveTemplate(input: {
        containerDiskInGb: 5,
        dockerArgs: "sleep infinity",
        env: [
          {
            key: "key1",
            value: "value1"
          },
          {
            key: "key2",
            value: "value2"
          }
        ],
        imageName: "ubuntu:latest",
        name: "Generated Template",
        ports: "8888/http,22/tcp",
        readme: "## Hello, World!",
        volumeInGb: 15,
        volumeMountPath: "/workspace"
      }) {
        containerDiskInGb
        dockerArgs
        env {
          key
          value
        }
        id
        imageName
        name
        ports
        readme
        volumeInGb
        volumeMountPath
      }
    }
    ```
  </Tab>

  <Tab title="Output">
    ```json  theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      "data": {
        "saveTemplate": {
          "containerDiskInGb": 5,
          "dockerArgs": "sleep infinity",
          "env": [
            {
              "key": "key1",
              "value": "value1"
            },
            {
              "key": "key2",
              "value": "value2"
            }
          ],
          "id": "wphkv67a0p",
          "imageName": "ubuntu:latest",
          "name": "Generated Template",
          "ports": "8888/http,22/tcp",
          "readme": "## Hello, World!",
          "volumeInGb": 15,
          "volumeMountPath": "/workspace"
        }
      }
    }
    ```
  </Tab>
</Tabs>

### Create Serverless Template

For Serverless templates, always pass `0` for `volumeInGb`, since Serverless workers don't have persistent storage (other than those with network volumes).

<Tabs>
  <Tab title="cURL">
    ```bash  theme={"theme":{"light":"github-light","dark":"github-dark"}}
    curl --request POST \
      --header 'content-type: application/json' \
      --url 'https://api.runpod.io/graphql?api_key=${YOUR_API_KEY}' \
      --data '{"query": "mutation { saveTemplate(input: { containerDiskInGb: 5, dockerArgs: \"python handler.py\", env: [ { key: \"key1\", value: \"value1\" }, { key: \"key2\", value: \"value2\" } ], imageName: \"runpod/serverless-hello-world:latest\", isServerless: true, name: \"Generated Serverless Template\", readme: \"## Hello, World!\", volumeInGb: 0 }) { containerDiskInGb dockerArgs env { key value } id imageName isServerless name readme } }"}'
    ```
  </Tab>

  <Tab title="GraphQL">
    ```GraphQL  theme={"theme":{"light":"github-light","dark":"github-dark"}}
    mutation {
      saveTemplate(input: {
        containerDiskInGb: 5,
        dockerArgs: "python handler.py",
        env: [
          {
            key: "key1",
            value: "value1"
          },
          {
            key: "key2",
            value: "value2"
          }
        ],
        imageName: "runpod/serverless-hello-world:latest",
        isServerless: true,
        name: "Generated Serverless Template",
        readme: "## Hello, World!",
        volumeInGb: 0
      }) {
        containerDiskInGb
        dockerArgs
        env {
          key
          value
        }
        id
        imageName
        isServerless
        name
        readme
      }
    }
    ```
  </Tab>

  <Tab title="Output">
    ```json  theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      "data": {
        "saveTemplate": {
          "containerDiskInGb": 5,
          "dockerArgs": "python handler.py",
          "env": [
            {
              "key": "key1",
              "value": "value1"
            },
            {
              "key": "key2",
              "value": "value2"
            }
          ],
          "id": "xkhgg72fuo",
          "imageName": "runpod/serverless-hello-world:latest",
          "isServerless": true,
          "name": "Generated Serverless Template",
          "readme": "## Hello, World!"
        }
      }
    }
    ```
  </Tab>
</Tabs>

## Modify a Template

### Modify a GPU Pod Template

<Tabs>
  <Tab title="cURL">
    ```bash  theme={"theme":{"light":"github-light","dark":"github-dark"}}
    curl --request POST \
      --header 'content-type: application/json' \
      --url 'https://api.runpod.io/graphql?api_key=${YOUR_API_KEY}' \
      --data '{"query": "mutation { saveTemplate(input: { id: \"wphkv67a0p\", containerDiskInGb: 5, dockerArgs: \"sleep infinity\", env: [ { key: \"key1\", value: \"value1\" }, { key: \"key2\", value: \"value2\" } ], imageName: \"ubuntu:latest\", name: \"Generated Template\", volumeInGb: 15, readme: \"## Goodbye, World!\" }) { id containerDiskInGb dockerArgs env { key value } imageName name volumeInGb readme } }"}'
    ```
  </Tab>

  <Tab title="GraphQL">
    ```GraphQL  theme={"theme":{"light":"github-light","dark":"github-dark"}}
    mutation {
      saveTemplate(input: {
        id: "wphkv67a0p",
        containerDiskInGb: 5,
        dockerArgs: "sleep infinity",
        env: [
          {
            key: "key1",
            value: "value1"
          },
          {
            key: "key2",
            value: "value2"
          }
        ],
        imageName: "ubuntu:latest",
        name: "Generated Template",
        volumeInGb: 15,
        readme: "## Goodbye, World!"
      }) {
        id
        containerDiskInGb
        dockerArgs
        env {
          key
          value
        }
        imageName
        name
        volumeInGb
        readme
      }
    }
    ```
  </Tab>

  <Tab title="Output">
    ```json  theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      "data": {
        "saveTemplate": {
          "id": "wphkv67a0p",
          "containerDiskInGb": 5,
          "dockerArgs": "sleep infinity",
          "env": [
            {
              "key": "key1",
              "value": "value1"
            },
            {
              "key": "key2",
              "value": "value2"
            }
          ],
          "imageName": "ubuntu:latest",
          "name": "Generated Template",
          "volumeInGb": 15,
          "readme": "## Goodbye, World!"
        }
      }
    }
    ```
  </Tab>
</Tabs>

### Modify a Serverless Template

<Tabs>
  <Tab title="cURL">
    ```bash  theme={"theme":{"light":"github-light","dark":"github-dark"}}
    curl --request POST \
      --header 'content-type: application/json' \
      --url 'https://api.runpod.io/graphql?api_key=${YOUR_API_KEY}' \
      --data '{"query": "mutation { saveTemplate(input: { id: \"xkhgg72fuo\", containerDisk

    InGb: 5, dockerArgs: \"python handler.py\", env: [ { key: \"key1\", value: \"value1\" }, { key: \"key2\", value: \"value2\" } ], imageName: \"runpod/serverless-hello-world:latest\", name: \"Generated Serverless Template\", volumeInGb: 0, readme: \"## Goodbye, World!\" }) { id containerDiskInGb dockerArgs env { key value } imageName name readme } }"}'
    ```
  </Tab>

  <Tab title="GraphQL">
    ```GraphQL  theme={"theme":{"light":"github-light","dark":"github-dark"}}
    mutation {
      saveTemplate(input: {
        id: "xkhgg72fuo",
        containerDiskInGb: 5,
        dockerArgs: "python handler.py",
        env: [
          {
            key: "key1",
            value: "value1"
          },
          {
            key: "key2",
            value: "value2"
          }
        ],
        imageName: "runpod/serverless-hello-world:latest",
        name: "Generated Serverless Template",
        volumeInGb: 0,
        readme: "## Goodbye, World!"
      }) {
        id
        containerDiskInGb
        dockerArgs
        env {
          key
          value
        }
        imageName
        name
        readme
      }
    }
    ```
  </Tab>

  <Tab title="Output">
    ```json  theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      "data": {
        "saveTemplate": {
          "id": "xkhgg72fuo",
          "containerDiskInGb": 5,
          "dockerArgs": "python handler.py",
          "env": [
            {
              "key": "key1",
              "value": "value1"
            },
            {
              "key": "key2",
              "value": "value2"
            }
          ],
          "imageName": "runpod/serverless-hello-world:latest",
          "name": "Generated Serverless Template",
          "readme": "## Goodbye, World!"
        }
      }
    }
    ```
  </Tab>
</Tabs>

## Delete a Template

Note that the template you'd like to delete must not be in use by any Pods or assigned to any Serverless endpoints. It can take up to 2 minutes to be able to delete a template after its most recent use by a Pod or Serverless endpoint, too.

The same mutation is used for deleting both Pod and Serverless templates.

<Tabs>
  <Tab title="cURL">
    ```bash  theme={"theme":{"light":"github-light","dark":"github-dark"}}
    curl --request POST \
      --header 'content-type: application/json' \
      --url 'https://api.runpod.io/graphql?api_key=${YOUR_API_KEY}' \
      --data '{"query": "mutation { deleteTemplate(templateName: \"Generated Template\") }"}'
    ```
  </Tab>

  <Tab title="GraphQL">
    ```GraphQL  theme={"theme":{"light":"github-light","dark":"github-dark"}}
    mutation {
      deleteTemplate(templateName: "Generated Template")
    }
    ```
  </Tab>

  <Tab title="Output">
    ```json  theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      "data": {
        "deleteTemplate": null
      }
    }
    ```
  </Tab>
</Tabs>

## Create a Secret

To create a secret, you need to send a GraphQL mutation request. This request will include the `secretCreate` mutation with the required input fields `value` and `name`. The `value` represents the actual secret, and the `name` is a unique identifier for the secret.

<Tabs>
  <Tab title="cURL">
    ```bash  theme={"theme":{"light":"github-light","dark":"github-dark"}}
    curl --request POST \
      --header 'content-type: application/json' \
      --url 'https://api.runpod.io/graphql?api_key=${YOUR_API_KEY}' \
      --data '{"query": "mutation { secretCreate(input: { value: \"i am a test secret\", name: \"i-am-a-secret\" }) { id name description } }"}'
    ```
  </Tab>

  <Tab title="GraphQL">
    ```GraphQL  theme={"theme":{"light":"github-light","dark":"github-dark"}}
    mutation {
      secretCreate(input: {
        value: "i am a test secret",
        name: "i-am-a-secret"
      }) {
        id
        name
        description
      }
    }
    ```
  </Tab>
</Tabs>