Sandbox Env API

The sandbox env API manages a key-value store of environment variables attached to a sandbox. Variables are encrypted at rest and injected into the sandbox process environment on start. The API never returns plaintext values - only key names and metadata.

Base path: /api/v1/sandboxes/{id}/env


Endpoints

MethodPathDescription
PATCH/api/v1/sandboxes/{id}Atomic write-only encrypted merge-patch ({"env": {"KEY": "val", "OLD": null}})
PATCH/api/v1/computers/{id}Same atomic write-only encrypted merge-patch contract for Computers
GET/api/v1/sandboxes/{id}/envList all env vars (names only, no values)
PUT/api/v1/sandboxes/{id}/envBulk set or update env vars
DELETE/api/v1/sandboxes/{id}/env/{key}Delete a single env var

Atomic Write-Only Merge-Patch (Sandboxes & Computers)

PATCH /api/v1/sandboxes/{id} and PATCH /api/v1/computers/{id}

  • Write-only encryption: plaintext values are encrypted immediately with ChaCha20-Poly1305 and are never returned by GET or PATCH.
  • Merge-patch semantics: string upserts, null unsets/deletes, omitted keys remain untouched.
  • Reserved platform protection: MIOSA_COMPUTER_ID, MIOSA_GATEWAY_PORT, MIOSA_HOST_ID, MIOSA_INSTANCE_ID, MIOSA_RUNTIME_IMAGE_REF, MIOSA_SANDBOX_ID, and MIOSA_TENANT_ID cannot be set or unset (400, atomic rollback).
  • Key format & bounds: /^[A-Z][A-Z0-9_]*$/ (1-64 chars); strictly < 128 KiB (131,072 bytes) per value; <= 256 KiB (262,144 bytes) total merged sum(name + value) inside a row-locked transaction.

For third-party API keys that must never enter the VM, use Brokered Egress Secrets.


List Env Vars

GET /api/v1/sandboxes/{id}/env

Returns all variable names. Values are never returned.

Auth

Requires sandboxes:read scope.

Authorization: Bearer msk_...

Response - 200 OK

{
  "data": [
    { "key": "DATABASE_URL", "encrypted": true },
    { "key": "API_SECRET", "encrypted": true },
    { "key": "LOG_LEVEL", "encrypted": false }
  ]
}

Set Env Vars

PUT /api/v1/sandboxes/{id}/env

Bulk upsert. Existing keys are updated; new keys are created. Keys not present in the request are left unchanged.

Auth

Requires sandboxes:write scope.

Authorization: Bearer msk_...

Request Body

{
  "vars": [
    { "key": "DATABASE_URL", "value": "postgres://...", "encrypted": true },
    { "key": "LOG_LEVEL", "value": "debug" }
  ]
}
FieldTypeRequiredDescription
vars[].keystringYesVariable name ([A-Z][A-Z0-9_]*)
vars[].valuestringYesVariable value
vars[].encryptedbooleanNoStore encrypted at rest (default: true)

Response - 200 OK

{
  "data": [
    { "key": "DATABASE_URL", "encrypted": true },
    { "key": "LOG_LEVEL", "encrypted": false }
  ]
}

Delete Env Var

DELETE /api/v1/sandboxes/{id}/env/{key}

Removes a single variable.

Response - 200 OK

{
  "deleted": true,
  "name": "LOG_LEVEL"
}

Errors

StatusCodeCause
400INVALID_IDSandbox ID is not a valid UUID
400invalid varsvars missing or a key fails name validation
404NOT_FOUNDSandbox does not exist or wrong tenant
404NOT_FOUNDKey does not exist (on DELETE)

Examples

Was this page helpful?
Opening MIOSA…