---
title: "Read the session's most recently controlled terminal"
method: GET
path: "/api/experimental/session/{sessionID}/terminal/read"
tags: ["persistentPty"]
---

# Read the session's most recently controlled terminal

`GET /api/experimental/session/{sessionID}/terminal/read`

## Request

- Base URL: `https://opencode.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://opencode.ai/api/experimental/session/{sessionID}/terminal/read`
- Auth: none required

Read the last physical rows without changing selection or taking control. Omitted lines uses the live terminal height; larger counts include retained history. Blank rows are preserved. Screen dimensions and cursor remain relative to the live screen. Returns null when no current terminal exists. Selection is server-local and resets on restart. Experimental: may change without compatibility guarantees.

## Path parameters

- `sessionID` string, required

## Query parameters

- `lines` string

## Response `200`

Success

- object
  - `data` PersistentPtyReadResult, required
    - `ptyID` string, required
    - `title` string, required
    - `cwd` string, required
    - `foregroundProcess` string, nullable, required
    - `screen` object, required
      - `text` string, required
      - `cols` integer, required
      - `rows` integer, required
      - `cursor` object, required
        - `x` integer, required
        - `y` integer, required

## Other responses

- `400`: InvalidRequestError
- `401`: UnauthorizedError
- `503`: ServiceUnavailableError

## Changes

> 50 revisions in range; 1 not diffed.

- **2026-10-28** `079d83620443`: 1 info
  - api operation id `server.experimental.persistentPty.read` removed and replaced with `experimental.persistentPty.read`

[Operation history](https://skmtc.dev/kaaass/apis/opencode/changes/api/experimental/session/:sessionID/terminal/read/get.md)

---

[API](https://skmtc.dev/kaaass/apis/opencode.md) - [All operations](https://skmtc.dev/kaaass/apis/opencode/llms.txt) - [OpenAPI document](https://skmtc.dev/kaaass/apis/opencode/revisions/4e083d954707?raw)
