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

# Execute a command in an existing sandbox.

> **Required scope:** sandbox:execute

**Required scope:** `sandbox:execute`

### Request body

`ExecuteRequest`

<ParamField body="command" type="string[]" required>
  Command to run (e.g., \['python3', '-c', 'print('hello')']).
</ParamField>

<ParamField body="env" type="object">
  Additional environment variables.
</ParamField>

<ParamField body="sandbox_id" type="string" required>
  Sandbox ID to execute in.
</ParamField>

<ParamField body="timeout_seconds" type="integer (int32)">
  Execution timeout in seconds (default: 30).
</ParamField>

<ParamField body="working_dir" type="string">
  Working directory inside the sandbox.
</ParamField>

### Response

No response body. Command executed.

### Status codes

| Code  | Meaning                                            |
| ----- | -------------------------------------------------- |
| `200` | Command executed                                   |
| `401` | Unauthorized — missing or invalid credentials      |
| `403` | Forbidden — the key/token lacks the required scope |
| `429` | Rate limited — see Retry-After / X-RateLimit-Reset |
| `503` | Sandbox infrastructure unavailable                 |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.nsr.stateset.com/api/v1/sandbox/execute' \
    --header 'X-API-Key: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "command": [
      "string"
    ],
    "env": {},
    "sandbox_id": "string",
    "timeout_seconds": 1,
    "working_dir": "string"
  }'
  ```
</RequestExample>
