Compose and create a template
POST
CoderSessionTokenheader
Coder-Session-Token<token>Create template request
application/json- body
base_template_id?stringbase_variable_values?description?stringLength
length <= 128display_name?stringicon?stringmodules?array<>name*stringorganization_id*stringFormat
uuidprovisioner_tags?session_id?stringSessionID is the wizard session this request belongs to, as reported to POST /api/v2/templatebuilder/sessions. It is optional and used only to attribute a build failure to the session that produced it.
Format
uuidCreated
application/json- response
template?The samples read CODER_URL and CODER_SESSION_TOKEN: set up your environment.
curl -X POST \ "$CODER_URL/api/v2/templatebuilder/compose/template" \ -H "Coder-Session-Token: $CODER_SESSION_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "string", "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6"}'const { CODER_URL, CODER_SESSION_TOKEN } = process.env;const url = `${CODER_URL}/api/v2/templatebuilder/compose/template`;const response = await fetch(url, { method: "POST", headers: { "Coder-Session-Token": CODER_SESSION_TOKEN, "Content-Type": "application/json", }, body: JSON.stringify({ name: "string", organization_id: "7c60d51f-b44e-4682-87d6-449835ea4de6", }),});console.log(response.status, await response.text());import osimport requestsurl = os.environ["CODER_URL"] + "/api/v2/templatebuilder/compose/template"token = os.environ["CODER_SESSION_TOKEN"]response = requests.post( url, headers={ "Coder-Session-Token": token, }, json={ "name": "string", "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", },)print(response.status_code, response.text)package mainimport ( "fmt" "io" "net/http" "os" "strings")func main() { body := strings.NewReader(`{ "name": "string", "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6"}`) url := os.Getenv("CODER_URL") + "/api/v2/templatebuilder/compose/template" token := os.Getenv("CODER_SESSION_TOKEN") req, err := http.NewRequest(http.MethodPost, url, body) if err != nil { panic(err) } req.Header.Set("Coder-Session-Token", token) req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer resp.Body.Close() out, err := io.ReadAll(resp.Body) if err != nil { panic(err) } fmt.Println(resp.Status, string(out))}Example Response
{ "template": { "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 }}