> ## 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 Directory

> List the entries of a directory inside a sandbox.

Returns the immediate children (files and subdirectories) of the specified
directory path. Does not recurse into subdirectories.

## Path Parameters

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

## Query Parameters

<ParamField query="path" type="string" required>
  Absolute path of the directory to list inside the sandbox.

  Example: `/home/user`
</ParamField>

## Response

Returns an array of `EntryInfo` objects, one per directory entry.

<ResponseField name="[].name" type="string">
  Entry filename or directory name (not the full path).
</ResponseField>

<ResponseField name="[].path" type="string">
  Full absolute path inside the sandbox.
</ResponseField>

<ResponseField name="[].type" type="string">
  Entry type: `"file"`, `"dir"`, or `"symlink"`.
</ResponseField>

<ResponseField name="[].size" type="integer">
  Size in bytes. `0` for directories.
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://api.declaw.ai/sandboxes/sbx-a1b2c3d4/files/list?path=/home/user" \
    -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")
  entries = sbx.files.list("/home/user")
  for entry in entries:
      print(entry.name, entry.type, entry.size)
  ```

  ```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 entries = await sbx.files.list("/home/user");
  for (const entry of entries) {
    console.log(entry.name, entry.type, entry.size);
  }
  ```
</CodeGroup>

```json Response theme={null}
[
  {
    "name": "script.py",
    "path": "/home/user/script.py",
    "type": "file",
    "size": 1024
  },
  {
    "name": "data",
    "path": "/home/user/data",
    "type": "dir",
    "size": 0
  }
]
```

## Error Responses

| Status | Cause                      |
| ------ | -------------------------- |
| `401`  | Missing or invalid API key |
| `404`  | Sandbox not found          |
| `502`  | envd daemon unreachable    |
| `503`  | Sandbox has no VM          |
