> ## 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.

# Get an exec

> Returns the exec: `status`, `exit_code` and `reason`. With `wait`, it's a long-poll: it returns as soon as the exec has ended, or after at most 10 s, always with `200`; call again until `status` is `exited`, `failed` or `terminated`. If the sandbox can't answer, you get the last known state.



## OpenAPI

````yaml /openapi/source/external/sandboxes/sandboxes.json get /ai/sandboxes/{sandbox_id}/execs/{exec_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}/execs/{exec_id}:
    get:
      tags:
        - Sandbox execs
      summary: Get an exec
      description: >-
        Returns the exec: `status`, `exit_code` and `reason`. With `wait`, it's
        a long-poll: it returns as soon as the exec has ended, or after at most
        10 s, always with `200`; call again until `status` is `exited`, `failed`
        or `terminated`. If the sandbox can't answer, you get the last known
        state.
      operationId: GetSandboxExec
      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: Exec ID (`exec-…`).
          in: path
          name: exec_id
          required: true
          schema:
            maxLength: 64
            minLength: 1
            type: string
          example: exec-0192f1c9-3e2a-7b1d-8c4f-5a6b7c8d9e0f
        - description: >-
            Seconds to wait for the exec to end. `0` (default) returns at once;
            the server waits at most 10 s and clamps larger values.
          in: query
          name: wait
          required: false
          schema:
            default: 0
            minimum: 0
            type: integer
      responses:
        '200':
          description: The exec.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExecRespData'
              example:
                data:
                  id: exec-0192f1c9-3e2a-7b1d-8c4f-5a6b7c8d9e0f
                  sandbox_id: sb-0192f1c2-7a4b-7c3e-9d1e-2f3a4b5c6d7e
                  command:
                    - python
                    - evaluate.py
                    - '--split'
                    - test
                  env:
                    LOG_LEVEL: info
                  workdir: /app
                  timeout: 3600
                  status: exited
                  exit_code: 0
                  reason: null
                  created_at: '2026-11-13T10:05:00Z'
                  finished_at: '2026-11-13T10:07:42Z'
        '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.
        '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:
    ExecRespData:
      properties:
        data:
          $ref: '#/components/schemas/Exec'
      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
    Exec:
      description: >-
        A process started in a sandbox. It keeps running when clients
        disconnect. Execs live as long as their sandbox.
      properties:
        command:
          description: Argv.
          items:
            type: string
          type: array
        created_at:
          description: When it was started.
          format: date-time
          type: string
        env:
          additionalProperties:
            type: string
          description: The extra environment variables given.
          type: object
        exit_code:
          description: >-
            Set once `exited`. A process killed by a signal reports 128 + the
            signal number (e.g. 137 for SIGKILL).
          type:
            - integer
            - 'null'
        finished_at:
          description: When it ended.
          format: date-time
          type:
            - string
            - 'null'
        id:
          description: Exec ID (`exec-…`).
          type: string
        reason:
          description: Set when `failed` or `terminated`.
          anyOf:
            - $ref: '#/components/schemas/ExecReason'
            - type: 'null'
        sandbox_id:
          description: The sandbox it runs in.
          type: string
        status:
          $ref: '#/components/schemas/ExecStatus'
        timeout:
          description: Exec timeout in seconds, if set.
          type:
            - integer
            - 'null'
        workdir:
          description: >-
            Working directory: the one given, else the sandbox's. `null` when
            neither is known: the sandbox was created without `workdir` and its
            image's wasn't read.
          type:
            - string
            - 'null'
      required:
        - id
        - sandbox_id
        - command
        - workdir
        - env
        - timeout
        - status
        - exit_code
        - reason
        - created_at
        - finished_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
    ExecReason:
      description: >-
        Why an exec is `failed` or `terminated`:

        - `sandbox_terminated`: the sandbox ended (or was ending) first;

        - `timeout`: the exec's `timeout` was reached;

        - `agent_unavailable`: the sandbox didn't confirm the start in time;

        - `cancelled`: killed with `SIGKILL` before its start was confirmed. If
        the start had in fact reached the sandbox, the exec moves on to what
        really ran, then exits from the kill;

        - `agent_error`: the sandbox returned an inconsistent answer.
      enum:
        - sandbox_terminated
        - timeout
        - agent_unavailable
        - cancelled
        - agent_error
      type: string
    ExecStatus:
      description: >-
        `starting` → `running` → `exited`. `failed`: the process was never
        confirmed started (see `reason`: `sandbox_terminated`,
        `agent_unavailable`, `cancelled` or `agent_error`). An
        `agent_unavailable` or `cancelled` exec can still move on to `running`,
        `exited` or `terminated` if its start did reach the sandbox.
        `terminated`: the process was stopped because the sandbox ended or the
        exec's `timeout` was reached.
      enum:
        - starting
        - running
        - exited
        - failed
        - terminated
      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

````