Fork a running sandbox into copies

The parent pauses briefly (`operation: forking`); each copy is created as by a create and answers `parent`.

POST/v1/sandboxes/{sandbox_id}/fork

The parent pauses briefly (operation: forking); each copy is created as by a create and answers parent. If any copy fails, the copies made so far are deleted and the call fails. Each copy counts against creates_per_minute. With first_action, each copy stops the parent's commands named in stop_execs (TERM, then KILL after 5 s) and runs one command before anything else runs, with POD_FORK_INDEX (0 to count − 1), POD_FORK_COUNT and POD_FORK_PARENT in its environment. first_actions names each copy's command, an exec operation read with GET /v1/sandboxes/{sandbox_id}/exec/{operation_id}.

A key with the sandboxes:write scope.

Request

curl -X POST "https://api.pod.mapier.ai/v1/sandboxes/sbx_3ahrz6dmv29gqy5ckt18fpx4b/fork" \
  -H "Authorization: Bearer $POD_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"count":2}'

Parameters

NameInTypeRequiredWhat it is
sandbox_idpathstringYes
Pod-End-UserheaderstringNoNarrows 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-KeyheaderstringYesRequired on this call. Makes a repeat safe for 24 hours.
waitquerybooleanNoWait for the result instead of answering 202 with an operation.
wait_timeout_squeryintegerNoHow long wait=true waits before answering 202 after all.

Body

FieldTypeRequiredWhat it is
countintegerNoDefault 1. From 1 to 10.
size"small" | "medium" | "large" | "xlarge" | "ci-2" | "ci-4" | "ci-8" | "ci-16"NoThe parent's size by default. A different size boots the copies from disk.
first_actionFirstActionNoRun in each copy before anything else: first the parent's commands named in stop_execs are stopped (TERM, then KILL after 5 s), then one command runs as an exec would, with POD_FORK_INDEX, POD_FORK_COUNT and POD_FORK_PARENT added to its environment (naming one of them in env is invalid). Give argv or command, not both. A copy whose memory was not kept (a fork to another size boots from disk) has no processes to stop.

Answer

201. With wait=true, the copies, running.

202. The work started; follow the operation.

201
{
  "data": [
    {
      "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
    }
  ],
  "first_actions": null
}
FieldTypeAlwaysWhat it is
dataSandbox[]Yes
first_actionsFirstActionRun[] | nullYesWith first_action, each copy's command; null without one.

Errors

The refusals this call is known for: invalid, saves_refused, not_supported, no_capacity, quota_exceeded, conflict, not_found, 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

ClientCall
TypeScriptsandbox.fork({ count })
Pythonsandbox.fork(count=…)
mpodmpod sandboxes fork <sandbox>