Source: https://cli.nylas.com/guides/mark-emails-read-unread-cli

# Mark Emails Read, Unread, or Starred (CLI)

Flipping the read flag is the most common thing you do to an email after reading it, and from a script it's the difference between an inbox that reflects reality and one that doesn't. The Nylas CLI sets read, unread, and starred state with one command per message, and a one-line pipeline applies it to a whole search result. This guide covers flipping a single message, bulk-updating from a search, and the read/star flags' meaning across providers.

Written by [Hazik](https://cli.nylas.com/authors/hazik) Director of Product Management

Updated June 8, 2026

> **TL;DR:** Set state per message with `nylas email mark read <id>`, `nylas email mark unread <id>`, or `nylas email mark starred <id>` (`nylas email mark-read --id` is the equivalent alias). To bulk-update, pipe `nylas email list --unread --json` through `jq` to extract IDs and loop. The same commands work across Gmail, Outlook, Exchange, Yahoo, and iCloud.

Command references used in this guide: [`nylas email mark-read`](https://cli.nylas.com/docs/commands/email-mark-read), [`nylas email mark-starred`](https://cli.nylas.com/docs/commands/email-mark-starred), and [`nylas email list`](https://cli.nylas.com/docs/commands/email-list).

## How do you mark a single email?

You mark one message with `nylas email mark` plus the state and the message ID: `nylas email mark read msg_abc123` sets it read, `unread` clears the flag, and `starred` adds a star or flag. There's an equivalent `nylas email mark-read --id MSG_ID` form if you prefer named flags. Get the ID from any list or search first, then flip the state in one command.

The change writes straight to the provider, so it shows up in Gmail or Outlook immediately — this isn't a local cache. Read state maps to the provider's own flag: the IMAP `\Seen` system flag defined in [RFC 9051](https://datatracker.ietf.org/doc/html/rfc9051) for IMAP accounts, and the equivalent on Gmail and Graph. Starred maps to Gmail's star and to the flag on Outlook and Exchange.

```bash
# Flip a single message's state
nylas email mark read    msg_abc123
nylas email mark unread  msg_abc123
nylas email mark starred msg_abc123

# Equivalent alias with a named flag
nylas email mark-read --id msg_abc123
```

## How do you mark many emails at once?

Bulk-update by listing the messages as JSON, extracting their IDs with `jq`, and looping the mark command. To mark everything unread as read, pipe `nylas email list --unread --json` into a loop — a one-liner that clears an inbox of hundreds of unread messages in one pass. The same shape works off a search, so you can target by sender, subject, or date.

Scope the selection before you run it, because bulk state changes are easy to over-apply. Print the subjects first to confirm you're hitting the right set, then run the loop. Marking by search — say, star everything from your CEO — turns a tedious manual sweep into a single filtered command across whichever provider is connected.

```bash
# Mark every unread message as read
nylas email list --unread --json \
  | jq -r '.[].id' \
  | while read -r id; do nylas email mark read "$id"; done

# Star everything from a specific sender
nylas email list --from ceo@company.com --json \
  | jq -r '.[].id' \
  | xargs -I{} nylas email mark starred {}
```

## How do you mark a whole thread?

To mark an entire conversation rather than one message, the threads command sets state across the thread in one call. `nylas email threads mark <thread-id> --read` marks every message in the thread read, which is what you usually want — reading the latest reply should clear the whole conversation, not leave older messages bolded. Find thread IDs the same way you find message IDs, in the JSON output of a list or search.

This matters for triage agents and scripts that process conversations, not individual messages. Clearing a thread keeps the unread count honest, so a downstream “how many unread conversations” metric reflects reality. For interactive thread work, see the dedicated threads guide.

## Next steps

- [Email threads from the CLI](https://cli.nylas.com/guides/email-threads-cli) — work whole conversations
- [Move emails between folders](https://cli.nylas.com/guides/move-emails-between-folders) — organize after marking
- [Delete emails from the terminal](https://cli.nylas.com/guides/delete-emails-from-terminal) — clean up in bulk
- [Build an AI email triage agent](https://cli.nylas.com/guides/build-ai-email-triage-agent) — mark state from an agent
- [Draft email with smart compose](https://cli.nylas.com/guides/smart-compose-email-cli) — generate a draft from a prompt
- [Full command reference](https://cli.nylas.com/docs/commands) — every flag and subcommand documented
