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

# Read File

> Read a file from the session workspace. Path is relative to the workspace root.

## Overview

Returns the base64-encoded content of a file in the session's workspace. The workspace is a per-session scratch directory inside the sandbox; paths must be relative (no leading `/`, no `..`, no NUL byte, up to 4096 bytes). Large files are truncated at the sandbox-enforced read limit — check `truncated` in the response.

## Path Parameters

<ParamField path="id" type="string" required={true}>
  Browser session ID (UUID).
</ParamField>

## Query Parameters

<ParamField query="path" type="string" required={true}>
  Workspace-relative file path, e.g. `notes/todo.txt`.
</ParamField>

## Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -G "https://api.scrapengine.io/api/v1/browser/sessions/baa3f390-fa6e-4a24-b84a-a575a5f3a9c7/fs/file" \
    -H "Authorization: Bearer $SCRAPENGINE_API_KEY" \
    --data-urlencode "path=notes/todo.txt"
  ```

  ```python Python theme={null}
  import os, requests

  response = requests.get(
      "https://api.scrapengine.io/api/v1/browser/sessions/baa3f390-fa6e-4a24-b84a-a575a5f3a9c7/fs/file",
      headers={"Authorization": f"Bearer {os.environ['SCRAPENGINE_API_KEY']}"},
      params={"path": "notes/todo.txt"},
  )
  data = response.json()
  ```
</CodeGroup>

## Response

### Success Response (200)

<ResponseField name="path" type="string">
  The requested workspace-relative path.
</ResponseField>

<ResponseField name="content" type="string">
  Base64-encoded file content.
</ResponseField>

<ResponseField name="bytes" type="integer">
  Decoded byte length of the file.
</ResponseField>

<ResponseField name="truncated" type="boolean">
  True when the content was truncated to the maximum read size.
</ResponseField>

**Example Response:**

```json theme={null}
{
  "path": "notes/todo.txt",
  "content": "SGVsbG8gV29ybGQ=",
  "bytes": 11,
  "truncated": false
}
```

### Error Responses

| Status | Description                                                                 |
| ------ | --------------------------------------------------------------------------- |
| `400`  | Invalid path — leading `/`, contains `..`, NUL byte, or exceeds 4096 bytes. |
| `401`  | Unauthorized — invalid or missing API key.                                  |
| `404`  | Session or file not found.                                                  |
| `413`  | File exceeds the maximum read size.                                         |
