Templates ›
Set sandbox template
PUT
/v1/sandboxes/{id}/templatePuts the sandbox on another template of its account. It has that template's variables and files from its next command, running or not, without a restart, and is up to date with it. It is held to the template's outbound rule, with its own addresses on top, at once: a running one from when this answers, and a stopped one from its next start. Its size and what it started from stay as they are, and so do its secrets and addresses of its own.
RequestTypeScript
- import { Agental } from "agental-sdk";
- const agental = new Agental();
- const sandbox = await agental.sandboxes.get("sbx_2a9a47e50daec64a");
- await sandbox.setTemplate("tpl_0123456789abcdef");
Answer200 OK · SandboxTemplate
- {
- "sandboxId": string,
- "templateId": string,
- "name": string,
- "default": boolean,
- "upToDate": boolean,
- "takenAt": string,
- "variables": string[],
- "hidden": string[],
- "files": string[],
- }
The sandbox's template from now on.
Path
idrequiredstring | e.g. "sbx_0123456789abcdef" |
Headers
AuthorizationrequiredBearer key | An API key that may make this call. |
Body
templateIdrequiredstring |
Returns
200 The sandbox's template from now on.
SandboxTemplate9 fields
sandboxIdstring
templateIdstring
namestring
The template's name.
defaultboolean
upToDateboolean
Whether it has the template's variables, files and outbound rule as they are now.
More
A sandbox takes them when it starts, when it is put on the template, and when POST /v1/templates/{id}/apply names it. A stopped one that is not up to date takes them at its next start.takenAtstring
When it last took them.
variablesstring[]
The names of the variables it has from the template: its own come on top of these.
hiddenstring[]
Of those, the ones kept out of the sandbox, as it has them.
filesstring[]
The paths of the files it has from the template: its own come on top of these.
Errors and other answers
| 404 | not_found no such sandbox, or no such template in the sandbox's account. |
| 409 | too_many_addresses the template's rule and the sandbox's own addresses come to more than 100. |
| 409 | invalid_state the sandbox is being made, and its rule would change. |
| 409 | sandbox_migrating it is being moved while it runs. |
| 409 | template_changed the template's rule changed three times while the sandbox's server was being told it; send it again. Nothing was changed. |
| 501 | network_policy_unavailable the template holds a rule where GET /v1/policy says networkPolicy 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.