Docs
Templates ›

Apply template

POST/v1/templates/{id}/apply

Brings running sandboxes on the template up to date with it now: all of them, or the ones named. It is the only call that changes a running sandbox because of its template; a change to a template reaches the others when they next start. Their next command gets the template's variables as they are now, with each sandbox's own on top. Its files are written to their disks now, where that can be done, and before their next command in any case. Each is held to the template's outbound rule, with its own addresses on top, from when this answers: its server is told first, one sandbox at a time, and one whose server does not take it is named in failed and left as it was. Nothing is restarted, and connections that are already open are not cut.

RequestTypeScript
  1. import { Agental } from "agental-sdk";
  2. const agental = new Agental();
  3. const template = await agental.templates.get("tpl_0123456789abcdef");
  4. const applied = await template.apply();
Answer200 OK · TemplateApplied
  1. {
  2. "templateId": string,
  3. "revision": integer,
  4. "applied": string[],
  5. "failed": [{
  6. "sandboxId": string,
  7. "error": string,
  8. }],
  9. }

The sandboxes that were brought up to date.

Path

idrequired
string
e.g. "tpl_0123456789abcdef"

Headers

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

Body

sandboxIds
array of string
The sandboxes to bring up to date. Each has to be on the template and running. Left out, every running sandbox on it.

Returns

200 The sandboxes that were brought up to date.

TemplateApplied4 fields
templateId
string
revision
integer
The template's revision, which every sandbox in applied now has.
applied
string[]
The sandboxes that were brought up to date.
failed
object[]2 fields
The sandboxes whose outbound rule changed and whose server did not take the new one, each with what went wrong, and any whose template's rule changed three times while its server was being told it.
More Each is held to the rule it had, keeps the copy of the template it had, and is not up to date. Empty when every one was brought up to date.
sandboxId
string
error
string

Errors and other answers

404 Not found.
409not_on_template a sandbox named is not on the template.
409sandbox_not_running a sandbox named is not running, and takes the template when it next starts. Nothing was applied.

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