Compose template from base and modules
POST
CoderSessionTokenheader
Coder-Session-Token<token>Compose request
application/json- body
base_template_id?stringbase_variable_values?modules?array<>The samples read CODER_URL and CODER_SESSION_TOKEN: set up your environment.
curl -X POST \ "$CODER_URL/api/v2/templatebuilder/compose" \ -H "Coder-Session-Token: $CODER_SESSION_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "base_template_id": "string", "base_variable_values": { "property1": "string", "property2": "string" }, "modules": [ { "agent_name": "string", "id": "string", "variables": { "property1": "string", "property2": "string" } } ]}'const { CODER_URL, CODER_SESSION_TOKEN } = process.env;const url = `${CODER_URL}/api/v2/templatebuilder/compose`;const response = await fetch(url, { method: "POST", headers: { "Coder-Session-Token": CODER_SESSION_TOKEN, "Content-Type": "application/json", }, body: JSON.stringify({ base_template_id: "string", base_variable_values: { property1: "string", property2: "string", }, modules: [ { agent_name: "string", id: "string", variables: { property1: "string", property2: "string", }, }, ], }),});console.log(response.status, await response.text());import osimport requestsurl = os.environ["CODER_URL"] + "/api/v2/templatebuilder/compose"token = os.environ["CODER_SESSION_TOKEN"]response = requests.post( url, headers={ "Coder-Session-Token": token, }, json={ "base_template_id": "string", "base_variable_values": { "property1": "string", "property2": "string", }, "modules": [ { "agent_name": "string", "id": "string", "variables": { "property1": "string", "property2": "string", }, }, ], },)print(response.status_code, response.text)package mainimport ( "fmt" "io" "net/http" "os" "strings")func main() { body := strings.NewReader(`{ "base_template_id": "string", "base_variable_values": { "property1": "string", "property2": "string" }, "modules": [ { "agent_name": "string", "id": "string", "variables": { "property1": "string", "property2": "string" } } ]}`) url := os.Getenv("CODER_URL") + "/api/v2/templatebuilder/compose" 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 Response200
Empty