---
title: "/templates/save"
method: POST
path: "/templates/save"
---

# /templates/save

`POST /templates/save`

Create a new template

## Request body

- TemplateSaveRequest
  - `name` string, required — Name of the template
  - `description` string — Description of the template
  - `public` boolean — Whether the template is publicly available
  - `launch_configuration` LaunchConfiguration — Defines automatic actions after the instance becomes active.
    - `type` 'docker' | 'script', required — Specifies the type of launch configuration. See [Launch Configuration](/getting-started/concepts#launch-configuration) for more details.
    - `docker_configuration` DockerConfiguration — May only be used if launch_configuration.type is 'docker'. Use docker_configuration to automatically pull and run a docker image. See this [tutorial](/guides/dockercontainers) for examples.
      - `image` string, required — Specifies the docker image to be pulled and run on the instance at startup.
      - `args` string — Specifies the container arguments passed into the image at runtime.
      - `shared_memory_in_gb` integer — Describes the amount of shared memory allocated for the container. Equivalent to using the --shm-size flag in the docker cli. If shared_memory_in_gb is not specified, then the container will use the host namespace which is the equivalent of --ipc=host.
      - `envs` Env[] — List of environment variable name-value pairs that will be passed to the docker container.
        - `name` string, required — Name of the environment variable
        - `value` string, required — Value of the environment variable
      - `port_mappings` PortMappings[] — List of port mappings between the host instance and the docker container. Equivalent of -p flag for docker run command.
        - `host_port` integer, required — Port of the host.
        - `container_port` integer, required — Port of the container.
      - `volume_mounts` VolumeMounts[] — List of volume mounts between the host instance and the docker container. Equivalent of -v flag for docker run command.
        - `host_path` string, required — Filepath of the host.
        - `container_path` string, required — Filepath of the container.
      - `registry_credentials` RegistryCredentials
        - `username` string — The username for the docker registry.
        - `password` string — The password for the docker registry.
    - `script_configuration` ScriptConfiguration — May only be used if launch_configuration.type is 'script'. Configures a startup script to be run automatically after the instance is active. See this [tutorial]/guides/startupscript) for examples.
      - `base64_script` string, required — A startup script that is base64 encoded.
  - `auto_delete` AutoDelete — Set a date or spend threshold to automatically delete the instance
    - `date_threshold` string — RFC3339 date string
    - `spend_threshold` string — Valid decimal representation of a dollar amount
  - `alert` Alert — Set a date or spend threshold to receive an email alert
    - `date_threshold` string — RFC3339 date string
    - `spend_threshold` string — Valid decimal representation of a dollar amount
  - `volume_mount` VolumeMount — Settings for mounting volumes onto file systems
    - `auto` boolean — Set to true to automatically mount unmounted disks to a default filesystem.
  - `tags` string[] — Tags associated with the template
  - `envs` Env[] — Environment variables for the template
    - `name` string, required — Name of the environment variable
    - `value` string, required — Value of the environment variable
  - `networking` Networking — Network configuration including firewall rules
    - `ufw_rules` UfwRule[] — List of UFW (Uncomplicated Firewall) rules
      - `rule` string — The UFW rule action
      - `from_ip` string, nullable — Source IP address or CIDR range
      - `to_ip` string, nullable — Destination IP address or CIDR range
      - `port` string, nullable — Port number or range (e.g. '80' or '8000:8999')
      - `proto` string, nullable — Protocol (e.g. tcp, udp)

## Response `200`

Returns a TemplateCreateResponse object

- TemplateCreateResponse — Response of the /templates/save API call
  - `id` string, uuid, required — The unique identifier for the instance. Used in the instances for the /instances/{id}/info and /instances/{id}/delete APIs.

---

[API](https://skmtc.net/shadeform/apis/shadeform-api.md) · [All operations](https://skmtc.net/shadeform/apis/shadeform-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/shadeform/shadeform-api/versions/e1750dca8851/schema)
