# Read messages


```sh
line messages "Alice"
line messages "Alice" --limit 50
line messages "Alice" --show-ids
line messages CHAT_ID --json
```

`messages` shows the 20 most recent messages; `--limit` takes 1–100. Normal
output lists the oldest first, and plain `--json` keeps LINE's order.
`--show-ids` adds the IDs you need for replies, reactions, downloads, and
unsend.

Reading never sends read receipts and never saves message text locally. Use
[`line read`](https://kongesque.github.io/line-cli/guides/mark-read/) to mark a chat as read. Some older encrypted
messages can't be read if LINE no longer provides their device keys.

Notes and Albums (content type 16 and plaintext `POSTNOTIFICATION` wrappers)
show as `[Note: <first line>]`, followed by the remaining lines and an
allowlisted LINE link, or as `[Album: <title>]` with a link. This applies to
`messages` and readable `watch` output.

## Check message IDs without decrypting

To see which message IDs LINE returned, without message content or key lookups:

```sh
line --error-format=json messages "Chat name" --diagnostics --json --limit 50
```

`--diagnostics` needs `--json` and can't be combined with `--details`,
`--resolve-names`, `--page`, or `--cursor`. A missing ID only means it wasn't in
this response. See the [diagnostic fields](https://kongesque.github.io/line-cli/reference/json/#history-diagnostics).


## Older history (JSON)

```sh
line messages CHAT_ID --page --json --limit 50
line messages CHAT_ID --page --json --limit 50 --cursor 'NEXT_CURSOR'
```

`--page` needs `--json`, and `--cursor` needs both. Each call returns one page
with `schema_version: 1`, `chat_id`, `order: "newest_first"`, `messages`,
`exhausted`, `stop_reason`, and, unless the history is exhausted, `next_cursor`.
Message IDs are strings, and each page is sorted by numeric ID, newest first.

Pass `next_cursor` back unchanged, for the same chat. It records the exact
delivered time and message ID, never the created time. An invalid cursor, or one
from another chat, fails before any history is fetched. Chat names are resolved
first.

| `stop_reason` | Meaning |
| --- | --- |
| `count_limit` | The requested number of messages was returned. |
| `page_limit` | The page is shorter but not empty. |
| `end_of_available_history` | No messages remain after the cursor's own message is removed. Only this sets `exhausted: true` and leaves out `next_cursor`. |

A short page isn't the end. Asking for 100 can return 99, because the cursor's
own message takes one slot, and a cursor can lead to an empty page. You can only
read history that LINE still offers this client; neither full history nor a
fixed retention period is guaranteed.

Missing delivered times, malformed pages, and pages that don't move forward fail
with an error. `--timeout` covers fetching and decoding; a timeout or
cancellation is an error, never reported as the end. If some messages can't be
decrypted, the page and cursor are still returned with a nonzero exit, so check
each message's status before you continue. Without `--page`, `--json` still
returns a plain array.


## Detailed JSON

```sh
line chats --details --json
line messages CHAT_ID --details --json --resolve-names
line messages CHAT_ID --details --page --json --limit 50
```

`--details` needs `--json`. It returns a `schema_version: 1` envelope with
decoded content and explicit unknown values. Add `--resolve-names` to look up
sender names. The plain JSON and `watch` formats don't change. If some messages
can't be decrypted, results are still written and the exit code is nonzero. See
the [detailed JSON reference](https://kongesque.github.io/line-cli/reference/json/#detailed-content) for fields, statuses,
and limits.


---
Source: https://kongesque.github.io/line-cli/guides/read/
