> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fibre.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a sandbox

> Start a sandbox and answer once it is running. With no body, it runs Fibre's default image on the `standard` runtime and can run commands at once.

Send an `Idempotency-Key` header to make retries safe: a repeat with the same key within 24 hours returns the first sandbox instead of creating another.

To start from a snapshot, send `snapshot`; only `lifetime_sec`, `idle_timeout_sec` and `labels` may be set with it.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/sandboxes
openapi: 3.1.0
info:
  title: Fibre API
  version: 0.2.0
  description: >-
    Sandboxes for agents and the code they write. Authenticate with
    `Authorization: Bearer <API key>`.
servers:
  - url: https://api.fibre.dev
security:
  - bearer: []
tags:
  - name: Sandboxes
    description: >-
      Create, find, change and delete sandboxes, run a command and wait, and
      save a sandbox's files as an image. Guide: [create and
      configure](/sandboxes/overview).
  - name: Commands
    description: >-
      Run commands in the background: stream their output, write to their input,
      stop them, keep servers running across sleep. Guide: [run
      commands](/sandboxes/running-commands).
  - name: Files
    description: >-
      Read, write, list, inspect and delete a sandbox's files. The body is the
      file's bytes; the path is a query parameter. Guide:
      [files](/sandboxes/files).
  - name: Browser and desktop
    description: >-
      Links to a sandbox's browser (for Playwright, Puppeteer or any DevTools
      client, and a live view) and to its desktop. Guides:
      [browser](/connect/browser), [desktop](/connect/desktop).
  - name: Snapshots
    description: >-
      Take a snapshot of a running sandbox, its whole state with memory, and
      start new sandboxes from it, already running. Each snapshot answers its
      size and what it costs a month. Guide: [snapshots](/setup/snapshots).
  - name: Secrets
    description: >-
      Store secrets, encrypted, and give them to sandboxes by name: to one
      command, or to a whole sandbox. Values are write-only: once set, only the
      name, version and times come back. Guide: [secrets](/production/secrets).
  - name: API keys
    description: >-
      Create keys limited to some areas, one sandbox or a lifetime; list and
      revoke them. Guide: [API keys](/get-started/api-keys).
  - name: Webhooks
    description: >-
      Signed notifications when sandboxes start, sleep, crash or are deleted,
      and when builds finish. Guide: [webhooks](/production/webhooks).
  - name: Billing
    description: >-
      Spend, plan, credit, limits and the ledger; links to pay. Guide: [usage
      and billing](/production/usage).
  - name: Pricing
    description: Sizes and their prices, plans and storage, without authentication.
