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

> ## Agent Instructions
> To set up offstage cloud from a coding agent, read https://api.offstage.cloud/SKILL.md and follow it. The whole API guide is one file at https://api.offstage.cloud/llms.txt.

# Write a file

> Writes the raw request body to `path` under the sandbox root, creating its directories and replacing any existing file (it never appends). A file may be up to 2 GiB, refused on the declared `content-length` before any upload. The body goes on to the Mac in 4 MiB parts as it arrives, and the answer comes once all of it is written there, so a large write takes as long as its upload; the whole body must arrive within 40 minutes. A write over 4 MiB keeps its parts in a hidden `.offstage-upload-…` folder at the sandbox root and joins them into the file once the last part is in. A team may have 24 MiB of file writes held at once, and a write holds at most 8 MiB of it however large it is; a write past that is 429 `uploads-busy`.



## OpenAPI

````yaml /openapi.json put /v1/sandboxes/{sandboxId}/files
openapi: 3.1.0
info:
  title: offstage cloud API
  version: 0.1.0
  summary: Real Macs for AI agents and CI, over HTTP.
  description: >-
    macOS sandboxes driven one call at a time, and fire-and-forget CI tasks, on
    Apple silicon Macs running macOS 27.


    - **Auth.** `Authorization: Bearer sk_offstage_…` (a team API key; one made
    before 2026-10-29 starts with `oc_live_` and still works), or the console's
    `oc_session` cookie. Operations marked `x-console-only: true` take only the
    cookie; an API key gets 403 `console-only`. A cookie request that changes
    something must come from this origin.

    - **Errors.** Every failure is `{"error": {"code", "message", "fix"?,
    "requestId"}}`. Switch on `code`; `fix`, when present, says what to do. Any
    operation can also answer 500 `internal` (a bug; quote the `requestId`), and
    an unknown route is 404 `no-such-route`.

    - **Request ids.** Every response carries an `x-request-id` header, repeated
    as `requestId` in error bodies.

    - **Units.** Times are Unix milliseconds, and durations end in `Ms`. Money
    is US dollars as numbers, exact to the micro-dollar (`costUsd`).

    - **Ids** are prefixed: `sbx_` sandbox, `cmd_` command, `run_` agent run,
    `task_` task, `key_` API key, `req_` request, `team_`, `usr_`, `box_` (a
    fleet Mac), `inv_`.

    - **Lists** are newest first. Pass the previous page's `nextCursor` as
    `cursor`; it is null on the last page.

    - **Bodies.** JSON, except file writes, which send raw bytes. Request
    schemas with `additionalProperties: false` refuse an unknown field with 400
    `unknown-field`.

    - **Limits.** A team may send 120 requests a minute, whatever key or session
    it uses. Every request also counts against its client address: 600 a minute,
    and far fewer on the routes that need no credential (5 sign-ups an hour, 20
    sign-ins and 20 verifications a minute). Over a window is 429 `rate-limit`
    with a `Retry-After` header.

    - **Verification.** A new account's team can sign in and look around, but
    cannot create sandboxes, tasks or API keys (403 `email-unverified`) until
    its owner opens the link emailed at signup.

    - **Holds.** No request is held longer than about 50 s, so default client
    timeouts and 60 s proxy idle timeouts are fine, except large files: a write
    answers once its upload is done, and a read streams for as long as the Mac
    takes to send it.


    The prose reference, with examples, is
    `https://api.offstage.cloud/llms.txt`. The agent setup guide is
    `https://api.offstage.cloud/SKILL.md`.
servers:
  - url: https://api.offstage.cloud
security:
  - apiKey: []
  - consoleSession: []
tags:
  - name: Sandboxes
    description: >-
      A Mac slot (a macOS user account) held for you: run commands, move files,
      take screenshots.
  - name: Tasks
    description: >-
      Fire-and-forget macOS work: clone a public repo, run a command, collect
      artifacts.
  - name: Recordings
    description: >-
      What a gui sandbox or gui task showed and did, kept by the plane: live
      while it runs, a replay after. Open one in the console at `/r/{id}`.
  - name: Capacity
    description: What the fleet can take right now, and whether the plane is up.
  - name: Billing
    description: The price, usage, the bill, the budget and the card.
  - name: Account
    description: Signing in, the team, its members and its API keys.
  - name: GitHub
    description: >-
      GitHub Actions jobs on offstage Macs: connect an organization in the
      console, then `runs-on: offstage-macos`.
  - name: Secrets
    description: Write-only team credentials selected by workload name.
