Create a sandbox
Creates a sandbox by restoring a template or a snapshot, or by booting an image.
Creates a sandbox by restoring a template or a snapshot, or by booting an image. By default the call waits until the sandbox is running and answers 201. If the sandbox is still creating when wait_timeout_s passes, or if wait is false, the call answers 202 with the sandbox in creating. Poll its state with a get. If a waiting call observes the placed sandbox in error, it answers 202 with that sandbox's ID, error state and reason, such as create_failed. When no server has room, the call answers 503 no_capacity with retry_after_s. Nothing is made or billed. With hold_server, server_held in that answer says a whole server is now held for this create: retry at retry_after_s with the same idempotency key, and it lands there once the server has room. With count above 1, a swarm name or roles, it is a batch create: the copies make one group, and it always answers 202 with BatchCreated at once (wait: true is invalid). Each copy counts against creates_per_minute. A batch larger than the trust tier's swarm cap is quota_exceeded with limit: max_swarm; nothing is made. Copies no server took are listed in unplaced, and the rest carry on.
A key with the sandboxes:write scope.
Request
curl -X POST "https://api.pod.mapier.ai/v1/sandboxes" \
-H "Authorization: Bearer $POD_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"system":"linux","size":"small","labels":{"app":"quickstart"}}'Parameters
| Name | In | Type | Required | What it is |
|---|---|---|---|---|
Pod-End-User | header | string | No | Narrows a project key to one of its end users: the call sees only that end user's sandboxes and usage, any other answering not_found, and a create is labelled with it. An end user of another project, or one that is not there, is not_found; a suspended one refuses creates and wakes (account_restricted). |
Idempotency-Key | header | string | Yes | Required on this call. Makes a repeat safe for 24 hours. |
Body
| Field | Type | Required | What it is |
|---|---|---|---|
project | string | No | The project the sandbox belongs to. A key's own project by default, and a key may name only that one; a signed-in person names any project of the organization (the organization's first by default). A project the caller may not see answers forbidden. |
system | "linux" | No | |
size | "small" | "medium" | "large" | "xlarge" | "ci-2" | "ci-4" | "ci-8" | "ci-16" | No | small by default. |
template | string | No | Restore this template. Give at most one of template, snapshot and image; with none, the system's default template. |
snapshot | string | No | Restore this snapshot. |
image | string | No | Boot this image from its disk; slower than a restore. |
class | "shared" | "ci" | "nested" | No | The size's class by default; must match it. |
wait | boolean | No | Wait until running and answer 201. Default true. |
wait_timeout_s | integer | No | Default 60. From 1 to 300. |
time_limit_s | integer | null | No | Stop the sandbox this long after it starts. None by default. At least 1. |
idle_s | integer | null | No | Sleep after this long with no activity. The project's default, 15 minutes unless set. null: never sleep for want of activity, for a sandbox that must stay awake while it waits, such as a CI runner waiting for its job or a quiet build step. Its time limit still applies, and a sleep call still puts it to sleep. At least 60. |
disk | "persistent" | "throwaway" | No | persistent by default; always throwaway on CI sizes. |
no_save | boolean | No | Refuse snapshots, share links and forks to every key but the one that created the sandbox. Default false. |
env | Env | No | Environment variables. Never logged, stored or answered back. |
labels | Labels | No | Up to 32 labels. Keys are lowercase, 1 to 63 characters; values up to 256. |
end_user | string | No | Label the sandbox with this end user of the project (POST /v1/end_users), so its usage can be read by end user and the end user's limits count it. Never changed after the create. An end user the key cannot see is invalid. |
volumes | AttachVolumeRequest[] | No | Volumes to attach at create, usually locked until the sandbox's work is known. Each is checked before anything is made: one that does not exist is invalid, one attached elsewhere conflict. Volumes must belong to the sandbox's project and mode. A batch with volumes is invalid because a volume has one attachment. |
needs | "kvm" | "ios-simulator"[] | No | Capabilities the sandbox needs, in the spec file's words: the scheduler places it where they are, kvm in the pool kept for VMs inside sandboxes. A capability the system does not have is invalid; one this cell does not offer yet is system_not_offered. |
nested_virtualization | boolean | No | Run VMs inside this sandbox: it is placed in the nested class's pool, on servers of its own, Linux only, in a shared size. The same as class: nested or kvm in needs; false beside either is invalid. It cannot be switched on later. A cell without the pool answers system_not_offered. |
hints | PlacementHints | No | "This sandbox will use these volumes or this snapshot": the scheduler prefers a server that already holds them for this organization. A hint never refuses a create and never overrides room; an id of another organization's object is found nowhere. At most 16 ids together, repeats dropped. A create from a snapshot hints its own snapshot. |
hold_server | boolean | No | Hold a whole server for this create when none has room now. Only for a CI size of at least 16 cores (ci-16); on any other size it is invalid. The answer is still 503 no_capacity, with server_held saying whether a server is held; the retry with the same idempotency key lands there once it has room. Nothing is queued. A batch cannot hold a server (invalid). Default false. |
count | integer | No | How many copies to make. Above 1 it is a batch create: 2 to 1000 copies as one swarm, answered 202 with BatchCreated. With roles, the roles' counts must add up to it; without count they set it. 0 is invalid. From 0 to 1000. |
swarm | string | No | The swarm's name. Makes the create a batch. |
roles | BatchRole[] | No | The copies' roles, each with its count. Copies are named <role>-<n> in the order given, n from 0 within its role, or member-<n> with no roles; the name is the copy's name on the group's private network. Makes the create a batch. |
policy | string | No | Run the sandbox under this stored policy of the project (Pod Agent IAM's listPolicies). The front door binds it before the sandbox runs anything (Pod Agent IAM's bindSandbox), so the sandbox reaches only what the policy grants. Left out, with no rules, the sandbox runs under the project's default for sandboxes with no policy: the public internet within Pod's baseline, unless the project switched its default to deny. A policy the project does not hold is invalid (field policy); a key issued inside a sandbox may name only its parent's policy or one that narrows it. |
rules | string | No | Rules for this sandbox alone, in the simple form, one a line (Allow net api.github.com GET /repos/*). They are cut to the ceiling (the policy and, above it, the project's and the organization's), and what was cut is in the sandbox's binding. Rules here close the network as a policy does: the sandbox reaches only what they and its policy allow. A rule the compiler refuses is invalid (field rules). |
Answer
201. The sandbox, running.
202. A single sandbox in creating or a waiting create's sandbox in error. For a batch, the group and its copies.
{
"id": "sbx_3ahrz6dmv29gqy5ckt18fpx4b",
"project": "prj_3ahrz6dmv29gqy5ckt18fp",
"state": "running",
"tier": null,
"operation": null,
"reason": null,
"restarted": false,
"system": "linux",
"size": "small",
"class": "shared",
"disk": "persistent",
"template": null,
"parent": null,
"created_at": "2026-11-23T12:00:00.000Z",
"state_at": "2026-11-23T12:00:00.000Z",
"time_limit_at": null,
"idle_s": 900,
"flags": {
"no_save": false,
"billing_mark": null
},
"labels": {
"app": "quickstart"
},
"queue_position": null,
"end_user": null,
"group": null
}| Field | Type | Always | What it is |
|---|---|---|---|
id | string | Yes | |
project | string | Yes | |
state | "creating" | "running" | "stopping" | "sleeping" | "waking" | "stopped" | "deleting" | "deleted" | "error" | Yes | running means restored and reset: a sandbox made or woken from a copy (a template, a snapshot or a fork) shows running only once Pod's agent inside it has reset the copy (random numbers, clock and identity), so nothing that runs in it shares them with another copy. Secrets and the machine profile load after the reset. |
tier | "memory" | "disk" | "none" | null | Yes | Set only while sleeping. |
operation | "snapshotting" | "forking" | "moving" | null | Yes | |
reason | "create_failed" | "boot_failed" | "server_lost" | "resize_failed" | "vm_crashed" | "time_limit" | "no_capacity" | "idle" | "stopped" | null | Yes | |
restarted | boolean | Yes | True when the last wake booted, so programs started again. |
system | "linux" | Yes | |
size | "small" | "medium" | "large" | "xlarge" | "ci-2" | "ci-4" | "ci-8" | "ci-16" | Yes | |
class | "shared" | "ci" | "nested" | Yes | |
disk | "persistent" | "throwaway" | Yes | throwaway keeps writes on the server and never sends them to object storage; the sandbox cannot sleep to disk on another server and is lost with its server. The key that created it may still snapshot it, with its memory, and restore the snapshot at the same size; with no_save, every other key is refused. |
template | string | null | Yes | |
parent | string | null | Yes | The sandbox this one was forked from. |
created_at | string | Yes | RFC 3339 in UTC with milliseconds, for example 2026-11-23T17:04:05.123Z. |
state_at | string | Yes | RFC 3339 in UTC with milliseconds, for example 2026-11-23T17:04:05.123Z. |
time_limit_at | string | null | Yes | |
idle_s | integer | null | Yes | Seconds with no activity before it sleeps; null when it never sleeps for want of activity. At least 60. |
flags | SandboxFlags | Yes | |
labels | Labels | Yes | Up to 32 labels. Keys are lowercase, 1 to 63 characters; values up to 256. |
queue_position | integer | null | Yes | While waking and waiting for room. At least 1. |
end_user | string | null | Yes | The end user the sandbox was made for, if any. |
group | string | null | Yes | The sandbox's group: its swarm, or its group of one, whose id is the sandbox's with grp_ for sbx_. Null only from a cell that predates groups. |
Errors
The refusals this call is known for: invalid, forbidden, quota_exceeded, plan_required, account_restricted, spend_cap_reached, rate_limited, no_capacity, system_not_offered, conflict, in_other_cell. 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
| Client | Call |
|---|---|
| TypeScript | pod.sandboxes.create({ … }) |
| Python | pod.sandboxes.create(…) |
| mpod | mpod sandboxes create |