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

# Get a sandbox execution



## OpenAPI

````yaml /api-spec/sandbox_api.yaml get /executions/{execution_id}
openapi: 3.0.3
info:
  title: GMI Sandbox API
  description: >-
    REST API for GMI Sandbox: create isolated execution environments from
    templates or durable snapshots, manage their lifecycle on the control plane,
    and run commands or transfer files through each sandbox's own data plane.
  contact:
    name: GMI Cloud Support
    email: support@gmicloud.ai
  version: '2.0'
servers:
  - url: https://console.gmicloud.ai/api/v2
    description: Control plane
security:
  - bearerAuth: []
tags:
  - name: Sandbox
    description: |
      Sandbox instance lifecycle management (Sandbox v2, /api/v2/sandboxes)
  - name: SandboxSnapshot
    description: Durable sandbox snapshot management (Sandbox v2, `/api/v2/snapshots`)
  - name: SandboxTemplate
    description: Sandbox template management (Sandbox v2, `/api/v2/templates`)
  - name: Sandbox-Exec
    description: >
      Sandbox execution data plane (accessed via the sandbox host and sandbox
      access token). These endpoints are not under the control plane's `/api/v2`
      path; clients connect directly to `https://{sandbox_key}.{domain}` and
      authenticate with `X-Access-Token`.
  - name: Sandbox-Shell
    description: >
      Sandbox interactive terminal (PTY) data plane. **These endpoints are not
      under `/api/v2`**: clients connect directly to
      `https://{sandbox_key}.{domain}` and authenticate with `X-Access-Token`.
      `{sandbox_key}`, `{domain}` and the `X-Access-Token` value are the
      `sandbox_key`, `domain` and `sandbox_access_token` returned by the
      control-plane create/connect endpoints; no extra endpoint is needed.


      Each sandbox has exactly **one logical shell session** and at most **one
      active WebSocket connection** at a time (a second concurrent attach is
      refused at handshake with `409`). Disconnecting does not destroy the shell
      — re-attaching resumes the same session; only `POST /shell/control` with
      `action=close` destroys it.
  - name: Sandbox-Files
    description: >
      Sandbox file data plane (`/files`). **These endpoints are not under
      `/api/v2`** and do not use `Authorization: Bearer`: they are served by the
      sandbox's own data-plane entry point — clients connect directly to
      `https://{sandbox_key}.{domain}` and authenticate with `X-Access-Token`.
      `{sandbox_key}` is the `sandbox_key` returned by the create/connect
      endpoints, used for data-plane host addressing. `{domain}` and
      `X-Access-Token` are the `domain` and `sandbox_access_token` from the same
      responses — no extra endpoint is needed to obtain them.


      This split is not historical baggage but the nature of a data plane: file
      transfer is long-lived, high-volume, and addressed per sandbox, differing
      from the control plane's short requests in both capacity model and failure
      domain, so they do not share an entry point.


      **One unified abstraction.** The same contract is served by two backend
      kinds (an in-sandbox file service / a data-center data-plane proxy);
      clients need not — and cannot — tell them apart. The cost is that the
      contract is their intersection: `Content-Length` on download and resumable
      download (`Range`/`206`) are **optional capabilities** that vary by data
      center, and clients must work correctly when they are absent. See the
      per-operation notes below.