paths:
  /v1/sandboxes/{sandboxId}/files:
    put:
      tags:
        - Sandboxes
      summary: Write a file
      description: >-
        Writes the raw request body to `path` under the sandbox root, creating
        its directories and replacing any existing file (it never appends). A
        file may be up to 2 GiB, refused on the declared `content-length` before
        any upload. The body goes on to the Mac in 4 MiB parts as it arrives,
        and the answer comes once all of it is written there, so a large write
        takes as long as its upload; the whole body must arrive within 40
        minutes. A write over 4 MiB keeps its parts in a hidden
        `.offstage-upload-…` folder at the sandbox root and joins them into the
        file once the last part is in. A team may have 24 MiB of file writes
        held at once, and a write holds at most 8 MiB of it however large it is;
        a write past that is 429 `uploads-busy`.
      operationId: writeFile
      parameters:
        - $ref: '#/components/parameters/SandboxId'
        - $ref: '#/components/parameters/FilePath'
      requestBody:
        required: false
        description: >-
          The file's bytes, sent as-is. Any `content-type` is accepted; an empty
          body writes an empty file.
        content:
          application/octet-stream:
            schema:
              type: string
              format: binary
      responses:
        '200':
          description: The file was written.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileWritten'
        '400':
          description: >-
            `bad-path`: `path` is missing, absolute, contains `..`, or uses
            characters other than letters, digits, `.`, `_`, `-` and `/`.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: >-
            `unauthorized`: no credential, an `Authorization` header that is not
            `Bearer …`, a value that is not an `sk_offstage_` (or older
            `oc_live_`) key, a revoked or unknown key, or a box token. The
            message says which.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >-
            `forbidden`: a cookie-authenticated request that changes something
            came from another origin.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: '`not-found`: no such sandbox, or it belongs to another team.'
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: >-
            `body-timeout`: the whole body did not arrive within 40 minutes. It
            arrives only as fast as the Mac takes its parts. The connection is
            closed; send it again, smaller, or have the Mac download the file
            with `curl -fLO`.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: >-
            `sandbox-not-ready`: the sandbox was still `pending` after waiting
            30 s for a slot; the op never ran, so retry, or GET the sandbox
            until it is `ready`. `sandbox-closed`: the sandbox has closed; the
            message gives the reason. `op-failed`: the Mac reported an error;
            the message starts with the Mac's own code. `sandbox-busy` means 16
            ops were running in the sandbox and 16 more waiting for a place, so
            this one was not taken: retry once some end.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: '`file-too-large`: the body is over 2 GiB (2,147,483,648 bytes).'
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: >-
            `rate-limit`: this team has sent more than 120 requests in the last
            60 s, or this client address more than 600; `Retry-After` gives the
            seconds left in the window. `uploads-busy`: the plane is already
            taking in as many file writes as it holds at once, from this team
            (24 MiB held, at most 8 MiB per write) or from every team together;
            the message says which. Send it again once the team's other writes
            finish.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
            Retry-After:
              schema:
                type: string
              description: >-
                Seconds to wait before sending it again: the seconds left in the
                window for `rate-limit`, 1 for `uploads-busy`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '504':
          description: >-
            `op-timeout`: the Mac did not answer within the op's deadline (a
            command's `timeoutMs` plus 30 s; 90 s for each 4 MiB part of a file
            read or write, or a screenshot), counted from when it took the op;
            or no place freed in the sandbox for the op within that deadline,
            and it never ran. GET the sandbox: if it closed as `box-lost`, start
            over; otherwise retry.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - apiKey: []
        - consoleSession: []
components:
  parameters:
    SandboxId:
      name: sandboxId
      in: path
      required: true
      description: A sandbox id, `sbx_…`.
      schema:
        type: string
    FilePath:
      name: path
      in: query
      required: true
      description: >-
        Relative to the sandbox root (`/Users/<slot>/offstage-sandbox/<sandbox
        id>`): letters, digits, `.`, `_`, `-` and `/`, no `..` segment, no
        leading `/` or `~`, at most 1024 characters. `.` segments and repeated
        slashes are normalized away.
      schema:
        type: string
        minLength: 1
        maxLength: 1024
        pattern: ^(?!/)(?!(.*/)?\.\.(/|$))[A-Za-z0-9._/-]+$
  headers:
    RequestId:
      description: This request's id, `req_…`. Quote it when asking for help.
      required: true
      schema:
        type: string
        pattern: ^req_
  schemas:
    FileWritten:
      type: object
      properties:
        path:
          type: string
          description: The path as the plane normalized it (`./a//b` becomes `a/b`).
        bytes:
          type: integer
          description: How many bytes were written.
          minimum: 0
      required:
        - path
        - bytes
      additionalProperties: false
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: >-
                Stable and machine-readable, like `sandbox-closed`. Switch on
                this, not on the message.
            message:
              type: string
              description: What went wrong, for a person.
            fix:
              type: string
              description: What to do about it, when there is something to do.
            requestId:
              type: string
              description: >-
                The same as the `x-request-id` header. Quote it when asking for
                help.
              pattern: ^req_
          required:
            - code
            - message
            - requestId
          additionalProperties: false
      required:
        - error
      additionalProperties: false
      description: >-
        The one error envelope: every 4xx and 5xx the plane itself sends. A
        proxy in front of it may send a 5xx whose body is not JSON.
      examples:
        - error:
            code: sandbox-closed
            message: sandbox sbx_mh3k2f9aQ1xYz0aBcDeFgHiJ is closed (idle)
            fix: create a new sandbox
            requestId: req_mh3k2f9aQ1xYz0aBcDeFgHiJ
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: >-
        A team API key, `sk_offstage_…`, created in the console. Everything it
        touches belongs to its team.
    consoleSession:
      type: apiKey
      in: cookie
      name: oc_session
      description: >-
        The console's session cookie (httpOnly, SameSite=Lax, 30 days), set by
        `signup` and `login`.

````

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