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

# Delete a sandbox

> Synchronous teardown. Returns the sandbox in its final state. An unknown or cross-org sandbox_id returns 404; a sandbox in a state that cannot be deleted right now (for example waking) returns 409.



## OpenAPI

````yaml /api-reference/openapi.yaml delete /v1/sandbox/{sandbox_id}
openapi: 3.1.0
info:
  title: Bonya Compute REST API
  version: 0.1.0
  description: >
    Public REST and WebSocket surface on TApi behind Caddy. Non-2xx responses
    are RFC 9457 application/problem+json with a stable machine-readable code.
    WebSocket endpoints are HTTP GET upgrades; their options travel in the START
    frame, never in query strings.
servers:
  - url: https://api.bonya.ai
    description: Production
security:
  - personalApiKey: []
  - supabaseJwt: []
tags:
  - name: Sandboxes
    description: Create, look up, list, pause, fork, snapshot, and delete sandboxes.
  - name: Snapshots
    description: Named point-in-time copies of a sandbox that new sandboxes can start from.
  - name: Templates
    description: Saved, versioned launch configurations for sandboxes.
  - name: Registry Connections
    description: Credentials for pulling private container images.
  - name: Secrets
    description: Write-only secrets and secret sets injected into sandboxes and jobs.
  - name: Previews
    description: Expose a sandbox port as an HTTPS URL.
  - name: Exec
    description: Run a command in a sandbox, buffered or over a TTY.
  - name: Sessions
    description: Named, persistent command sessions that outlive a connection.
  - name: Filesystem
    description: Read, write, and manage files inside a sandbox.
  - name: Jobs
    description: Managed, tracked runs of a command or script.
  - name: Job Schedules
    description: Cron, interval, or one-shot timing wrapped around a job.
  - name: Organizations
    description: Organization membership, administration and usage reporting.
  - name: Invitations
    description: Invite members to an organization and accept invitations.
  - name: API Keys
    description: Personal API key management.
  - name: Device Login
    description: Browser-based login for the CLI.
paths:
  /v1/sandbox/{sandbox_id}:
    parameters:
      - $ref: '#/components/parameters/SandboxID'
      - $ref: '#/components/parameters/OrganizationHeader'
    delete:
      tags:
        - Sandboxes
      summary: Delete a sandbox
      description: >-
        Synchronous teardown. Returns the sandbox in its final state. An unknown
        or cross-org sandbox_id returns 404; a sandbox in a state that cannot be
        deleted right now (for example waking) returns 409.
      operationId: deleteSandbox
      responses:
        '200':
          description: Deleted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Sandbox'
        default:
          $ref: '#/components/responses/Problem'
components:
  parameters:
    SandboxID:
      name: sandbox_id
      in: path
      required: true
      schema:
        type: string
    OrganizationHeader:
      name: X-Bonya-Organization-ID
      in: header
      required: false
      schema:
        type: string
      description: >
        Org context. Omitted means the caller's personal organization. A
        well-formed non-member org is 404; malformed is 400.
  schemas:
    Sandbox:
      type: object
      required:
        - id
        - name
        - organization_id
        - template_version
        - state
        - generation
        - vcpus
        - memory_mib
        - user_layer_bytes
        - created_at
        - network
        - network_revision
        - network_applied_revision
      properties:
        id:
          type: string
          description: Sandbox id, for example sb-bpyk22c3ei3hfx.
        name:
          type: string
        organization_id:
          type: string
        template_version:
          type: string
        state:
          $ref: '#/components/schemas/SandboxState'
        generation:
          type: integer
        vcpus:
          type: integer
        memory_mib:
          type: integer
        user_layer_bytes:
          type: integer
        failure_reason:
          type: string
        created_at:
          type: string
          format: date-time
        started_at:
          type: string
          format: date-time
        deleted_at:
          type: string
          format: date-time
        parent_snapshot_id:
          type: string
          description: The named snapshot it was created from.
        forked_from_sandbox_id:
          type: string
        pause_source:
          type: string
          description: 'Who paused it: idle, requested, memory_pressure.'
        network:
          $ref: '#/components/schemas/NetworkPolicy'
        network_revision:
          type: integer
        network_applied_revision:
          type: integer
          description: >-
            Revision the node is known to enforce; below network_revision until
            a change is applied.
        image:
          $ref: '#/components/schemas/ImageRef'
        gpu:
          $ref: '#/components/schemas/GpuRequest'
        exec_capability_jws:
          type: string
          description: Exec capability token, present on responses that carry one.
    SandboxState:
      type: string
      enum:
        - creating
        - running
        - warm
        - cooling
        - cold
        - waking
        - deleting
        - deleted
        - failed
        - lost
    NetworkPolicy:
      type: object
      additionalProperties: false
      required:
        - mode
      properties:
        mode:
          type: string
          enum:
            - open
            - allowlist
            - airgap
          default: open
          description: >-
            open is unrestricted egress; allowlist allows only the listed
            destinations; airgap has no network.
        allow:
          type: array
          maxItems: 64
          items:
            $ref: '#/components/schemas/NetworkRule'
      allOf:
        - if:
            properties:
              mode:
                const: allowlist
          then:
            required:
              - allow
            properties:
              allow:
                minItems: 1
          else:
            properties:
              allow:
                maxItems: 0
    ImageRef:
      type: object
      required:
        - reference
      properties:
        reference:
          type: string
        digest:
          type: string
    GpuRequest:
      type: object
      required:
        - type
        - count
      properties:
        type:
          type: string
        count:
          type: integer
          minimum: 1
    Problem:
      type: object
      required:
        - type
        - title
        - status
        - code
      properties:
        type:
          type: string
        title:
          type: string
        status:
          type: integer
        code:
          type: string
        detail:
          type: string
    NetworkRule:
      type: object
      additionalProperties: false
      description: Exactly one of domain or cidr. Per-rule ports are not supported yet.
      properties:
        domain:
          type: string
          description: A DNS name such as pypi.org or *.pythonhosted.org.
        cidr:
          type: string
  responses:
    Problem:
      description: RFC 9457 problem
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
  securitySchemes:
    personalApiKey:
      type: http
      scheme: bearer
      description: >-
        Personal byk_ API key; user-principal, resolved to a tenant by org
        context.
    supabaseJwt:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Supabase-issued session JWT; required for org, invite, and key
        management.

````

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