paths:
  /executions/{execution_id}:
    servers:
      - url: https://{sandbox_key}.{domain}
        description: >
          Sandbox data-plane entry point. Both variables come from the
          create/connect response: `sandbox_key` is `data.sandbox_key`, `domain`
          is `data.domain`.
        variables:
          sandbox_key:
            default: sandbox-key
            description: >-
              Sandbox key (the `sandbox_key` returned by the create/connect
              endpoints)
          domain:
            default: sandbox.example.com
            description: >
              The `domain` returned verbatim by the create/connect endpoints.
              Its default naming shape is `{idc-name}.{root-hostname}`, but
              clients must not assemble or derive it themselves.
    get:
      tags:
        - Sandbox-Exec
      summary: Get a sandbox execution
      operationId: getSandboxExecution
      parameters:
        - $ref: '#/components/parameters/SandboxExecExecutionIDParam'
        - $ref: '#/components/parameters/SandboxExecRequestIDParam'
      responses:
        '200':
          description: Current execution status and any available output.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SandboxExecResultResponse'
        '401':
          $ref: '#/components/responses/SandboxExecUnauthorized'
        '404':
          $ref: '#/components/responses/SandboxExecNotFound'
        '409':
          $ref: '#/components/responses/SandboxExecRuntimeNotRunning'
        '429':
          $ref: '#/components/responses/SandboxExecRateLimited'
        '500':
          $ref: '#/components/responses/SandboxExecInternalError'
        '503':
          $ref: '#/components/responses/SandboxExecUnavailable'
      security:
        - sandboxAccessToken: []
      servers:
        - url: https://{sandbox_key}.{domain}
          description: Sandbox data-plane host
          variables:
            sandbox_key:
              default: sandbox-key
              description: >-
                Data-plane addressing key (`sandbox_key` from the control-plane
                response).
            domain:
              default: sandbox.example.com
              description: Sandbox data-plane domain from the control-plane response.
