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

# Replace a sandbox's tags

> Replaces the sandbox's whole tag set; `{}` clears it. Tags are the only thing you can change after create; any other field is rejected. Works on terminated sandboxes too.



## OpenAPI

````yaml /openapi/source/external/sandboxes/sandboxes.json patch /ai/sandboxes/{sandbox_id}
openapi: 3.1.0
info:
  title: Telnyx API
  version: 1.0.0
  description: >-
    Run a container image of your choice on a whole GPU node, each sandbox in
    its own virtual machine, for seconds or indefinitely. Run commands inside
    it, move files in and out, stream its logs, read its metrics, and pay per
    second while it runs.


    ## Preview


    GPU Sandboxes is in an invite-only preview. `GET /ai/sandbox-access` tells
    whether it is enabled for your organization.


    ## Authentication


    All endpoints require a Telnyx API key sent as a Bearer token in the
    `Authorization` header.


    ## Retries


    Every side-effecting endpoint accepts an `Idempotency-Key` header. Send one
    on `POST /ai/sandboxes` and `POST /ai/sandboxes/{sandbox_id}/execs`, so a
    retry after a lost response doesn't start (and bill) a second workload.


    ## Errors


    Errors use the standard Telnyx error body. General errors carry their
    5-digit `code` (e.g. `10009`); Sandboxes-specific errors are identified by
    their name in `title` (e.g. `quota_exceeded`).
  contact:
    email: support@telnyx.com
  x-latency-category: responsive
  x-endpoint-cost: light
servers:
  - url: https://api.telnyx.com/v2
    description: Telnyx API v2
security:
  - bearerAuth: []
tags:
  - name: Sandboxes
    description: >-
      Create, find, wait for, tag and terminate sandboxes, and close the main
      process's stdin.
  - name: Sandbox execs
    description: Run commands in a running sandbox.
  - name: Sandbox files
    description: Read, write, list and delete files inside a running sandbox.
  - name: Sandbox logs
    description: The main process's stored and live output.
  - name: Sandbox metrics
    description: CPU, network, memory, disk and GPU usage.
  - name: Sandbox GPU types
    description: What you can rent, and at what price.
  - name: Sandbox access
    description: Whether Sandboxes is enabled for your organization.
paths:
  /ai/sandboxes/{sandbox_id}:
    patch:
      tags:
        - Sandboxes
      summary: Replace a sandbox's tags
      description: >-
        Replaces the sandbox's whole tag set; `{}` clears it. Tags are the only
        thing you can change after create; any other field is rejected. Works on
        terminated sandboxes too.
      operationId: UpdateSandboxTags
      parameters:
        - description: Sandbox ID (`sb-…`).
          in: path
          name: sandbox_id
          required: true
          schema:
            maxLength: 64
            minLength: 1
            type: string
          example: sb-0192f1c2-7a4b-7c3e-9d1e-2f3a4b5c6d7e
        - description: >-
            Optional client-chosen key (e.g. a UUID, at most 255 characters)
            that makes the call safe to retry. Within 24 h, the same key with
            the same request returns the stored response instead of acting
            twice; the same key with a different request fails with
            `idempotency_key_reused`; a request with a key that's still being
            processed fails with `request_in_progress`.
          in: header
          name: Idempotency-Key
          required: false
          schema:
            maxLength: 255
            minLength: 1
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SandboxUpdateReq'
            example:
              tags:
                project: llm-ft
                stage: eval
      responses:
        '200':
          description: The sandbox with its new tags.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SandboxRespData'
              example:
                data:
                  id: sb-0192f1c2-7a4b-7c3e-9d1e-2f3a4b5c6d7e
                  name: train-run-42
                  tags:
                    project: llm-ft
                    stage: eval
                  state: running
                  ready: true
                  image:
                    ref: ghcr.io/acme/trainer:1.4
                  command:
                    - python
                    - train.py
                  workdir: /app
                  env:
                    EPOCHS: '3'
                  gpu:
                    type: B300
                    count: 8
                  cpu: 192
                  memory_mib: 2097152
                  disk_gib: 8192
                  timeout: 36000
                  idle_timeout: null
                  queue_timeout: 1800
                  network_mode: public
                  cidr_allowlist: null
                  readiness_probe: null
                  log_bucket: acme-sandbox-logs
                  logs_incomplete: false
                  logs_incomplete_reason: null
                  resolved:
                    image: >-
                      ghcr.io/acme/trainer@sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
                    command:
                      - python
                      - train.py
                    workdir: /app
                  termination_reason: null
                  termination_message: null
                  exit_code: null
                  created_at: '2026-11-13T10:00:00Z'
                  started_at: '2026-11-13T10:01:12Z'
                  terminated_at: null
        '400':
          description: >-
            Validation error: the standard Telnyx validation errors (codes such
            as 10004 missing parameter, 10015 bad request, 10025 invalid string
            length, 10026 invalid type).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
        '401':
          description: Missing or invalid API key (code 10009).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: '10009'
                    title: Authentication failed
                    detail: Could not find any usable credentials in the request.
        '403':
          description: >-
            - `sandboxes_require_verification`: your account isn't fully
            verified.

            - `sandboxes_not_whitelisted`: Sandboxes isn't enabled for your
            organization (invite-only preview); `GET /ai/sandbox-access` tells
            whether it is.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - title: sandboxes_not_whitelisted
                    detail: The organization isn't whitelisted.
        '404':
          description: >-
            Not found (code 10005): the resource doesn't exist or belongs to
            another organization. The detail says what's missing.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: '10005'
                    title: Resource not found
                    detail: Sandbox not found.
        '409':
          description: >-
            - `request_in_progress`: a request with the same `Idempotency-Key`
            is still being processed; retry later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - title: request_in_progress
                    detail: >-
                      A request with this Idempotency-Key is still being
                      processed.
        '422':
          description: >-
            - `idempotency_key_reused`: the same `Idempotency-Key` was sent with
            a different request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - title: idempotency_key_reused
                    detail: This Idempotency-Key was used with a different request.
        '503':
          description: A dependency can't answer right now (code 10037); retry later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: '10037'
                    title: Service unavailable
                    detail: A dependency can't answer right now; retry later.
