Set template variable
/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.
- import { Agental } from "agental-sdk";
- const agental = new Agental();
- const template = await agental.templates.get("tpl_0123456789abcdef");
- await template.secrets.set("GITHUB_TOKEN", token, { hosts: ["api.github.com"] });
No JSON body.
The variable as it is kept: a kept-out one with its hosts and stand-in, and not its value.
Path
idrequiredstring | e.g. "tpl_0123456789abcdef" |
namerequiredstring | e.g. "DATABASE_URL" |
Headers
AuthorizationrequiredBearer key | An API key that may make this call. |
Body
valuerequiredstring | |
hostsarray 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
| 400 | invalid_request the name or value is not one that can be kept. |
| 400 | invalid_host a host cannot be one, or there are none or more than 10, and the message says which and why. |
| 404 | Not found. |
| 501 | hidden_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.