components:
  parameters:
    SandboxExecExecutionIDParam:
      name: execution_id
      in: path
      required: true
      description: >-
        Public execution identifier returned by the create operation. A value
        that is not a valid UUID is treated as an unknown execution and returns
        404 `Execution.NotFound`.
      schema:
        type: string
        format: uuid
    SandboxExecRequestIDParam:
      name: X-Request-ID
      in: header
      required: false
      description: >
        Ignored. The server generates its own request ID (`req-<uuid>`) for
        every request and

        returns it in the `X-Request-ID` response header and the body's
        `request_id`.
      schema:
        type: string
        minLength: 1
        maxLength: 128
  schemas:
    SandboxExecResultResponse:
      type: object
      required:
        - request_id
        - execution_id
        - sandbox_id
        - status
        - exit_code
        - stdout
        - stderr
        - stdout_truncated
        - stderr_truncated
        - started_at
        - completed_at
      properties:
        request_id:
          type: string
          description: >-
            Server-generated request ID (`req-<uuid>`), identical to the
            `X-Request-ID` response header.
        execution_id:
          type: string
          format: uuid
        sandbox_id:
          type: string
          description: >-
            Echo of the data-plane addressing key (i.e. `sandbox_key`; the data
            plane identifies the instance by the key in the host).
        status:
          $ref: '#/components/schemas/SandboxExecStatus'
        termination_reason:
          type: string
          enum:
            - explicit_cancel
            - execution_timeout
            - runtime_terminated
          description: >-
            Why an execution that did not finish on its own ended. Omitted when
            the command exited by itself, including when it was killed by a
            signal from inside the sandbox (see exit_code). explicit_cancel: the
            execution was cancelled (status cancelled). execution_timeout: the
            execution reached its timeout (status timed_out).
            runtime_terminated: the command's process is gone without having
            reported an outcome, for example the sandbox was resumed from a
            pause without memory, or its output stream was lost for good, so the
            outcome of the command is unknown (status failed). Pausing a sandbox
            does not by itself end an execution: after a pause with memory the
            command continues and the execution reports its real result.
          example: runtime_terminated
        failure_reason:
          type: string
          enum:
            - cwd_not_found
            - cwd_not_directory
            - permission_denied
          description: >-
            Classified process startup failure. Omitted when no recognized
            startup cause is available. cwd_not_found means the working
            directory does not exist; cwd_not_directory means the working
            directory is not a directory; permission_denied means startup was
            denied without a reliably identified operation. Contains no path or
            raw upstream error. Runtime interruptions use termination_reason.
        exit_code:
          type: integer
          format: int32
          nullable: true
          description: >-
            Exit status of the command. A command killed by a signal (for
            example an out-of-memory kill) reports 128 + signal (137 for
            SIGKILL) with status failed and no termination_reason. Null while
            non-terminal, and when the execution was cancelled, timed out, or
            its runtime was terminated.
        stdout:
          type: string
          nullable: true
          description: >-
            Captured standard output, or null while not yet available. At most 1
            MiB is kept; further output is dropped and `stdout_truncated` is
            true.
        stderr:
          type: string
          nullable: true
          description: >-
            Captured standard error, or null while not yet available. At most 1
            MiB is kept; further output is dropped and `stderr_truncated` is
            true.
        stdout_truncated:
          type: boolean
          nullable: true
        stderr_truncated:
          type: boolean
          nullable: true
        started_at:
          type: string
          format: date-time
          nullable: true
        completed_at:
          type: string
          format: date-time
          nullable: true
    SandboxExecStatus:
      type: string
      description: >-
        Public lifecycle status of a sandbox execution. `timed_out` means the
        per-command time limit (`execution_timeout_seconds`) was reached and the
        command was terminated (SIGTERM, then SIGKILL after a grace period);
        `exit_code` is then null.
      enum:
        - pending
        - running
        - cancelling
        - succeeded
        - failed
        - cancelled
        - timed_out
    SandboxExecErrorResponse:
      type: object
      description: >-
        Data-plane error body, in the platform error envelope (without
        `trace_id`).
      required:
        - code
        - message
        - request_id
      properties:
        code:
          type: string
          description: >-
            Stable machine-readable error code. A 401 is always
            `Auth.Unauthorized`.
          example: Execution.InvalidRequest
        message:
          type: string
          description: Sanitized human-readable error message.
        request_id:
          type: string
          description: >-
            Server-generated ID for this request (`req-<uuid>`), identical to
            the `X-Request-ID` response header. A caller-supplied `X-Request-ID`
            is not used.
          example: req-3f2b6c1e-8a0d-4f6b-9c3e-2d7a1b5e9f40
        details:
          type: object
          additionalProperties: true
  responses:
    SandboxExecUnauthorized:
      description: >
        Missing or invalid X-Access-Token. The body is always

        `{"code":"Auth.Unauthorized","message":"unauthorized","request_id":"..."}`;
        missing, malformed,

        expired, and wrong-sandbox tokens are indistinguishable.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/SandboxExecErrorResponse'
          example:
            code: Auth.Unauthorized
            message: unauthorized
            request_id: req-3f2b6c1e-8a0d-4f6b-9c3e-2d7a1b5e9f40
    SandboxExecNotFound:
      description: >-
        Execution does not exist, is not owned by this sandbox, or the
        identifier is not a valid UUID.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/SandboxExecErrorResponse'
    SandboxExecRuntimeNotRunning:
      description: >-
        The sandbox is not running, so no command can be executed. The error
        code is `Execution.RuntimeNotRunning`. Start or resume the sandbox and
        retry.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/SandboxExecErrorResponse'
    SandboxExecRateLimited:
      description: >-
        The request was rate-limited. For `POST /executions` the code is
        `Execution.ConcurrencyLimitExceeded`: a sandbox allows at most 10
        non-terminal executions at the same time; retry after one completes.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/SandboxExecErrorResponse'
    SandboxExecInternalError:
      description: >-
        The execution service failed to complete the request. The error code
        identifies the failing step, for example `Execution.ResultFailed` when
        reading an execution's result fails.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/SandboxExecErrorResponse'
    SandboxExecUnavailable:
      description: >-
        A dependency of the execution service is temporarily unavailable; the
        request can be retried. The error code is
        `Execution.ProviderUnavailable` (the sandbox backend could not be
        reached) or `Execution.StoreUnavailable` (the execution record could not
        be read or written).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/SandboxExecErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >
        API Key or Access Token, always sent as `Authorization: Bearer <token>`.
        The gateway recognizes the token type automatically.
    sandboxAccessToken:
      type: apiKey
      in: header
      name: X-Access-Token
      description: >
        Sandbox data-plane token — the `sandbox_access_token` returned by the
        create/connect endpoints. Used for `/files`, Sandbox-Exec, and other
        data-plane endpoints; the control plane (`/api/v2`) does not accept it,
        and conversely the control plane's `Authorization: Bearer` is invalid on
        the data plane.


        The token is bound to its sandbox: using sandbox A's token against
        sandbox B's host fails. It stays valid until the sandbox's lifetime
        ends; there is no separate rotation endpoint (`rotate_traffic_token`
        rotates the port traffic token `traffic_access_token` and does not
        affect this one).

````

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