Make a key for one sandbox, to use from inside it

A sandbox key (class `sandbox`) lets an agent in the sandbox manage its own sandbox: read and write its files, run commands, sleep it, fork it to make children it can reach, open its ports.

POST/v1/sandboxes/{sandbox_id}/keys

A sandbox key (class sandbox) lets an agent in the sandbox manage its own sandbox: read and write its files, run commands, sleep it, fork it to make children it can reach, open its ports. Pass it to the sandbox in the environment of the commands it runs, as POD_SANDBOX_KEY (or POD_API_KEY), where the SDKs and mpod find it; environment values are never logged or stored. It holds at most its maker's scopes (a key's own, or the person's role's), and only scopes on a sandbox: sandboxes:*, files:*, snapshots:write. It is accepted only from the sandbox's own slot, reaches only that sandbox and its children, and is refused within 60 seconds of being revoked. It lives ttl_s: 60 seconds to 30 days, a day by default. It is revoked when the sandbox is deleted, when its maker's key is revoked and when its maker leaves the organization. A sandbox holds at most 20 live keys (conflict past it). The secret is answered once and stored only as a SHA-256 hash. A repeat with the same Idempotency-Key answers conflict and never the secret again.

A key with the keys:write scope.

Request

curl -X POST "https://api.pod.mapier.ai/v1/sandboxes/sbx_3ahrz6dmv29gqy5ckt18fpx4b/keys" \
  -H "Authorization: Bearer $POD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"scopes":["sandboxes:read"]}'

Parameters

NameInTypeRequiredWhat it is
sandbox_idpathstringYes
Idempotency-KeyheaderstringNoMakes a repeat of this call safe for 24 hours.

Body

FieldTypeRequiredWhat it is
scopes"sandboxes:read" | "sandboxes:write" | "sandboxes:exec" | "files:read" | "files:write" | "snapshots:write" | "usage:read" | "keys:write" | "projects:write" | "members:read" | "end_users:read" | "end_users:write" | "screen:read" | "screen:write" | "webhooks:read" | "webhooks:write" | "permissions:read" | "permissions:write" | "permissions:records" | "ci:read" | "ci:write" | "network:read" | "network:write"[]YesA subset of the maker's scopes, all on a sandbox (sandboxes:*, files:*, snapshots:write).
namestringNosandbox {id} when absent.
ttl_sintegerNoHow long the key lives, 60 seconds to 30 days. Default 86400. From 60 to 2592000.

Answer

201. The key and its secret, shown this once.

201
{
  "key": {
    "id": "key_3ahrz6dmv29gqy5ckt18fp",
    "name": "example",
    "project": "prj_3ahrz6dmv29gqy5ckt18fp",
    "mode": "test",
    "class": "person",
    "scopes": ["sandboxes:read"],
    "last_four": "example",
    "created_by": "example",
    "created_at": "2026-11-23T12:00:00.000Z",
    "expires_at": null,
    "revoked_at": null,
    "service": null,
    "billing_mark": null,
    "parent_sandbox": null,
    "parent_scopes": null,
    "last_used_at": null,
    "rotated_at": null,
    "previous_secret_until": null
  },
  "secret": "pod_3ahrz6dmv29gqy5ckt18fpx4bjs07enw3ahrz6dm"
}
FieldTypeAlwaysWhat it is
keyApiKeyYes
secretstringYesShown once. Stored by Pod only as a SHA-256 hash.

Errors

The refusals this call is known for: invalid, forbidden, conflict, not_found. Any call can also answer unauthorized, rate_limited, unavailable or internal; the error list says what each means and when to send the call again.

In the SDKs

ClientCall
TypeScriptpod.sandboxKeys.create(sandboxId, { scopes })
Pythonpod.sandbox_keys.create(sandbox_id, scopes=…)