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

# Run a command in a session's sandbox

> Runs one command as the sandbox's agent user (never root) in `/workspace` or a directory under it, and returns its exit code and output (stdout capped at 64 KiB, stderr at 16 KiB). The command's network traffic goes through the session's egress rules like the agent's. Allowed while the session is `ready` (409 during a run, while an approval is pending, or paused); at most 30 per minute per session (429). Recorded on the transcript as `session.exec` (argv and exit code, never env values).



## OpenAPI

````yaml /api-reference/openapi.json post /v1/sessions/{session_id}/exec
openapi: 3.1.0
info:
  title: Veri API
  description: >-
    REST API for the Veri RL post-training platform. All requests require a
    Bearer API key (`vk_` prefix).
  license:
    name: ''
  version: 0.1.0
servers:
  - url: https://api.veri.studio
    description: Production
security: []
tags:
  - name: Training jobs
    description: Create, monitor, and manage training jobs.
  - name: Datasets
    description: Upload and connect training datasets.
  - name: Deployments
    description: Serve trained models and run inference.
  - name: Volumes
    description: Persistent file storage mounted into jobs.
  - name: Models
    description: Custom model registry deployments serve from.
  - name: Regions
    description: Discover available launch regions.
  - name: GPU
    description: Live GPU availability by provider and region.
  - name: Code artifacts
    description: Upload custom training script bundles.
  - name: Billing
    description: Credit balance and transaction history.
  - name: API keys
    description: Create and revoke API keys.
  - name: Account
    description: The authenticated caller's identity.
  - name: Settings
    description: Account-level integrations (Weights & Biases).
  - name: Metrics
    description: Prometheus metrics export for your own observability stack.
  - name: Evaluators
    description: 'Evaluators: versioned scoring rules (LLM judge, code, human).'
  - name: Experiments
    description: >-
      Experiments: offline runs of a pinned dataset snapshot through a target,
      scored by pinned evaluators.
  - name: Annotation queues
    description: >-
      Human review: queue traces, threads and experiment items, reserve one at a
      time, score them and feed corrections back into datasets.
  - name: Monitors
    description: >-
      Monitors: evaluators scoring a sampled share of a deployment's live
      traffic.
  - name: Observability
    description: Agent conversations, agents and their traffic.
  - name: Public runs
    description: Unauthenticated reads of runs their owners published to Explore.
paths:
  /v1/sessions/{session_id}/exec:
    post:
      tags:
        - Sessions
      summary: Run a command in a session's sandbox
      description: >-
        Runs one command as the sandbox's agent user (never root) in
        `/workspace` or a directory under it, and returns its exit code and
        output (stdout capped at 64 KiB, stderr at 16 KiB). The command's
        network traffic goes through the session's egress rules like the
        agent's. Allowed while the session is `ready` (409 during a run, while
        an approval is pending, or paused); at most 30 per minute per session
        (429). Recorded on the transcript as `session.exec` (argv and exit code,
        never env values).
      operationId: exec
      parameters:
        - name: session_id
          in: path
          description: Session ID
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SessionExecRequest'
        required: true
      responses:
        '200':
          description: The command ran (any exit code)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionExecResponse'
        '400':
          description: >-
            Invalid argv, cwd outside /workspace, bad env or timeout, or session
            ops disabled
        '404':
          description: Not found in this workspace
        '409':
          description: The session is not ready
        '422':
          description: >-
            Unknown field in the body (`root` / `harness_env` are refused: exec
            never runs as root)
        '429':
          description: More than 30 execs in the last minute on this session
        '501':
          description: The sandbox runtime does not support exec
      security:
        - bearerAuth: []
components:
  schemas:
    SessionExecRequest:
      type: object
      description: |-
        Unknown fields are refused (422): the runtime's operator-only switches
        (`root`, `harness_env`) are not part of this API, and a body naming them
        must fail loudly rather than run as the agent user without saying so.
      required:
        - argv
      properties:
        argv:
          type: array
          items:
            type: string
          description: |-
            The command and its arguments (no shell: use `["sh", "-c", "..."]`
            for pipes). 1..=256 entries.
        cwd:
          type:
            - string
            - 'null'
          description: Working directory, `/workspace` (default) or a path under it.
        env:
          type: object
          description: |-
            Extra environment variables, on top of the session's own (what the
            agent sees, model credentials excluded). `ANTHROPIC_*`, `OPENAI_*`,
            `VERI_*`, `PATH` and `LD_*` are dropped (listed in `env_dropped`).
          additionalProperties:
            type: string
          propertyNames:
            type: string
        timeout_s:
          type:
            - integer
            - 'null'
          format: int32
          description: Seconds before the command is killed, 1..=300 (default 60).
          minimum: 0
      additionalProperties: false
    SessionExecResponse:
      type: object
      required:
        - object
        - exit_code
        - stdout
        - stderr
        - truncated
        - timed_out
        - duration_ms
        - env_dropped
      properties:
        object:
          type: string
        exit_code:
          type: integer
          format: int64
        stdout:
          type: string
          description: At most 64 KiB (`truncated` when cut).
        stderr:
          type: string
          description: At most 16 KiB (`truncated` when cut).
        truncated:
          type: boolean
        timed_out:
          type: boolean
          description: The command ran past `timeout_s` and was killed.
        duration_ms:
          type: integer
          format: int64
        env_dropped:
          type: array
          items:
            type: string
          description: '`env` keys that were dropped (reserved names).'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key
      description: API key with the `vk_` prefix. Create one from the dashboard.

````

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