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

# Change the size

> Turn automatic sizing on, or resize a running sandbox to a named size.

REQ-141. `{"size": "auto"}` (optional `min_size`, default small,
and `max_size`, default large) turns automatic sizing on; the
sandbox must hold a size inside the range. A named size turns it
off and resizes the running sandbox to that size, live: a grow
needs room on its host (409 `node_full` otherwise) and a shrink
never cuts into memory the guest uses (409 `resize_refused`, the
message naming the smallest safe size). A RAM shrink can take a
few minutes; the answer comes when it has landed, with what the
sandbox holds (a partial change shows the size it got to). Free may set
`max_size` at most `medium` (402 `plan_required`). Audited as
`sandbox.size`; each change the host makes is a `sandbox.resized`
event (GET /v1/sandboxes/{id}/scaling).



## OpenAPI

````yaml /api-reference/openapi.yaml patch /v1/sandboxes/{id}/size
openapi: 3.1.0
info:
  title: Zode API
  version: 0.1.0
  description: Sandboxes for coding agents. Every route takes an API key as a bearer token.
servers:
  - url: https://api.zode.dev
security:
  - bearerAuth: []
tags:
  - name: Sandboxes
  - name: Port previews
  - name: Commands
  - name: Browser and desktop
  - name: Snapshots
  - name: Images
  - name: Environments
  - name: Networking
  - name: Outbound routes and exits
  - name: Flight recorder
  - name: Attestation
  - name: Agents
  - name: Proxying
  - name: Webhooks
  - name: OpenTelemetry
  - name: Alerts
  - name: CI
  - name: Usage and billing
  - name: Workspace
  - name: Platform