paths:
  /v1/sandboxes:
    post:
      tags:
        - Sandboxes
      summary: Create a sandbox
      description: >-
        Start a sandbox and answer once it is running. With no body, it runs
        Fibre's default image on the `standard` runtime and can run commands at
        once.


        Send an `Idempotency-Key` header to make retries safe: a repeat with the
        same key within 24 hours returns the first sandbox instead of creating
        another.


        To start from a snapshot, send `snapshot`; only `lifetime_sec`,
        `idle_timeout_sec` and `labels` may be set with it.
      operationId: create-a-sandbox
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          description: >-
            A key of yours (1 to 255 characters). A repeat with the same key
            within 24 hours returns the first sandbox.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                image:
                  type: string
                  maxLength: 512
                  description: The image it starts from.
                size:
                  type: string
                  enum:
                    - xsmall
                    - small
                    - medium
                    - large
                    - xlarge
                  description: >-
                    `xsmall`, `small`, `medium`, `large` or `xlarge`; `small` if
                    left out.
                cpu_cores:
                  type: number
                  minimum: 0.25
                  maximum: 16
                  description: vCPUs.
                memory_mb:
                  type: integer
                  minimum: 256
                  maximum: 32768
                  description: Memory, in MB.
                env_vars:
                  type: object
                  additionalProperties:
                    type: string
                  description: Environment variables for every command in the sandbox.
                entrypoint:
                  type: array
                  items:
                    type: string
                  description: >-
                    The command it runs as its main program, instead of the
                    image's.
                exposed_port:
                  type: integer
                  minimum: 1
                  maximum: 65535
                  description: The port its `url` serves. 8000 unless set.
                lifetime_sec:
                  type: integer
                  minimum: 60
                  maximum: 315360000
                  description: >-
                    Seconds until it is deleted automatically, counted from now:
                    60 up to 10 years. Left out, the sandbox is kept until you
                    delete it; on PATCH, `null` removes it.
                idle_timeout_sec:
                  type: integer
                  minimum: 0
                  maximum: 86400
                  description: >-
                    Seconds with nothing happening before it sleeps; `0` never
                    sleeps. 300 unless set.
                snapshot:
                  type: string
                  minLength: 1
                  maxLength: 100
                  description: >-
                    The name of a snapshot to start from, already running where
                    it was.
                ready:
                  type: string
                  enum:
                    - port
                    - process
                  description: >-
                    When it counts as running: `process` (as soon as it runs) or
                    `port` (once `exposed_port` answers).
                network:
                  type: object
                  properties:
                    allow:
                      type: array
                      items:
                        type: string
                        maxLength: 255
                      maxItems: 200
                      description: >-
                        Names (`pypi.org`), `*.` suffixes, IPv4 addresses and
                        CIDR ranges it may reach. Up to 200.
                    block:
                      type: boolean
                      description: '`true`: no network at all.'
                  additionalProperties: false
                  description: >-
                    What it can reach: `{"allow": [...]}` for only those names
                    and addresses, `{"block": true}` for nothing. Leave it out
                    for the whole internet.
                runtime:
                  type: string
                  enum:
                    - standard
                    - vm
                  description: >-
                    `standard`, or `vm` (a full virtual machine with its own
                    kernel).
                needs:
                  type: array
                  items:
                    type: string
                    enum:
                      - docker
                      - fuse
                      - cgroups
                      - loop
                      - iptables
                      - browser
                      - desktop
                  maxItems: 7
                  description: >-
                    What it must be able to do: `docker`, `fuse`, `cgroups`,
                    `loop`, `iptables` (these pick `vm`), `browser`, `desktop`.
                init:
                  type: string
                  enum:
                    - systemd
                  description: >-
                    `systemd` when the image's systemd runs as the first process
                    (`vm` only).
                labels:
                  type: object
                  additionalProperties:
                    type: string
                    maxLength: 128
                  propertyNames:
                    pattern: ^[a-z0-9]([a-z0-9._-]{0,61}[a-z0-9])?$
                  description: >-
                    Your own key-value tags, up to 16. Keys: lowercase letters,
                    digits, `.`, `_`, `-`.
                secrets:
                  type: array
                  items:
                    type: string
                    maxLength: 255
                    pattern: ^[A-Z_][A-Z0-9_]*$
                  maxItems: 50
                  description: >-
                    Stored secrets by name, given as environment variables. Up
                    to 50; naming them needs a key with `secrets.read`, and a
                    key bound to one sandbox cannot. In an answer: the names
                    only.
              additionalProperties: false
            example:
              size: small
              lifetime_sec: 3600
              idle_timeout_sec: 300
              labels:
                user: '42'
      responses:
        '201':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    pattern: ^sbx-[0-9a-f]{10}$
                    description: Its ID.
                  status:
                    type: string
                    description: Its current state.
                  image:
                    type:
                      - string
                      - 'null'
                    description: The image it starts from.
                  cpu_cores:
                    type: number
                    description: vCPUs.
                  memory_mb:
                    type: integer
                    description: Memory, in MB.
                  disk_gb:
                    type: integer
                    description: >-
                      Writable disk: xsmall and small 10, medium 20, large 40,
                      xlarge 80
                  runtime:
                    type: string
                    enum:
                      - standard
                      - vm
                    description: >-
                      `standard`, or `vm` (a full virtual machine with its own
                      kernel).
                  init:
                    anyOf:
                      - type: string
                        enum:
                          - systemd
                      - type: 'null'
                    description: systemd as PID 1 (vm only)
                  created_at:
                    type: string
                    format: date-time
                    description: When it was created.
                  expires_at:
                    anyOf:
                      - type: string
                        format: date-time
                      - type: 'null'
                    description: >-
                      When its lifetime ends and it is deleted; null when it has
                      none (kept until deleted)
                  idle_timeout_sec:
                    type: integer
                    description: >-
                      Seconds with nothing happening before it sleeps; `0` never
                      sleeps. 300 unless set.
                  ready:
                    type: string
                    enum:
                      - port
                      - process
                    description: >-
                      When it counts as running: `process` (as soon as it runs)
                      or `port` (once `exposed_port` answers).
                  network:
                    anyOf:
                      - type: object
                        properties: {}
                        additionalProperties: true
                      - type: 'null'
                    description: >-
                      What it can reach: `{"allow": [...]}` for only those names
                      and addresses, `{"block": true}` for nothing. Leave it out
                      for the whole internet.
                  labels:
                    type: object
                    additionalProperties:
                      type: string
                    description: >-
                      Your own key-value tags, up to 16. Keys: lowercase
                      letters, digits, `.`, `_`, `-`.
                  secrets:
                    type: array
                    items:
                      type: string
                    description: >-
                      The stored secrets it gets as environment variables, by
                      name (never their values)
                  hostname:
                    type: string
                    description: Its HTTPS hostname.
                  url:
                    type: string
                    format: uri
                    description: Its public HTTPS address, serving `exposed_port`.
                  runtime_reason:
                    type: string
                    description: >-
                      requested | snapshot | database | init:<init> |
                      needs:<need> | default
                  host_port:
                    type: integer
                    description: Internal.
                  snapshot:
                    type: string
                    description: >-
                      The name of a snapshot to start from, already running
                      where it was.
                  browser:
                    type: object
                    properties:
                      cdp_url:
                        type: string
                        description: >-
                          For a DevTools client (Playwright connectOverCDP,
                          Puppeteer connect); a credential until expires_at
                      live_view_url:
                        type: string
                        description: >-
                          A page that shows the browser and passes on clicks and
                          keys, nothing else
                      expires_at:
                        type: string
                        format: date-time
                        description: >-
                          When its lifetime ends and it is deleted; `null` when
                          it has none (kept until you delete it).
                    required:
                      - cdp_url
                      - live_view_url
                      - expires_at
                    additionalProperties: true
                    description: 'With needs: ["browser"]'
                  desktop_url:
                    type: string
                    description: 'With needs: ["desktop"]: a single-use link to the desktop'
                  desktop_expires_in:
                    type: integer
                    description: Seconds until the unopened desktop link expires.
                required:
                  - id
                  - status
                  - image
                  - cpu_cores
                  - memory_mb
                  - disk_gb
                  - runtime
                  - init
                  - created_at
                  - expires_at
                  - idle_timeout_sec
                  - ready
                  - network
                  - labels
                  - secrets
                  - hostname
                  - url
                  - runtime_reason
                additionalProperties: true
        '400':
          description: >-
            `validation_failed`: The body does not match the route's schema;
            `details` names the fields; `needs_vm`: A listed need (`docker`,
            `fuse`, …) runs only on runtime `vm`, but the runtime is `standard`;
            `init_needs_vm`: `init` (systemd as PID 1) runs only on runtime
            `vm`; `size_too_large`: The requested CPU and memory are larger than
            the largest size; `snapshot_fields_fixed`: A sandbox started from a
            snapshot takes these fields from the snapshot;
            `invalid_idempotency_key`: `Idempotency-Key` must be 1 to 255
            printable characters without spaces
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: >-
            `missing_credentials`, `invalid_api_key`: no key, or a wrong,
            revoked or expired one
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '402':
          description: >-
            `payment_required`: Out of credit: add funds or turn on auto top-up;
            `subscription_required`: Choose a plan or start the trial to run
            sandboxes; `trial_limit`: The trial does not allow this: choose a
            plan
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >-
            `image_not_owned`: The image belongs to another organization;
            `image_access_denied`: The registry refused access to the image:
            check the registry credentials; `insufficient_scope`: The API key's
            scopes do not cover this route; `required` names the scope;
            `key_resource_bound`: The API key is limited to one sandbox or
            service
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: >-
            `image_not_found`: The image does not exist in its registry;
            `snapshot_not_found`: No snapshot with this name in the
            organization; `secret_not_found`: No stored secret with this name:
            set it first (POST /v1/secrets)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: >-
            `idempotency_key_in_progress`: The first request with this
            `Idempotency-Key` is still running: retry later
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: >-
            `idempotency_key_reused`: This `Idempotency-Key` was used with
            another request in the last 24 h: use a new key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: >-
            `sandbox_limit`: The organization keeps as many sandboxes as its
            plan allows, awake or asleep: delete some first; `org_limit`: The
            organization already uses as much of the machines that could run
            this sandbox as one organization may: stop some first
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: >-
            `create_failed`: Creating the sandbox failed and nothing was left
            behind: retry; `no_capacity`: No host has room for this sandbox now:
            retry later; `start_failed`: The sandbox failed to start: check the
            image and its entrypoint
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
          description: What went wrong, for people
        code:
          type: string
          enum:
            - invalid_request
            - unauthorized
            - forbidden
            - not_found
            - conflict
            - payload_too_large
            - rate_limited
            - internal
            - unavailable
            - invalid_json
            - validation_failed
            - missing_credentials
            - invalid_api_key
            - invalid_token
            - invalid_credentials
            - email_taken
            - insufficient_scope
            - key_resource_bound
            - key_broader
            - unknown_scope
            - api_key_not_found
            - key_resource_not_found
            - sandbox_not_found
            - exec_timeout
            - sandbox_limit
            - size_too_large
            - needs_vm
            - init_needs_vm
            - vm_unavailable
            - invalid_cursor
            - invalid_idempotency_key
            - idempotency_key_reused
            - idempotency_key_in_progress
            - runtime_conflict
            - snapshot_fields_fixed
            - create_failed
            - start_failed
            - engine_error
            - no_capacity
            - host_disk_full
            - already_running
            - not_running
            - command_required
            - exec_failed
            - engine_unreachable
            - command_not_found
            - path_required
            - invalid_path
            - file_not_found
            - file_is_directory
            - file_not_directory
            - file_permission_denied
            - file_exists
            - directory_not_empty
            - file_too_large
            - upload_aborted
            - disk_full
            - files_unsupported
            - restart_required
            - secret_not_found
            - snapshot_not_found
            - snapshot_exists
            - snapshot_source_not_found
            - snapshot_source_unsupported
            - snapshot_in_use
            - snapshot_failed
            - snapshot_timeout
            - image_required
            - image_not_owned
            - keep_unavailable
            - desktop_unavailable
            - browser_unavailable
            - browser_unreachable
            - image_registry_refused
            - image_not_found
            - image_access_denied
            - image_too_large
            - image_rate_limited
            - image_pull_failed
            - image_pull_timeout
            - image_ref_mismatch
            - image_ref_conflict
            - build_limit
            - payment_required
            - subscription_required
            - trial_limit
            - spend_limit
            - org_limit
            - billing_error
            - billing_not_configured
            - billing_provider_error
            - invalid_plan
            - invalid_amount
            - webhook_url
          description: 'Stable: programs branch on it'
        request_id:
          type: string
          description: As in the X-Request-Id header
        docs_url:
          type: string
          format: uri
          description: The code's entry in the error list.
      required:
        - error
        - code
        - request_id
        - docs_url
      additionalProperties: true
      description: Every non-2xx answer
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: An API key (fb_live_…)

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.