---
title: "POST /v1/sandboxes"
method: POST
path: "/v1/sandboxes"
tags: ["Sandboxes"]
---

# POST /v1/sandboxes

`POST /v1/sandboxes`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/v1/sandboxes`
- Auth: HTTP bearer

## Request body

- CreateSandboxBody
  - `_runtime` string, nullable
  - `allow_docker` boolean: Permit installing/running Docker with normal guest-root privileges. Requires backend="microsandbox". Does not install Docker or expose the host socket.
  - `backend` string, nullable: Isolation backend: `"docker"` (default), `"firecracker"` (ADR-029, hardware-virtualized microVM — requires a host provisioned with `temps firecracker setup`) or `"microsandbox"` (ADR-050, experimental libkrun microVM — requires `temps microsandbox setup`). Omit for the platform default; existing clients are unaffected. Requesting an unavailable backend fails with 400 rather than silently downgrading isolation.
  - `cpu_limit` number, double, nullable: CPU cores, `[0.01, 16]`, bounded by the placement host and any administrator maximum. Omit for the effective placement default.
  - `creation_id` string, nullable: Id the client gives this create, so it can read the create's steps from `GET /v1/sandboxes/creations/{creation_id}` while it waits for this request: 8 to 64 letters, digits, `-` or `_`, new for every create (a UUID works). Optional.
  - `disk_size_mb` integer, nullable: Root disk size in MB, `[1, 65536]` (Firecracker only; Docker ignores it). Omit for the platform default (1 GiB).
  - `egress_policy` SandboxEgressPolicy: Which outside destinations the sandbox may reach (temps-native). Omit for `{"mode": "internet"}`: any public destination on ports 80 and 443. `{"mode": "restricted", "rules": [...]}` allows only the listed hosts (`api.example.com`, or `*.example.com` for subdomains) and CIDR blocks, each on its `ports` (default 80 and 443). Private, loopback, link-local and metadata addresses are never reachable. A restricted policy needs the docker backend; elsewhere the create fails with 422. Change it later with `PUT /v1/sandboxes/{id}/egress-policy`.
    - `mode` 'internet' | 'restricted': How a sandbox may reach the outside world.
    - `rules` EgressRule[]: Allowed destinations, in `restricted` mode. At most 100.
      - `cidr` string, nullable: An IPv4 or IPv6 address or CIDR block (`198.51.100.7`, `2606:4700::/32`), matched against a literal IP the sandbox asked for or the address a hostname resolved to.
      - `host` string, nullable: A hostname, matched case-insensitively against the name the sandbox asked for (`api.example.com`). A leading `*.` matches subdomains only: `*.example.com` matches `a.example.com` and `a.b.example.com`, never `example.com` itself.
      - `ports` integer[]: Destination ports this rule permits, 1-65535. Empty means 80 and 443.
  - `env` object: Extra env vars baked into the container on create.
  - `from_snapshot` string, nullable: Create the sandbox from a snapshot (ADR-037). Mutually exclusive with `image`: if both are set the request fails with 400. When set, the sandbox is created with the snapshotted filesystem rather than a base image, giving users a reproducible starting point. The snapshot must be in `ready` status and belong to the calling user.
  - `image` string, nullable: Docker image override. `null` uses the platform default.
  - `lifecycle` string, nullable: Lifecycle class (ADR-036, temps-native): `"ephemeral"` (default) or `"workspace"`. A workspace is a long-lived development environment: it is still suspended after `timeout_secs` of inactivity, but the next exec or filesystem call wakes it transparently instead of returning 409, and nothing ever destroys it automatically. Use it for "give me a place to work on this repo"; leave it unset for throwaway sandboxes.
  - `memory_limit_mb` integer, nullable: Memory in MB, `[6, 32768]` (lower if an administrator set a maximum, and never more than the host has). Omit for the operator's default.
  - `name` string, nullable
  - `networkPolicy` unknown
  - `node` string, nullable: Node to create the sandbox on (ADR-048): a node name, a node id, or `control-plane` / `0` for the control plane. Omit to let Temps place it (the control plane when allowed, otherwise the allowed worker with the fewest live sandboxes). The node must be allowed by the operator's sandbox placement settings and online; otherwise the request fails with 422 — it never silently falls back to another node.
  - `pids_limit` integer, nullable: Max processes, `[1, 4096]` (lower if an administrator set a maximum); `0`/negative (unlimited) is rejected. Omit for the platform default (512).
  - `ports` integer[]: Ports the sandbox will listen on. Each port becomes a `routes[]` entry in the create/get response so `@vercel/sandbox`'s `sandbox.domain(port)` can resolve it client-side without an extra round-trip.
  - `preview_password` string, password, nullable: A credential. Write-only: it is never returned, and the AI assistant supplies it through a secret slot instead of typing it into the conversation.
  - `projectId` string, nullable
  - `project_id` integer, nullable: Create the sandbox against a temps project (temps-native). The project's connected repo and git credential seed the work dir when no explicit `source` is given, and the sandbox is attributed to the project so it can be listed alongside it. Requires access to the project and `git_repositories:read` when Temps derives the source from the project. The same team/scope rules that gate every other project-scoped endpoint apply.
  - `resources` ResourcesBody, nullable: Nested `resources: { memory, vcpus }` as sent by `@vercel/sandbox`. `memory` is in MB, `vcpus` is fractional CPU count.
    - `memory` integer, nullable
    - `vcpus` number, double, nullable
  - `source` union: Initial content to seed into the sandbox work dir. Mirrors the `@vercel/sandbox` `source` option. `type` is one of: - `git` — clone `url`; optionally check out `revision` - `tarball` — download `url` (must be tar or tar.gz) and extract For private git repos, pass credentials one of two ways: 1. **Inline (SDK-compatible):** `username` + `password`. GitHub tokens use `username: "x-access-token"`. 2. **Stored connection (temps-native):** `git_connection_id` references a row in the caller's git provider connections. Temps resolves the token server-side and injects it safely. `git_connection_id` is mutually exclusive with `username`/`password`.
    - object
      - `depth` integer, nullable
      - `destination` string, nullable: Optional path relative to the sandbox work directory.
      - `git_connection_id` integer, nullable
      - `password` string, nullable
      - `revision` string, nullable
      - `strip_git_metadata` boolean: Remove `<destination>/.git` after cloning. Requires destination.
      - `type` 'git', required
      - `url` string, required
      - `username` string, nullable
    - object
      - `type` 'tarball', required
      - `url` string, required
  - `timeout` integer, nullable: Idle timeout as sent by `@vercel/sandbox` (milliseconds). Converted to seconds when `timeout_secs` is absent.
  - `timeout_secs` integer, nullable: Idle timeout in seconds (temps-native). Clamped to `[60, 86400]`.

## Response `201`

Sandbox created

- SandboxResponse: `@vercel/sandbox` wraps every single-sandbox response as `{ sandbox: {...}, routes: [...] }`. The SDK reads both.
  - `routes` SandboxRoute[], required
    - `port` integer, required
    - `subdomain` string, required
    - `url` string, required
  - `sandbox` SandboxInner, required: Inner `sandbox` object in `@vercel/sandbox` responses. Strict shape — the SDK's zod validator rejects missing required fields.
    - `agent_run_id` integer, nullable: Agent run this sandbox executes (autofixer / workflow agent). `None` for sandboxes created via this API.
    - `allow_docker` boolean, required: Normal guest-root semantics enabled for Docker (microsandbox only).
    - `backend` string, nullable: Isolation backend: "docker" | "firecracker" | "microsandbox". `None` on legacy rows created before the backend was recorded.
    - `createdAt` integer, required
    - `cwd` string, required
    - `disk_size_mb` integer, nullable: Configured root disk size in MB (Firecracker). `None` when unknown or the default.
    - `egress_policy` SandboxEgressPolicy, required: Which outside destinations the sandbox may reach (temps-native).
      - `mode` 'internet' | 'restricted': How a sandbox may reach the outside world.
      - `rules` EgressRule[]: Allowed destinations, in `restricted` mode. At most 100.
        - `cidr` string, nullable: An IPv4 or IPv6 address or CIDR block (`198.51.100.7`, `2606:4700::/32`), matched against a literal IP the sandbox asked for or the address a hostname resolved to.
        - `host` string, nullable: A hostname, matched case-insensitively against the name the sandbox asked for (`api.example.com`). A leading `*.` matches subdomains only: `*.example.com` matches `a.example.com` and `a.b.example.com`, never `example.com` itself.
        - `ports` integer[]: Destination ports this rule permits, 1-65535. Empty means 80 and 443.
    - `id` string, required
    - `image` string, nullable
    - `lifecycle` string, required: Lifecycle class (ADR-036): `"ephemeral"` or `"workspace"`. Always present — a client that doesn't know about workspaces sees `"ephemeral"` and behaves exactly as before.
    - `memory` integer, required
    - `name` string, required
    - `node_id` integer, nullable: Worker node hosting the sandbox (ADR-048). `null` = the control plane.
    - `node_name` string, required: Name of the hosting node; `"control-plane"` for control-plane sandboxes.
    - `preview_access` 'temps_login' | 'password' | 'public', required: Who may open the preview URLs: `temps_login` (a signed-in Temps user who may read this sandbox; the default), `password` (whoever knows the preview password) or `public` (anyone).
    - `preview_allowed_cidrs` string[], required: Client networks allowed to open the preview URLs, as normalised CIDRs. Checked before `preview_access`; empty = any address.
    - `preview_password_hint` string, nullable
    - `preview_url_template` string, required
    - `project_id` integer, nullable: Project this sandbox was created from, when created from one.
    - `region` string, required
    - `requestedAt` integer, required: Creation time as Unix epoch milliseconds.
    - `runtime` string, required
    - `source_repo_url` string, nullable: Repo the work dir was seeded from. Never carries credentials.
    - `status` string, required
    - `timeout` integer, required: Idle timeout in milliseconds (SDK convention).
    - `updatedAt` integer, required
    - `vcpus` number, double, required

## Other responses

- `400`: Validation error, including a CPU, memory, process or disk limit outside the allowed range or above the administrator's maximum
- `401`: Unauthorized
- `422`: Requested node does not exist, is not allowed to run sandboxes, is not active, or no node is eligible; or the user already has the maximum number of sandboxes an administrator allows
- `500`: Internal server error
- `502`: The project stores no clone URL and its git connection could not look up the project's repository

## Changes

- **2026-11-24** `9d3a2d20b6fd`: 1 info
  - added the non-success response with the status `502`
- **2026-11-19** `fa7fe1033472`: 1 info
  - added the new optional request property `creation_id`
- **2026-10-28** `b8d51a990805`: 4 info
  - added the new optional request property `egress_policy`
  - added the required property `sandbox/egress_policy` to the response with the `201` status
  - added the required property `sandbox/preview_access` to the response with the `201` status
  - added the required property `sandbox/preview_allowed_cidrs` to the response with the `201` status
- **2026-10-25** `718cc1844de1`: 3 breaking, 9 warning
  - the `disk_size_mb` request property's min was increased to `1.00`
  - the `memory_limit_mb` request property's min was increased to `6.00`
  - the `resources/oneOf[#/components/schemas/ResourcesBody]/memory` request property's min was increased to `6.00`
  - the `cpu_limit` request property's max was set to `16.00`
  - …8 more
- **2026-10-25** `852053a38074`: 3 info
  - the `disk_size_mb` request property's min was decreased from `1.00` to `0.00`
  - the `memory_limit_mb` request property's min was decreased from `6.00` to `0.00`
  - the `resources/oneOf[#/components/schemas/ResourcesBody]/memory` request property's min was decreased from `6.00` to `0.00`

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/v1/sandboxes/post.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