components:
  schemas:
    SandboxUpdateReq:
      additionalProperties: false
      description: New tags for a sandbox. Nothing else can change after create.
      properties:
        tags:
          additionalProperties:
            type: string
            maxLength: 255
          description: >-
            Replaces the whole tag set; `{}` clears it. Your own key/value
            labels, e.g. `{"project": "llm-ft"}`. At most 20 tags; keys 1–63
            characters, values up to 255. Filter on them with `GET
            /ai/sandboxes?tag[<key>]=<value>`.
          type: object
          maxProperties: 20
          propertyNames:
            minLength: 1
            maxLength: 63
      required:
        - tags
      type: object
    SandboxRespData:
      properties:
        data:
          $ref: '#/components/schemas/Sandbox'
      required:
        - data
      type: object
    TelnyxErrors:
      description: The standard Telnyx error body.
      properties:
        errors:
          description: One or more errors.
          items:
            $ref: '#/components/schemas/TelnyxError'
          type: array
      required:
        - errors
      type: object
    Sandbox:
      description: >-
        A sandbox: one container image running in its own virtual machine.
        Terminated sandboxes stay readable for at least 30 days.
      properties:
        cidr_allowlist:
          description: Allowed CIDRs, if any.
          items:
            type: string
          type:
            - array
            - 'null'
        command:
          description: As requested.
          items:
            type: string
          type:
            - array
            - 'null'
        cpu:
          description: 'CPU cores: the GPU type''s per-GPU default × the GPU count.'
          type: number
        created_at:
          description: When it was created.
          format: date-time
          type: string
        disk_gib:
          description: >-
            Size in GiB of `/data`, the sandbox's own disk: the GPU type's
            per-GPU default × the GPU count. Writing past it fails with "no
            space left on device", and the sandbox keeps running. Everything
            written outside `/data` counts against the root filesystem's
            separate limit (`root_disk_gib` in the GPU types list); going past
            that ends the sandbox with `disk_limit_exceeded`.
          type: integer
        env:
          additionalProperties:
            type: string
          description: As requested.
          type: object
        exit_code:
          description: The main process's exit code; set whenever it ran.
          type:
            - integer
            - 'null'
        gpu:
          $ref: '#/components/schemas/GpuSpec'
          description: The rented GPU type and count.
        id:
          description: Sandbox ID (`sb-…`).
          type: string
        idle_timeout:
          description: Idle timeout in seconds, if set.
          type:
            - integer
            - 'null'
        image:
          $ref: '#/components/schemas/ImageSpec'
        log_bucket:
          description: >-
            The bucket the sandbox's logs go to, the bucket created for you
            included; `null` until it's known.
          type:
            - string
            - 'null'
        logs_incomplete:
          description: Some output is permanently missing from the archive.
          type: boolean
        logs_incomplete_reason:
          description: Why, when `logs_incomplete` is true.
          anyOf:
            - $ref: '#/components/schemas/LogsIncompleteReason'
            - type: 'null'
        memory_mib:
          description: 'Memory in MiB: the GPU type''s per-GPU default × the GPU count.'
          type: integer
        name:
          description: Name, if one was given.
          type:
            - string
            - 'null'
        network_mode:
          $ref: '#/components/schemas/NetworkMode'
          description: Fixed at create.
        queue_timeout:
          description: Queue timeout in seconds.
          type: integer
        readiness_probe:
          description: As requested.
          anyOf:
            - $ref: '#/components/schemas/ReadinessProbe'
            - type: 'null'
        ready:
          description: >-
            Whether the readiness probe passes. Without a probe, `true` once
            `running`.
          type: boolean
        resolved:
          description: Set once the image is resolved and the working directory is known.
          anyOf:
            - $ref: '#/components/schemas/ResolvedSpec'
            - type: 'null'
        started_at:
          description: When it entered `running`.
          format: date-time
          type:
            - string
            - 'null'
        state:
          $ref: '#/components/schemas/SandboxState'
        tags:
          additionalProperties:
            type: string
          description: Your tags.
          type: object
        terminated_at:
          description: When it entered `terminated`.
          format: date-time
          type:
            - string
            - 'null'
        termination_message:
          description: >-
            Why the sandbox ended, when there's more to say than
            `termination_reason`. Set in two cases only. With
            `image_pull_failed`, before the sandbox ran: the registry's own
            message, or what Telnyx's checks of the image found (the reference,
            the image's platform, ENTRYPOINT/CMD, WorkingDir or User). Text from
            your registry is shown as received, cleaned of control characters.
            With `internal_error`: a short reason from Telnyx, such as the
            sandbox's disk not being ready.
          type:
            - string
            - 'null'
        termination_reason:
          description: Set once `state` is `terminated`.
          anyOf:
            - $ref: '#/components/schemas/TerminationReason'
            - type: 'null'
        timeout:
          description: Maximum lifetime in seconds; `null` means no limit.
          type:
            - integer
            - 'null'
        workdir:
          description: As requested.
          type:
            - string
            - 'null'
      required:
        - id
        - name
        - tags
        - state
        - termination_reason
        - termination_message
        - exit_code
        - ready
        - network_mode
        - image
        - command
        - workdir
        - env
        - gpu
        - cpu
        - memory_mib
        - disk_gib
        - timeout
        - idle_timeout
        - queue_timeout
        - cidr_allowlist
        - readiness_probe
        - log_bucket
        - resolved
        - logs_incomplete
        - logs_incomplete_reason
        - created_at
        - started_at
        - terminated_at
      type: object
    TelnyxError:
      description: One error in the standard Telnyx error body.
      properties:
        code:
          description: >-
            Telnyx error code: a 5-digit string for general errors, e.g.
            `10009`. Sandboxes-specific errors are identified by their name in
            `title`.
          type: string
        detail:
          description: Human-readable explanation.
          type:
            - string
            - 'null'
        meta:
          description: Extra information.
          anyOf:
            - $ref: '#/components/schemas/TelnyxErrorMeta'
            - type: 'null'
        source:
          description: Where the error is.
          anyOf:
            - $ref: '#/components/schemas/TelnyxErrorSource'
            - type: 'null'
        title:
          description: >-
            Short, constant summary of the error. For Sandboxes-specific errors,
            the error's name, e.g. `quota_exceeded`.
          type: string
      required:
        - title
      type: object
    GpuSpec:
      additionalProperties: false
      description: >-
        The GPU type and count to rent. Only types listed by `GET
        /ai/sandbox-gpu-types` are accepted, with a count from their
        `allowed_counts`; anything else fails with `resources_not_allowed`.
        Currently each type lists one count, so the sandbox gets a whole node of
        that type.
      properties:
        count:
          description: >-
            A count from the type's `allowed_counts`. Currently that's the
            node's GPU count, so the sandbox rents a whole node.
          maximum: 8
          minimum: 1
          type: integer
        type:
          description: GPU type, e.g. `B300`.
          maxLength: 64
          minLength: 1
          type: string
      required:
        - type
        - count
      type: object
    ImageSpec:
      additionalProperties: false
      description: >-
        The container image to run. The image must be publicly pullable and have
        a `linux/amd64` variant.
      properties:
        ref:
          description: >-
            Image reference, e.g. `ghcr.io/acme/trainer:1.4`. The image must be
            publicly pullable and have a `linux/amd64` variant. The registry
            must be a public DNS name; IP literals, `localhost`, single-label
            hosts and internal registries fail with `registry_not_allowed`.
          maxLength: 1024
          minLength: 1
          type: string
      required:
        - ref
      type: object
    LogsIncompleteReason:
      description: >-
        Why some of the sandbox's output is permanently missing from the
        archive:

        `log_bucket_unavailable` (the log bucket couldn't be written),
        `node_lost` (the

        sandbox's node was lost), `logs_missing` (output was lost on its way to
        the

        archive), `logs_unverified` (the sandbox's output couldn't be counted,
        so the

        archive can't be shown complete), or `size_cap_reached` (the output
        passed the

        size cap).
      enum:
        - log_bucket_unavailable
        - node_lost
        - logs_missing
        - logs_unverified
        - size_cap_reached
      type: string
    NetworkMode:
      description: >-
        Outbound network access, fixed at create: `public` (the internet, never
        internal addresses), `blocked` (`block_network: true`; no network at
        all, not even DNS) or `allowlist` (`cidr_allowlist`; only those CIDRs).
      enum:
        - public
        - blocked
        - allowlist
      type: string
    ReadinessProbe:
      description: >-
        How to tell the sandbox is ready; drives the `ready` field. Set exactly
        one of `tcp_port` or `exec`; the other may be omitted or `null`.
      oneOf:
        - title: TCP port probe
          type: object
          properties:
            tcp_port:
              description: Ready once this port accepts connections inside the sandbox.
              type: integer
              minimum: 1
              maximum: 65535
            exec:
              description: Not set for a TCP port probe.
              type: 'null'
          required:
            - tcp_port
          additionalProperties: false
        - title: Exec probe
          type: object
          properties:
            exec:
              description: Ready once this command (argv) exits with 0.
              type: array
              items:
                type: string
              minItems: 1
            tcp_port:
              description: Not set for an exec probe.
              type: 'null'
          required:
            - exec
          additionalProperties: false
    ResolvedSpec:
      description: >-
        What actually runs, resolved before the sandbox is placed. Set once the
        image

        is resolved.
      properties:
        command:
          description: Final argv.
          items:
            type: string
          type: array
        image:
          description: 'Image pinned by digest: `host/repo@sha256:…`.'
          type: string
        workdir:
          description: Final working directory.
          type: string
      required:
        - image
        - command
        - workdir
      type: object
    SandboxState:
      description: |-
        Lifecycle state: `queued` → `preparing` (GPU preparation, when needed) →
        `scheduled` → `starting` (pulling the image) → `running` → `terminated`.
        Any non-terminal state can go straight to `terminated`, which is final.
      enum:
        - queued
        - preparing
        - scheduled
        - starting
        - running
        - terminated
      type: string
    TerminationReason:
      description: >-
        Why the sandbox ended. Always set once `state` is `terminated`.


        - Before running: `queue_timeout`, `terminated_by_user` (cancelled while
        queued), `image_pull_failed` (the image can't be used;
        `termination_message` says why when it's known), `no_command` (the image
        has no ENTRYPOINT or CMD and no `command` was given),
        `account_suspended`, `killed_by_operator`, `spend_limit_reached`,
        `internal_error`.

        - From running: `exit` (see `exit_code`), `timeout`, `idle_timeout`,
        `terminated_by_user`, `oom_killed`, `disk_limit_exceeded`,
        `account_suspended`, `killed_by_operator`, `spend_limit_reached`,
        `node_lost`, `internal_error`.


        `spend_limit_reached`: your account, or the API key that created the
        sandbox, reached its Sandboxes spend limit. A sandbox ended this way
        isn't restarted when the limit is raised.
      enum:
        - exit
        - timeout
        - idle_timeout
        - queue_timeout
        - terminated_by_user
        - image_pull_failed
        - no_command
        - oom_killed
        - disk_limit_exceeded
        - account_suspended
        - killed_by_operator
        - spend_limit_reached
        - node_lost
        - internal_error
      type: string
    TelnyxErrorMeta:
      description: Extra error information.
      properties:
        url:
          default: null
          description: Documentation page for the error code.
          type:
            - string
            - 'null'
      type: object
    TelnyxErrorSource:
      description: Where in the request the error was found.
      properties:
        parameter:
          default: null
          description: Name of the offending parameter.
          type:
            - string
            - 'null'
        pointer:
          default: null
          description: JSON pointer into the request body, e.g. `/timeout`.
          type:
            - string
            - 'null'
      type: object
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````