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

# Create a sandbox from a template



## OpenAPI

````yaml /openapi.json post /sandboxes
openapi: 3.1.0
info:
  title: Styne sandbox API
  version: 0.1.0
  description: >-
    Isolated Linux sandboxes for AI agents: create from a template, run
    commands, files, fork, snapshots, pause and resume. The wire contract is the
    E2B API, so an unmodified E2B SDK works.
servers:
  - url: https://api.styne.ai
security:
  - bearerAuth: []
tags:
  - name: Sandboxes
    externalDocs:
      url: https://docs.styne.ai/quickstart
  - name: Templates
    externalDocs:
      url: https://docs.styne.ai/guide-templates
  - name: Run commands
    externalDocs:
      url: https://docs.styne.ai/exec
  - name: Files
    externalDocs:
      url: https://docs.styne.ai/files
  - name: Fork
    externalDocs:
      url: https://docs.styne.ai/fork
  - name: Snapshots
    externalDocs:
      url: https://docs.styne.ai/snapshots
  - name: Volumes
    externalDocs:
      url: https://docs.styne.ai/volumes
  - name: Logs and metrics
    externalDocs:
      url: https://docs.styne.ai/observability
  - name: Timeouts, pause and resume
    externalDocs:
      url: https://docs.styne.ai/pause-tiers
  - name: Plans and billing
    externalDocs:
      url: https://docs.styne.ai/billing
  - name: Agent sign-up
    externalDocs:
      url: https://docs.styne.ai/agent-signup
  - name: Browsers
    externalDocs:
      url: https://docs.styne.ai/browsers
  - name: Browser profiles
    externalDocs:
      url: https://docs.styne.ai/profiles
  - name: Login vault
    externalDocs:
      url: https://docs.styne.ai/vault
  - name: Ports and preview URLs
    externalDocs:
      url: https://docs.styne.ai/ports
  - name: SSH and port forwarding
    externalDocs:
      url: https://docs.styne.ai/ssh
  - name: CI runners
    externalDocs:
      url: https://docs.styne.ai/ci
  - name: Run a coding agent in a sandbox
    externalDocs:
      url: https://docs.styne.ai/agents
  - name: State store
    externalDocs:
      url: https://docs.styne.ai/state
  - name: Calls between sandboxes
    externalDocs:
      url: https://docs.styne.ai/calls
  - name: Wake triggers and schedules
    externalDocs:
      url: https://docs.styne.ai/wake-triggers
  - name: Checkpoints and rewind
    externalDocs:
      url: https://docs.styne.ai/checkpoints
  - name: Container images
    externalDocs:
      url: https://docs.styne.ai/images
paths:
  /sandboxes:
    post:
      tags:
        - Sandboxes
      summary: Create a sandbox from a template
      operationId: sandboxes.create
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: >-
                Create a sandbox. Name a template (templateID), a saved snapshot
                (snapshot) or a size; with none of them the default size is
                used.
              properties:
                templateID:
                  type: string
                  description: >-
                    Template id or alias from GET /templates, for example base,
                    code, small, large or browser.
                snapshot:
                  type: string
                  description: >-
                    Name of a saved snapshot of your account to start from;
                    replaces templateID.
                size:
                  type: string
                  description: The standard image at this size; replaces templateID.
                  enum:
                    - small
                    - default
                    - large
                    - xlarge
                image:
                  type: string
                  description: >-
                    A container image to start from, for example alpine,
                    python:3.12-slim or ghcr.io/org/app:tag; excludes templateID
                    and snapshot. It starts on a node that holds a prepared
                    build of the image; an image nobody prepared is a 404.
                timeout:
                  type: integer
                  description: Seconds until the sandbox times out.
                idleTimeout:
                  type: integer
                  minimum: 0
                  maximum: 3600
                  description: >-
                    Seconds without a call or connection after which the sandbox
                    sleeps even if a process runs inside it; it wakes on the
                    next call. 0 or absent: it sleeps only when nothing of yours
                    runs inside.
                autoPause:
                  type: boolean
                  description: Pause instead of kill when the timeout is reached.
                autoResume:
                  description: >-
                    Resume a paused sandbox on the next request: true, or
                    {"enabled": true} as the SDKs send it.
                  oneOf:
                    - type: boolean
                    - type: object
                      properties:
                        enabled:
                          type: boolean
                      required:
                        - enabled
                lifecycle:
                  type: object
                  description: What happens at the timeout.
                  properties:
                    onTimeout:
                      type: string
                      description: kill or pause.
                      enum:
                        - kill
                        - pause
                    autoResume:
                      type: boolean
                      description: Resume on the next request after a pause.
                secure:
                  type: boolean
                  description: Require the access token on every sandbox call.
                allow_internet_access:
                  type: boolean
                  description: >-
                    false blocks outbound internet access from the sandbox.
                    Snake case, as the E2B SDK sends it.
                network:
                  type: object
                  description: Network rules.
                  properties:
                    allowPublicTraffic:
                      type: boolean
                      description: Serve the sandbox ports without the traffic token.
                    allowOut:
                      type: array
                      description: Outbound destinations allowed.
                      items:
                        type: string
                    denyOut:
                      type: array
                      description: Outbound destinations blocked.
                      items:
                        type: string
                    maskRequestHost:
                      type: string
                      description: Host header sent to the sandbox port.
                metadata:
                  type: object
                  description: String keys and values.
                  additionalProperties:
                    type: string
                envVars:
                  type: object
                  description: Environment variables set in every command of the sandbox.
                  additionalProperties:
                    type: string
                environment:
                  type: string
                  description: >-
                    Stored environment to start from; the account default when
                    left out.
                vcpus:
                  type: integer
                  description: >-
                    vCPUs the sandbox needs; a request above the template size
                    is refused.
                memory_mib:
                  type: integer
                  description: >-
                    Memory in MiB the sandbox needs; a request above the
                    template size is refused.
                volumeMounts:
                  type: array
                  description: >-
                    Volumes of your account to mount, by name or id. The sandbox
                    runs on the node that keeps them; see Volumes.
                  items:
                    type: object
                    properties:
                      name:
                        type: string
                        description: Volume name or id.
                      path:
                        type: string
                        description: Mount path inside the sandbox.
                      readOnly:
                        type: boolean
                        description: Mount read-only.
                    required:
                      - name
                      - path
      responses:
        2XX:
          description: >-
            Success. The answer is described on
            https://docs.styne.ai/quickstart.
        default:
          description: An error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      externalDocs:
        description: Sandboxes
        url: https://docs.styne.ai/quickstart
components:
  schemas:
    Error:
      type: object
      description: >-
        Every error answer has this shape; the codes are listed on the errors
        page.
      properties:
        code:
          type: integer
          description: The HTTP status.
        error_code:
          type: string
          description: A stable machine-readable code, for example free_tier_limit.
        message:
          type: string
          description: What happened and what to do, in plain words.
        origin:
          type: string
          description: >-
            Where the fault came from, for example client, customer_limit or
            infrastructure.
        request_id:
          type: string
          description: Quote it to support; the same value is in the x-request-id header.
      required:
        - code
        - message
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Your Styne API key: Authorization: Bearer $STYNE_API_KEY.'

````

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