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

# Upload a file

> Streams the raw request body to the destination path inside the sandbox.

**Body is the file bytes, not JSON, not multipart, not form-data.**

The parent directory must already exist; the server does **not** `mkdir -p`.

Size cap: 50 MB by default (`SANDBOX_MAX_FILE_SIZE_BYTES`). Include
`Content-Length` so oversize uploads are rejected before the body is read.




## OpenAPI

````yaml PUT /sandboxes/{id}/files/{filePath}
openapi: 3.0.3
info:
  title: Brimble Sandbox API
  description: >
    REST API for managing Brimble sandboxes, ephemeral compute environments with

    optional persistent storage. Covers lifecycle (create / pause / resume /
    destroy),

    egress policy, runtime operations (exec, runCode, file upload/download),

    observability (logs, stats), and snapshots.


    ## Conventions


    - **Response envelope:** non-`204` JSON responses use `{ "message": string,
    "data"?: <payload> }`.
      The schemas below describe the **`data`** payload only.
    - **Errors:** every non-2xx response uses `{ "message": string }`. The
    message is
      user-facing.
    - **Async transitions:** pause / resume / destroy return immediately;
      the status change is visible on the next `GET` or in the dashboard.
      **Create is synchronous** — `POST /sandboxes` blocks until `status` is `ready`.
    - **IDs:** every `id` is a 24-char hex string.
  version: 1.0.0
  contact:
    name: Brimble Engineering
    url: https://brimble.io
servers:
  - url: https://sandbox.brimble.io
    description: Production
security:
  - brimbleKey: []
tags:
  - name: Sandboxes
    description: Lifecycle and metadata
  - name: Runtime
    description: Exec, code, files
  - name: Observability
    description: Logs and stats
  - name: Snapshots
    description: Manual & automatic snapshots
  - name: Volumes
    description: >-
      Persistent disks, pre-provisioned independently of sandbox lifecycle, then
      attached to a sandbox or project
paths:
  /sandboxes/{id}/files/{filePath}:
    parameters:
      - $ref: '#/components/parameters/SandboxIdParam'
      - in: path
        name: filePath
        required: true
        schema:
          type: string
        description: >
          Absolute path inside the sandbox, **with literal forward slashes** (do
          not

          URL-encode `/` as `%2F`; the edge proxy will reject `%2F` with a
          generic

          400 before the request reaches the API).


          Example: `tmp/notes.txt` resolves to `/tmp/notes.txt` inside the
          sandbox.
        style: simple
        explode: false
    put:
      tags:
        - Runtime
      summary: Upload a file
      description: >
        Streams the raw request body to the destination path inside the sandbox.


        **Body is the file bytes, not JSON, not multipart, not form-data.**


        The parent directory must already exist; the server does **not** `mkdir
        -p`.


        Size cap: 50 MB by default (`SANDBOX_MAX_FILE_SIZE_BYTES`). Include

        `Content-Length` so oversize uploads are rejected before the body is
        read.
      operationId: putSandboxFile
      requestBody:
        required: true
        content:
          application/octet-stream:
            schema:
              type: string
              format: binary
      responses:
        '204':
          description: File written
        '400':
          $ref: '#/components/responses/BadRequest'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  parameters:
    SandboxIdParam:
      in: path
      name: id
      required: true
      schema:
        type: string
        pattern: ^[a-f0-9]{24}$
      description: 24-char hex id of the sandbox.
  responses:
    BadRequest:
      description: Validation error / invalid state transition
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            invalidId:
              summary: Invalid sandbox id
              value:
                message: Invalid sandbox id
            statusTransition:
              summary: Wrong status
              value:
                message: Sandbox is paused; only ready sandboxes can be paused
            fileNotDir:
              summary: Parent dir missing on upload
              value:
                message: 'Destination directory does not exist: /work'
            duplicateVolumeName:
              summary: Duplicate volume name
              value:
                message: A volume named "node-cache" already exists
            volumeAttached:
              summary: Delete attempted on attached volume
              value:
                message: Volume is attached; detach it before deleting
    Forbidden:
      description: Plan / spending-limit / permission error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            planLimit:
              value:
                message: >-
                  Your plan allows up to 3 sandboxes. Destroy an existing one or
                  upgrade.
            spendingLimit:
              value:
                message: >-
                  Sandbox creation paused, spending limit reached. Raise the
                  limit or wait for the next billing cycle.
            writePerm:
              value:
                message: Permission denied writing to /etc/passwd
            volumeSizeCap:
              summary: Volume size exceeds plan cap
              value:
                message: Your plan allows volumes up to 20GB. Reduce size or upgrade.
            volumeCountCap:
              summary: Volume count exceeds plan cap
              value:
                message: >-
                  Your plan allows up to 2 volumes. Delete an existing one or
                  upgrade.
    NotFound:
      description: >-
        Sandbox or related resource not found (also returned when owned by
        another user)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            sandboxNotFound:
              value:
                message: Sandbox not found
            snapshotNotFound:
              value:
                message: Snapshot not found
            volumeNotFound:
              value:
                message: Volume not found
  schemas:
    ErrorResponse:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          description: Human-readable, user-facing error reason.
  securitySchemes:
    brimbleKey:
      type: apiKey
      in: header
      name: x-brimble-key
      description: |
        Your account-level Brimble API key. Find it in the dashboard under
        your profile drawer → **API key** (click the avatar in the sidebar).
        Available on paid plans only.

````