Skip to content
Skip to Content
Coder Docs

Create template by organization

POST
/api/v2/organizations/{organization}/templates

Authorization

CoderSessionToken
headerCoder-Session-Token<token>

Path Parameters

organization*string

Organization ID

Request Body

Request body

application/json
  1. body
activity_bump_ms?integer

ActivityBumpMillis allows optionally specifying the activity bump duration for all workspaces created from this template. Defaults to 1h but can be set to 0 to disable activity bumping.

agents_allowed?boolean

AgentsAllowed controls whether Coder Agents can create workspaces using this template. Defaults to true.

allow_user_autostart?boolean

AllowUserAutostart allows users to set a schedule for autostarting their workspace. By default this is true. This can only be disabled with a Premium license.

allow_user_autostop?boolean

AllowUserAutostop allows users to set a custom workspace TTL to use in place of the template's DefaultTTL field. By default this is true. If false, the DefaultTTL will always be used. This can only be disabled with a Premium license.

allow_user_cancel_workspace_jobs?boolean

Allow users to cancel in-progress workspace jobs. *bool as the default value is "true".

allow_workspace_renames?boolean

AllowWorkspaceRenames permits users to rename workspaces built from this template. Renaming can be destructive for templates whose Terraform references the workspace name, so this defaults to false.

autostart_requirement?

AutostartRequirement allows optionally specifying the autostart allowed days for workspaces created from this template. This is a Premium feature.

autostop_requirement?

AutostopRequirement allows optionally specifying the autostop requirement for workspaces created from this template. This is a Premium feature.

cors_behavior?string

CORSBehavior allows optionally specifying the CORS behavior for all shared ports.

Value in"simple""passthru"
default_ttl_ms?integer

DefaultTTLMillis allows optionally specifying the default TTL for all workspaces created from this template.

delete_ttl_ms?integer

TimeTilDormantAutoDeleteMillis allows optionally specifying the max lifetime before Coder permanently deletes dormant workspaces created from this template.

description?string

Description is a description of what the template contains. It must be no longer than 128 Unicode code points.

Lengthlength <= 128
disable_everyone_group_access?boolean

DisableEveryoneGroupAccess allows optionally disabling the default behavior of granting the 'everyone' group access to use the template. If this is set to true, the template will not be available to all users, and must be explicitly granted to users or groups in the permissions settings of the template.

display_name?string

DisplayName is the displayed name of the template.

dormant_ttl_ms?integer

TimeTilDormantMillis allows optionally specifying the max lifetime before Coder locks inactive workspaces created from this template.

failure_ttl_ms?integer

FailureTTLMillis allows optionally specifying the max lifetime before Coder stops all resources for failed workspaces created from this template.

icon?string

Icon is a relative path or external URL that specifies an icon to be displayed in the dashboard.

max_port_share_level?string

MaxPortShareLevel allows optionally specifying the maximum port share level for workspaces created from the template.

Value in"owner""authenticated""organization""public"
name*string

Name is the name of the template.

require_active_version?boolean

RequireActiveVersion mandates that workspaces are built with the active template version.

template_use_classic_parameter_flow?boolean

UseClassicParameterFlow allows optionally specifying whether the template should use the classic parameter flow. The default if unset is true, and is why *bool is used here. When dynamic parameters becomes the default, this will default to false.

template_version_id*string

VersionID is an in-progress or completed job to use as an initial version of the template.

This is required on creation to enable a user-flow of validating a template works. There is no reason the data-model cannot support empty templates, but it doesn't make sense for users.

Formatuuid
time_til_autostop_notify_ms?integer

TimeTilAutostopNotifyMillis allows optionally specifying the duration before the autostop deadline at which a reminder notification is sent for workspaces created from this template. Defaults to 0 (disabled).

Response Body

OK

application/json
  1. response
active_user_count?integer

ActiveUserCount is set to -1 when loading.

active_version_id?string
Formatuuid
activity_bump_ms?integer
agents_allowed?boolean
allow_user_autostart?boolean

AllowUserAutostart and AllowUserAutostop are Premium features. Their values are only used if your license is entitled to use the advanced template scheduling feature.

