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

# Read File

> Read the content of a file inside a sandbox.

Reads the specified file from the sandbox filesystem and returns its raw content
as a plain-text response body (`Content-Type: text/plain`). The bytes are returned
unmodified — no encoding is applied.

## 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 file to read inside the sandbox.

  Example: `/home/user/script.py`
</ParamField>

## Response

Returns the raw file content as `text/plain`. The response body is the file's
bytes — no JSON wrapper.

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://api.declaw.ai/sandboxes/sbx-a1b2c3d4/files?path=/home/user/script.py" \
    -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")
  content = sbx.files.read("/home/user/script.py")
  print(content)  # print('hello')\n
  ```

  ```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 content = await sbx.files.read("/home/user/script.py");
  console.log(content);
  ```
</CodeGroup>

```
print('hello')
```

## Error Responses

| Status | Cause                                                |
| ------ | ---------------------------------------------------- |
| `401`  | Missing or invalid API key                           |
| `404`  | File not found or sandbox not found                  |
| `409`  | Sandbox is paused — resume it before accessing files |
| `410`  | Sandbox has been killed                              |
| `502`  | envd daemon unreachable                              |
| `503`  | Sandbox has no VM                                    |
