Skip to navigation

Change a running sandbox's network rules

Replaces the outbound network rules of a running sandbox. A 200 means the vendor accepted the rules. A change that removes access was in force when the call returned in every run on both vendors. On Modal, access that a change adds can stay blocked for some seconds after the 200 (seen: still blocked right after the call in 3 of 5 runs, open 15 seconds later in the one run checked again). Modal’s call reports no moment at which the rules took effect, so Meadow cannot wait for it: check from inside the sandbox before you rely on a new allowance. A common use: create the sandbox with the hosts that setup needs, then narrow the rules before untrusted code runs.

Rules:

  • network is the only field and it is required. It has the same shape and the same checks as network on create.
  • The whole rule set is replaced. A field you leave out is set to its default (false or an empty list), so {"network": {}} opens the network. Send every rule you want to keep.
  • Sending the same rules again is safe and returns 200.
  • The sandbox must be running. Any other status returns 409.
  • Connections that are already open may be cut when the new rules no longer allow them.
  • No webhook event is sent for this change.
  • A rule set the vendor hosting the sandbox cannot apply returns 400 and changes nothing. The message names the cause:
    • Daytona cannot combine allow_domains with allow_cidrs.
    • Modal changes rules only on a sandbox that was created with allow_domains or allow_cidrs. A Modal sandbox created with an open network or with block_all returns 400 for every change. A list type (allow_domains or allow_cidrs) can be used in a change only when the sandbox was created with at least one entry of that type, and opening the network needs both. On Modal, block_all in a change is applied as two empty allow lists.
    • A Modal sandbox created before this operation existed returns 400.

Scope: sandboxes.

curl -sS -X PATCH "$MEADOW_BASE_URL/v1/sandboxes/$SANDBOX_ID" \
-H "Authorization: Bearer $MEADOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"network": {"block_all": false, "allow_domains": ["api.example.com"], "allow_cidrs": []}}'

Authentication

AuthorizationBearer

A Meadow API key, sent as Authorization: Bearer mdw_.... The header x-api-key: mdw_... is accepted in its place.

Path parameters

sandbox_idstringRequired

The sandbox id returned by POST /v1/sandboxes. It must belong to the key’s project.

Request

At most 1 MiB.
networkobjectRequired

Outbound network rules. With block_all false and both lists empty, outbound traffic is open. block_all cannot be combined with the allow lists.

Response headers

x-request-idstringOptional

Meadow’s id for this request, req_ and 24 hex characters. Every response carries it, including errors, streams and unknown routes. Every error in the Error schema repeats it as request_id. Quote it when you report a problem.

Response

The sandbox with the new rules in network.

idstring
The sandbox id.
project_idstring
The project the sandbox belongs to.
statusenum
  • creating: accepted. Meadow is trying vendors.
  • running: ready for exec, file, port, and SSH calls.
  • terminating: delete was asked for and the vendor has not confirmed yet.
  • terminated: ended by delete, by timeout_seconds, by the idle timeout, or by the vendor at its own lifetime limit.
  • failed: no vendor could create it, or the vendor lost it while it ran. See failure_reason.
Allowed values:
created_atdatetime
When the create call was accepted.
namestring or nullOptional
The label given at create. Null when none was given.
failure_reasonenumOptional

Why the sandbox is failed. Null otherwise.

  • all_providers_failed: every provider in the route failed, for mixed reasons. Read attempts.
  • timeout: every attempt timed out.
  • image_pull_failed: every attempt failed to pull the image.
  • build_failed: every attempt failed to build the image.
  • provider_lost: the sandbox was running and the provider lost it, for example because the image’s main command exited on Modal.
  • internal: Meadow failed.
providerenum or nullOptional
The provider hosting the sandbox. Null until one accepts it.
Allowed values:
provider_sandbox_idstring or nullOptional
The vendor's own id, for finding the sandbox in their dashboard.
attemptslist of objectsOptional
Every try to create the sandbox, in order. Empty until the first try ends.
skipped_providerslist of objectsOptional

Providers Meadow moved to the end of the route because their circuit breaker was open (sandbox_health on GET /v1/provider-keys), in the order it moved them. Empty when the route was tried as written. A moved provider is still tried if every provider before it fails, and then it also appears in attempts.

The order is decided when the create is about to try a provider, after POST /v1/sandboxes has answered 202. So this list is filled on the answer of a wait=true create, on GET /v1/sandboxes/{sandbox_id} and in webhook events, and is empty on the first 202 of a create that does not wait.

resourcesobjectOptional
The size of the sandbox. Unknown fields return 400.
labelsmap from strings to stringsOptional
The labels given at create. Empty when none were given.
portslist of integersOptional
The ports listed at create.
sshbooleanOptional
Whether SSH was asked for at create.
networkobject or nullOptional

The outbound network rules in force: the rules given at create, or the rules of the last PATCH /v1/sandboxes/{sandbox_id}. All three fields are always present. Null for a sandbox created before Meadow recorded the rules.

started_atdatetime or nullOptional

When the sandbox became running. Null before that.

expires_atdatetime or nullOptional

When timeout_seconds ends the sandbox: started_at plus the timeout. Null until it is running.

terminated_atdatetime or nullOptional

When the sandbox became terminated. Null otherwise.

costobjectOptional

What this sandbox costs at the vendor, so far. Returned by GET /v1/sandboxes/{sandbox_id} and GET /v1/sandboxes, and left out of the other sandbox responses. It is read from the usage records with the same arithmetic as GET /v1/usage, so the two agree: this object covers every vendor sandbox the create started, a provider that Meadow moved on from included, and its cost is what sandbox_cost in /v1/usage adds up for this sandbox over its whole life.

It is a list price times time, not the vendor’s invoice. cost_status says how far to trust it:

  • price_table: the size the vendor granted times its list price.
  • price_estimated: an estimate. cost_reason says why: grant_unconfirmed (the vendor has not yet confirmed the size, so the size asked for is priced), spot_unconfirmed, or meadow_clock (the sandbox has ended and its time is still Meadow’s own count, which runs longer than the vendor’s: Meadow has not yet read the time the vendor billed), or vendor_window_unavailable (the same, and Meadow can no longer read that time: the account stores no key for the vendor, or the sandbox ended more than 4 days ago). A reason about the price is shown before either when both apply.
  • price_unknown: no cost can be stated, and cost is null. Unknown never means free. cost_reason is not_recorded when no usage record exists yet (records are written about once a minute, and a create that never reached a vendor has none), or the reason the price table gives, such as a GPU type or a shape it has no price for. A create the vendor refused before it made a sandbox has a record that costs 0.

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
404
Not Found Error
409
Conflict Error
413
Content Too Large Error
429
Too Many Requests Error
500
Internal Server Error
502
Bad Gateway Error