---
title: "Workspace: File Read"
method: POST
path: "/v1/agents/{agent_id}/workspace/file_read"
tags: ["API v1", "Agents", "Agents Workspace"]
---

# Workspace: File Read

`POST /v1/agents/{agent_id}/workspace/file_read`

## Request

- Base URL: `https://api.xpander.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.xpander.ai/v1/agents/{agent_id}/workspace/file_read`
- Auth: API key in header `x-api-key`

Read a file from the agent's workspace filesystem. Supports partial reads via line ranges.

## Path parameters

- `agent_id` string, required

## Request body

- FileReadRequest
  - `path` string, required: Relative path to the file to read from the workspace filesystem.
  - `start_line` integer, nullable: 1-indexed starting line number for partial reads. Omit to read from the beginning.
  - `end_line` integer, nullable: 1-indexed ending line number (inclusive) for partial reads. Omit to read to the end.
  - `encoding` string: File encoding to use when reading. Falls back to detected encoding if decoding fails.

## Response `200`

Successful Response

- FileReadResponse
  - `content` string: File content (full or partial based on line range)
  - `lines_count` integer: Total number of lines in the returned content
  - `encoding_detected` string: The encoding used to decode the file

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/xpander/apis/xpander-ai-api-service.md) - [All operations](https://skmtc.dev/xpander/apis/xpander-ai-api-service/llms.txt) - [OpenAPI document](https://skmtc.dev/xpander/apis/xpander-ai-api-service/revisions/725c0066d5df?raw)