paths:
  /v1/sandboxes/{id}/size:
    parameters:
      - $ref: '#/components/parameters/SandboxID'
    patch:
      tags:
        - Sandboxes
      summary: Change the size
      description: |-
        Turn automatic sizing on, or resize a running sandbox to a named size.

        REQ-141. `{"size": "auto"}` (optional `min_size`, default small,
        and `max_size`, default large) turns automatic sizing on; the
        sandbox must hold a size inside the range. A named size turns it
        off and resizes the running sandbox to that size, live: a grow
        needs room on its host (409 `node_full` otherwise) and a shrink
        never cuts into memory the guest uses (409 `resize_refused`, the
        message naming the smallest safe size). A RAM shrink can take a
        few minutes; the answer comes when it has landed, with what the
        sandbox holds (a partial change shows the size it got to). Free may set
        `max_size` at most `medium` (402 `plan_required`). Audited as
        `sandbox.size`; each change the host makes is a `sandbox.resized`
        event (GET /v1/sandboxes/{id}/scaling).
      operationId: setSandboxSize
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - size
              properties:
                size:
                  type: string
                  example: auto
                  description: '`auto`, or a size name (GET /v1/sizes).'
                min_size:
                  type: string
                  enum:
                    - small
                    - medium
                    - large
                    - xlarge
                  description: With `auto` only.
                max_size:
                  type: string
                  enum:
                    - small
                    - medium
                    - large
                    - xlarge
                  description: With `auto` only.
      responses:
        '200':
          description: The sandbox, with `auto` and what it holds now.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Sandbox'
        '400':
          $ref: '#/components/responses/Error'
        '401':
          $ref: '#/components/responses/Error'
        '402':
          $ref: '#/components/responses/PlanRequired'
        '403':
          $ref: '#/components/responses/Error'
        '404':
          $ref: '#/components/responses/Error'
        '409':
          description: >-
            invalid_state (not running), node_full (the host has no room for
            that size) or resize_refused (a shrink below what the guest uses;
            the message names the smallest safe size).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '501':
          description: feature_unavailable on this host.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: 'node_error: the host did not answer.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'no_capacity: the host is full right now.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  parameters:
    SandboxID:
      name: id
      in: path
      required: true
      schema:
        type: string
        pattern: ^sbx_[a-z2-7]{16}$
  schemas:
    Sandbox:
      type: object
      required:
        - id
        - name
        - status
        - vcpus
        - ram_mb
        - disk_gb
        - region
        - git_repo
        - git_branch
        - pr_number
        - max_cost_micros
        - parent_sandbox_id
        - created_at
        - updated_at
        - deleted_at
        - created_by
      properties:
        id:
          type: string
          example: sbx_ilvsd743b36wqi26
        name:
          type: string
        status:
          $ref: '#/components/schemas/SandboxStatus'
        vcpus:
          type: integer
        ram_mb:
          type: integer
        disk_gb:
          type: integer
        size:
          type: string
          example: medium
          description: >-
            The size's name (GET /v1/sizes); `<vcpus>x<ram GB>` for a shape
            outside the catalogue.
        region:
          type: string
          example: eu-central
        git_repo:
          type: string
        git_branch:
          type: string
        pr_number:
          type:
            - integer
            - 'null'
        max_cost_micros:
          type:
            - integer
            - 'null'
          format: int64
          description: >-
            AI spend cap for this sandbox, in micro-dollars. Counts only AI
            calls made on the workspace's keys through the node's AI proxy, not
            compute or storage. The total is kept in the node daemon's memory,
            so a node daemon restart starts it again from zero. Reaching it
            refuses further AI calls (402 `zode_spend_cap`) and sends
            `spend.cap_reached`; the sandbox keeps running.
        parent_sandbox_id:
          type:
            - string
            - 'null'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          format: date-time
        browser:
          type: boolean
          description: Chrome with CDP is on.
        desktop:
          type: boolean
          description: The Linux desktop is on.
        feature_error:
          type: string
          description: >-
            Only on a create or fork whose browser or desktop could not be
            switched on; the sandbox was made.
        auto:
          description: |
            The automatic sizing range, null for a fixed size. With it set,
            `size` reads `auto` and `vcpus` and `ram_mb` are what the sandbox
            holds right now.
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/AutoSize'
        created_by:
          description: >-
            The member who created or forked it; null for sandboxes made before
            this was recorded.
          oneOf:
            - type: 'null'
            - type: object
              required:
                - member_id
                - email
              properties:
                member_id:
                  type: string
                  example: mem_ilvsd743b36wqi26
                email:
                  type: string
                  description: Kept after the member leaves the workspace.
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              examples:
                - not_found
                - rate_limited
                - plan_required
              description: >
                Stable machine code; branch on it rather than on `message`.

                Deliberately not a closed enum: new codes are added over time,

                so treat an unknown code by its HTTP status. The codes in use,

                by status (a few appear under two):


                - 400: `bad_request` (malformed JSON or unknown field),
                `above_workspace` (a sandbox asked for more GitHub access than
                its workspace allows),
                  `invalid_link` (a mailed link that is bad, used or expired),
                  `invalid_request`, `bad_signature`, `confirm_required`,
                  `key_rejected` (the provider refused the API key when it was checked),
                  `bot_check_failed` (Turnstile token missing or refused),
                  `default_environment`, `email_not_allowed`,
                  `endpoint_required`, `invalid_code`, `invalid_email`,
                  `invalid_image`, `invalid_name`, `invalid_nonce`,
                  `invalid_state`, `invalid_token`, `not_admin`,
                  `order_mismatch`, `org_required`, `owner_cannot_leave`,
                  `password_too_long`, `password_too_short`,
                  `personal_workspace`, `same_email`, `secret_unsupported`,
                  `self`, `too_many`, `unknown_channel`,
                  `unknown_environment`, `unknown_installation`,
                  `url_not_allowed`, `use_transfer`, `invalid_rule`,
                  `mesh_credential_refused`
                - 401: `unauthorized`, `invalid_credentials`, `bad_signature`,
                  `passkey_refused`, `no_pending_sign_in`,
                  `recovery_code_refused`, `job_token_expired`
                - 402: `plan_required` (the plan does not include it),
                  `credit_exhausted` (no credit left and no card on file)
                - 403: `forbidden` (the role may not), `token_scope`, `csrf`,
                  `cors`, `email_unverified`, `installation_not_yours`,
                  `no_user`, `not_yours`, `subscriptions_off`,
                  `wrong_account`, `wrong_password`, `step_up_required`,
                  `workspace_suspended` (a platform admin suspended it)
                  (prove a passkey with /v1/auth/step-up, then retry),
                  `reauth_required` (sign in again or confirm your password
                  with /v1/auth/reauth, then retry; `error.password` says
                  whether the account has one),
                  `wrong_node` (a node's token naming another node),
                  `not_in_pool` (node heartbeat)
                - 404: `not_found`, `code_not_found`, `invalid_invite`,
                  `not_configured`, `unknown_node`, `unknown_org`,
                  `unknown_sandbox`
                - 409: `invalid_state` (wrong sandbox status),
                  `concurrency_limit` (plan's running-sandbox cap),
                  `ci_limit` (plan's CI limit on machines running at once:
                  the job waits; shard workers queue),
                  `daily_cap_reached` (workspace daily spend cap),
                  `limit_reached`, `name_taken`, `node_full`, `not_running`,
                  `browser_off`, `desktop_off`, `already_deleted`,
                  `resize_refused` (a shrink would cut into memory the guest
                  uses, or the guest is not reporting),
                  `already_granted`, `already_linked`, `already_member`, `already_on_plan`,
                  `billing_not_open`, `checkout_required`,
                  `code_not_applicable`, `code_redeemed`, `code_taken`,
                  `endpoint_disabled`, `installation_taken`,
                  `invite_pending`, `last_method`, `no_sandbox`,
                  `not_placed`, `not_waiting`, `sandboxes_running`,
                  `sole_owner`, `too_many_keys`, `trial_unavailable`,
                  `trial_used`, `default_group`, `in_use`, `network_in_use`,
                  `no_passkeys`, `too_many_passkeys`, `passkey_exists`,
                  `last_passkey`, `two_step_off`, `use_passkey`,
                  `no_password`,
                  `version_taken` (official image release), `busy`,
                  `invocation_taken`, `invocation_done` (zode-ci results),
                  `tmux_required` (one-click sign-in needs tmux in the
                  sandbox's image), `enforce_not_available` (test selection),
                  `enforce_not_ready` (Enforce before 200 clean Shadow runs),
                  `not_a_proof_repo` (Enforce bypass outside the proof list),
                  `node_id_taken` (node heartbeat), `shard_limit`,
                  `runner_not_running`, `memory_fork_unavailable` (CI
                  test-shard workers), `failure_snapshot_unavailable`,
                  `failure_snapshot_limit` (CI failure snapshots),
                  `no_change`, `already_suspended`,
                  `not_suspended` (platform admin controls),
                  `egress_unavailable` (outbound routes no host can enforce yet),
                  `memory_full` (a repository's agent memory is at its note limit)
                - 405: `method_not_allowed` (the memory door takes POST only)

                - 410: `expired`, `used`, `expired_token`, `expired_invite`,
                  `code_expired`, `code_used_up`
                - 413: `too_large`

                - 415: `unsupported_media_type`

                - 426: `upgrade_required` (an exit agent on another protocol)

                - 429: `rate_limited` (see the RateLimited response),
                  `too_many_viewers` (desktop viewers)
                - 500: `internal`

                - 501 (this server or host cannot do it yet):
                  `feature_unavailable`, `attach_unavailable`,
                  `exec_unavailable`, `snapshots_unavailable`,
                  `security_groups_unavailable`,
                  `private_networking_unavailable`,
                  `images_unavailable`, `recorder_unavailable`,
                  `attestation_unavailable`, `disk_fork_unavailable`,
                  `ports_unavailable`
                - 502: `node_error`, `billing_error` (Stripe unreadable),
                `helper_failed` (the throwaway sign-in
                  sandbox did not start), `host_unreachable`, `key_destroy_failed`,
                  `provider_error`, `github_error`, `recorder_error`, `node_unreachable`,
                  `exit_failed` (the exit could not reach the site)
                - 503: `no_capacity`, `node_busy`, `unhealthy`,
                `alerts_unavailable`, `memory_unavailable`,
                  `auth_unavailable`, `ci_unavailable`, `email_unavailable`,
                  `ingest_unavailable`, `secrets_unavailable`, `egress_unavailable`,
                  `webhook_not_ready`, `official_images_off`,
                  `ci_tests_unavailable`, `pool_unavailable`, `github_unavailable`,
                  `exit_offline` (no agent is linked for the exit)

                The device-flow code and token endpoints answer 400 in the

                RFC 6749/8628 shape instead (OAuthError).
            message:
              type: string
    SandboxStatus:
      type: string
      enum:
        - creating
        - running
        - stopping
        - stopped
        - starting
        - deleting
        - deleted
        - error
    AutoSize:
      type: object
      required:
        - min_size
        - max_size
        - min_vcpus
        - max_vcpus
        - min_ram_mb
        - max_ram_mb
      properties:
        min_size:
          type: string
          example: small
        max_size:
          type: string
          example: large
        min_vcpus:
          type: integer
          example: 2
        max_vcpus:
          type: integer
          example: 8
        min_ram_mb:
          type: integer
          example: 4096
        max_ram_mb:
          type: integer
          example: 16384
  responses:
    Error:
      description: Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    PlanRequired:
      description: |
        `plan_required`: the workspace's plan does not include this (the
        desktop comes with Pro and up, audit CSV export with Team and up).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: zode_tok_<64 hex chars>
      description: >-
        An API key (`zode_tok_...`). Create one in the console under API keys
        (https://console.zode.dev/tokens), or with `zode login`.

````

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