allow_user_autostop?boolean
allow_user_cancel_workspace_jobs?boolean
allow_workspace_renames?boolean

AllowWorkspaceRenames permits users to rename workspaces built from this template. Renaming can be destructive for templates whose Terraform references the workspace name.

autostart_requirement?
autostop_requirement?

AutostopRequirement and AutostartRequirement are Premium features. Their values are only used if your license is entitled to use the advanced template scheduling feature.

build_time_stats?
cors_behavior?codersdk.CORSBehavior
Value in"simple""passthru"
created_at?string
Formatdate-time
created_by_id?string
Formatuuid
created_by_name?string
default_ttl_ms?integer
deleted?boolean
deprecated?boolean
deprecation_message?string
description?string
disable_module_cache?boolean

DisableModuleCache disables the use of cached Terraform modules during provisioning for this template. It is read-only while ModuleCacheDisabledByDeployment is true.

display_name?string
failure_ttl_ms?integer

FailureTTLMillis, TimeTilDormantMillis, and TimeTilDormantAutoDeleteMillis are Premium features. Their values are used if your license is entitled to use the advanced template scheduling feature.

icon?string
id?string
Formatuuid
max_port_share_level?codersdk.WorkspaceAgentPortShareLevel
Value in"owner""authenticated""organization""public"
module_cache_disabled_by_deployment?boolean

ModuleCacheDisabledByDeployment reports that the deployment disables the Terraform module cache for every template. Templates cannot opt back in, so the effective state is disabled regardless of DisableModuleCache.

name?string
organization_display_name?string
organization_icon?string
organization_id?string
Formatuuid
organization_name?string
Formaturl
provisioner?"terraform"
Value in"terraform"
require_active_version?boolean

RequireActiveVersion mandates that workspaces are built with the active template version.

time_til_autostop_notify_ms?integer

TimeTilAutostopNotifyMillis is the duration before the workspace's autostop deadline at which a reminder notification is sent. 0 disables the notification.

time_til_dormant_autodelete_ms?integer
time_til_dormant_ms?integer
updated_at?string
Formatdate-time
use_classic_parameter_flow?boolean

The samples read CODER_URL and CODER_SESSION_TOKEN: set up your environment.

curl -X POST \	"$CODER_URL/api/v2/organizations/{organization}/templates" \	-H "Coder-Session-Token: $CODER_SESSION_TOKEN" \	-H "Content-Type: application/json" \	-d '{  "name": "string",  "template_version_id": "0ba39c92-1f1b-4c32-aa3e-9925d7713eb1"}'
Example Response200
{  "active_user_count": 0,  "active_version_id": "eae64611-bd53-4a80-bb77-df1e432c0fbc",  "activity_bump_ms": 0,  "agents_allowed": true,  "allow_user_autostart": true,  "allow_user_autostop": true,  "allow_user_cancel_workspace_jobs": true,  "allow_workspace_renames": true,  "autostart_requirement": {    "days_of_week": [      "monday"    ]  },  "autostop_requirement": {    "days_of_week": [      "monday"    ],    "weeks": 0  },  "build_time_stats": {    "property1": {      "p50": 123,      "p95": 146    },    "property2": {      "p50": 123,      "p95": 146    }  },  "cors_behavior": "simple",  "created_at": "2019-08-24T14:15:22Z",  "created_by_id": "9377d689-01fb-4abf-8450-3368d2c1924f",  "created_by_name": "string",  "default_ttl_ms": 0,  "deleted": true,  "deprecated": true,  "deprecation_message": "string",  "description": "string",  "disable_module_cache": true,  "display_name": "string",  "failure_ttl_ms": 0,  "icon": "string",  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",  "max_port_share_level": "owner",  "module_cache_disabled_by_deployment": true,  "name": "string",  "organization_display_name": "string",  "organization_icon": "string",  "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",  "organization_name": "string",  "provisioner": "terraform",  "require_active_version": true,  "time_til_autostop_notify_ms": 0,  "time_til_dormant_autodelete_ms": 0,  "time_til_dormant_ms": 0,  "updated_at": "2019-08-24T14:15:22Z",  "use_classic_parameter_flow": true}