---
title: "Read a file from the active repo session workspace."
method: GET
path: "/v1/repo-sessions/{session_id}/file"
tags: ["repos"]
---

# Read a file from the active repo session workspace.

`GET /v1/repo-sessions/{session_id}/file`

## Request

- Base URL: `https://api.kody.codes`
- URL: `https://api.kody.codes/v1/repo-sessions/{session_id}/file`
- Auth: HTTP bearer

Read a file from the active repo session workspace. Reads the live session overlay, not just the published base commit. Append #L165, #L165-L180, or a Markdown heading slug (#export-jsdoc) to path to return that region instead of the whole file. A missing or invalid anchor fails instead of ignoring the fragment.

Org permission: `package:read`.

## Path parameters

- `session_id` string, required: Active repo session id from repoOpenSession or repoListSessions.

## Query parameters

- `path` string, required: Repo-relative file path to read. Append #L165, #L165-L180, or a Markdown heading slug (#export-jsdoc) to return that region. A missing anchor fails instead of returning the whole file.

## Response `200`

Success.

- object
  - `path` string, required
  - `content` string, nullable, required
  - `anchor` object: Set when path included a # fragment. start_line/end_line are the returned window; a single #L165 line includes surrounding context.
    - `kind` 'lines' | 'heading', required
    - `requested` string, required
    - `start_line` integer, required
    - `end_line` integer, required
    - `requested_start_line` integer, required
    - `requested_end_line` integer, required
    - `total_lines` integer, required
    - `heading` object, nullable, required
      - `title` string, required
      - `slug` string, required
      - `level` integer, required

## Other responses

- `400`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `401`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `403`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `404`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `409`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `413`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `429`: Too many requests (edge IP/token limit) or an entitlement / plan-cap limit. Wait at least `Retry-After` seconds before retrying.
- `500`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `503`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `default`: Error envelope `{ "error": { "code", "message", "details"? } }`.

---

[API](https://skmtc.dev/kody/apis/kody-api.md) · [All operations](https://skmtc.dev/kody/apis/kody-api/llms.txt) · [OpenAPI document](https://skmtc.dev/kody/apis/kody-api/revisions/705f4f022728?raw)
