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

# Post apiv1sandboxes:idexec



## OpenAPI

````yaml https://api.simplesandbox.dev/doc post /api/v1/sandboxes/:id/exec
openapi: 3.0.0
info:
  version: 1.0.0
  title: Sandbox API
servers: []
security: []
paths:
  /api/v1/sandboxes/:id/exec:
    post:
      parameters:
        - schema:
            type: string
            example: e7847229c547d8
          required: true
          name: id
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExecSandboxBody'
      responses:
        '200':
          description: Command executed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExecSandboxResponse'
            text/event-stream:
              schema:
                nullable: true
                description: SSE stream of execution logs
        '400':
          description: Active organization missing
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Sandbox not found
components:
  schemas:
    ExecSandboxBody:
      type: object
      properties:
        command:
          type: string
          minLength: 1
          example: npm install
          description: >-
            Command to execute via /bin/sh -c. Supports shell features like
            pipes, redirects, and variables.
        options:
          type: object
          properties:
            timeout:
              type: integer
              minimum: 0
              example: 10
              description: >-
                Timeout in seconds before the command is forcefully stopped. Set
                to 0 for unlimited duration.
            stdin:
              type: string
              example: input text
            container:
              type: string
              example: app
            background:
              type: boolean
              default: false
              example: true
            env:
              type: object
              additionalProperties:
                type: string
              example:
                MY_VAR: value
                DEBUG: 'true'
              description: >-
                Environment variables to set for the command execution. These
                will be merged with the sandbox's existing environment.
            cwd:
              type: string
              example: /app/project
              description: >-
                Working directory for command execution. Must be an absolute
                path. If not specified, uses the sandbox's default working
                directory or the persistent cwd set via sandbox.cwd().
          default:
            background: false
      required:
        - command
    ExecSandboxResponse:
      type: object
      properties:
        stdout:
          type: string
          example: |
            hello
        stderr:
          type: string
          example: ''
        exitCode:
          type: integer
          example: 0
        success:
          type: boolean
          example: true
      required:
        - stdout
        - stderr
        - exitCode
        - success
    Error:
      type: object
      properties:
        code:
          type: number
          example: 422
        message:
          type: string
          example: 'Validation failed: Name has already been taken'
        details:
          nullable: true
      required:
        - code
        - message

````