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
| Method | Path | Description |
|---|---|---|
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}/env | List all env vars (names only, no values) |
PUT | /api/v1/sandboxes/{id}/env | Bulk 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
GETorPATCH. - Merge-patch semantics: string upserts,
nullunsets/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, andMIOSA_TENANT_IDcannot be set or unset (400, atomic rollback). - Key format & bounds:
/^[A-Z][A-Z0-9_]*$/(1-64 chars); strictly< 128 KiB(131,072bytes) per value;<= 256 KiB(262,144bytes) total mergedsum(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" }
]
} | Field | Type | Required | Description |
|---|---|---|---|
vars[].key | string | Yes | Variable name ([A-Z][A-Z0-9_]*) |
vars[].value | string | Yes | Variable value |
vars[].encrypted | boolean | No | Store 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
| Status | Code | Cause |
|---|---|---|
| 400 | INVALID_ID | Sandbox ID is not a valid UUID |
| 400 | invalid vars | vars missing or a key fails name validation |
| 404 | NOT_FOUND | Sandbox does not exist or wrong tenant |
| 404 | NOT_FOUND | Key does not exist (on DELETE) |