Set network
/v1/sandboxes/{id}/networkSets the addresses the sandbox may reach on top of its template's outbound rule, in place of the ones it had. They add to what the template lets out and never take from it: on an open template they change nothing until the template is blocked or an allowlist. The sandbox is held to its template's rule with these on top from when this answers, without a restart, running or stopped, and connections that are already open are not cut. The rule itself is its template's, and is changed with PUT /v1/templates/{id}/network: sending outbound here is refused with rule_on_template. What is sent to the sandbox, commands, files, its public addresses and SSH, is not affected. Only where GET /v1/policy says networkPolicy.
- import { Agental } from "agental-sdk";
- const agental = new Agental();
- const sandbox = await agental.sandboxes.get("sbx_2a9a47e50daec64a");
- await sandbox.setNetwork({ allow: ["203.0.113.7"] });
- {
- "outbound": "open" | "blocked" | "allowlist",
- "allow": string[],
- "template": {
- "templateId": string,
- "name": string,
- "outbound": "open" | "blocked" | "allowlist",
- "allow": string[],
- },
- "own": {
- "allow": string[],
- },
- }
The rule the sandbox is held to from now on, and what it comes from, with each address written one way.
Path
idrequiredstring | e.g. "sbx_0123456789abcdef" |
Headers
AuthorizationrequiredBearer key | An API key that may make this call. |
Body
allowrequiredarray of string | The addresses the sandbox may reach on top of its template's outbound rule, in place of the ones it had. An empty list takes them all away. IPv4 addresses and ranges, as 203.0.113.7 or 198.51.100.0/24, 100 at most. Names are not taken, and nor is a range inside a private network. A range is kept by its first address, so 198.51.100.7/24 comes back as 198.51.100.0/24. With its template's addresses they come to 100 at most. e.g. ["192.0.2.99"] |
Returns
200 The rule the sandbox is held to from now on, and what it comes from, with each address written one way.
outboundallowMore
Empty for open and blocked.templateMore
GET /v1/sandboxes/{id}/template says whether that is the template as it is now.templateIdnameoutboundallowownMore
They add to an allowlist, make a blocked template's rule an allowlist of them, and change nothing while the template is open.allowErrors and other answers
| 400 | invalid_network_policy an address cannot be allowed, or the list itself holds more than 100, and the message says which and why. |
| 400 | rule_on_template outbound was sent, and the message says where a rule is set now. |
| 404 | Not found. |
| 409 | too_many_addresses the list is of 100 or fewer, and with its template's addresses, as the sandbox has them or as the template is now, they come to more than 100. sandbox_archived or sandbox_migrating: the sandbox's machine is not where sandboxes run. Start it, or read it until it is no longer migrating, and send it again. |
| 409 | invalid_state the sandbox is neither running nor stopped. Nothing was changed. |
| 501 | network_policy_unavailable addresses were sent 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.