Docs
Templates ›

Set template variable

PUT/v1/templates/{id}/secrets/variables/{name}

Sets one of the template's variables, which every command run in it has in its environment. With hosts, it is kept out of the sandbox: its commands see a stand-in, and the proxy on the sandbox's server puts the value in place of the stand-in in the headers and the address of HTTPS requests to those hosts, and nowhere else. The stand-in stays the same when the value is replaced. Without hosts it is plain, and its commands read its value. An empty value is kept as an empty value: DELETE removes one. Hosts do not open the template's outbound rule. A sandbox on the template takes the change when it next starts, or when POST /v1/templates/{id}/apply names it.

RequestTypeScript
  1. import { Agental } from "agental-sdk";
  2. const agental = new Agental();
  3. const template = await agental.templates.get("tpl_0123456789abcdef");
  4. await template.secrets.set("GITHUB_TOKEN", token, { hosts: ["api.github.com"] });
Answer200 OK · SecretVariable

No JSON body.

The variable as it is kept: a kept-out one with its hosts and stand-in, and not its value.

Path

idrequired
string
e.g. "tpl_0123456789abcdef"
namerequired
string
e.g. "DATABASE_URL"

Headers

Authorizationrequired
Bearer key
An API key that may make this call.

Body

valuerequired
string
hosts
array of string
Keeps the variable out of the sandbox: its commands see a stand-in, and the value is sent only to these hosts, over HTTPS. Left out, the variable is plain, and its commands read its value: a kept-out variable set without hosts is plain from then on. Only where GET /v1/policy says hiddenVariables. e.g. ["api.github.com","github.com"]

Returns

200 The variable as it is kept: a kept-out one with its hosts and stand-in, and not its value.

Errors and other answers

400invalid_request the name or value is not one that can be kept.
400invalid_host a host cannot be one, or there are none or more than 10, and the message says which and why.
404 Not found.
501hidden_variables_unavailable hosts were sent where GET /v1/policy says hiddenVariables is false. Nothing was changed.

Every error answers { "error": { "code", "message" } }; a key without the action a call needs answers 403 key_action_forbidden, naming it.