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

# List Commands

> List all tracked background processes for a sandbox.

Returns an array of background processes that are currently tracked for the
sandbox. Only commands started with `background: true` appear in this list.
Processes are removed from the list when they complete via
[wait](/api-reference/command/wait) or are killed via
[kill](/api-reference/command/kill).

## Path Parameters

<ParamField path="sandbox_id" type="string" required>
  The sandbox identifier. Format: `sbx-<8 chars>`.
</ParamField>

## Response

Returns an array of `ProcessInfo` objects. May be empty if no background
processes are tracked.

<ResponseField name="[].pid" type="integer">
  Process ID.
</ResponseField>

<ResponseField name="[].cmd" type="string">
  The command string that was run.
</ResponseField>

<ResponseField name="[].is_pty" type="boolean">
  Whether the process was started with a pseudo-terminal.
</ResponseField>

<ResponseField name="[].envs" type="object">
  Environment variables the process was started with.
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.declaw.ai/sandboxes/sbx-a1b2c3d4/commands \
    -H "X-API-Key: YOUR_API_KEY"
  ```

  ```python Python theme={null}
  from declaw import Sandbox

  sbx = Sandbox.connect("sbx-a1b2c3d4", api_key="YOUR_API_KEY", domain="api.declaw.ai")
  processes = sbx.commands.list()
  for proc in processes:
      print(proc.pid, proc.cmd)
  ```

  ```typescript TypeScript theme={null}
  import { Sandbox } from "@declaw/sdk";

  const sbx = await Sandbox.connect("sbx-a1b2c3d4", {
    apiKey: "YOUR_API_KEY",
    domain: "api.declaw.ai",
  });
  const processes = await sbx.commands.list();
  for (const proc of processes) {
    console.log(proc.pid, proc.cmd);
  }
  ```
</CodeGroup>

```json Response theme={null}
[
  {
    "pid": 42,
    "cmd": "python3 worker.py",
    "is_pty": false
  },
  {
    "pid": 43,
    "cmd": "sleep 60",
    "is_pty": false
  }
]
```

## Error Responses

| Status | Cause                      |
| ------ | -------------------------- |
| `401`  | Missing or invalid API key |
