Your agent needs email to communicate with the outside world — sending updates, reading replies, triaging inboxes, extracting data from messages. The Nylas CLI gives your agent full email access across Gmail, Outlook, Exchange, Yahoo, iCloud, and IMAP through simple shell commands that return structured JSON.
Prerequisites
Section titled “Prerequisites”Make sure the CLI is installed and authenticated. If not, follow the AI agents quickstart first.
nylas auth whoami --jsonRead email
Section titled “Read email”List recent messages. Always pass --json for structured output and --limit to control token consumption.
nylas email list --limit 5 --jsonList only unread messages:
nylas email list --unread --limit 10 --jsonRead the full content of a specific message:
nylas email read <MESSAGE_ID> --jsonSend email
Section titled “Send email”Send a message on behalf of the connected user. Always pass --yes to skip the confirmation prompt.
nylas email send \ --subject "Weekly status update" \ --body "Here are this week's highlights..." \ --yesSend with CC and scheduled delivery:
nylas email send \ --subject "Meeting notes" \ --body "Attached are the notes from today's sync." \ --schedule "tomorrow 9am" \ --yesSearch email
Section titled “Search email”Search uses the provider’s native search syntax (Gmail search operators, Microsoft KQL), so queries like from: and has:attachment work as expected.
nylas email search "has:attachment subject:invoice" --limit 10 --jsonManage messages
Section titled “Manage messages”# Mark a message as readnylas email mark read <MESSAGE_ID>
# Star/flag a messagenylas email mark starred <MESSAGE_ID>
# Delete a messagenylas email delete <MESSAGE_ID> --yesExample: inbox triage workflow
Section titled “Example: inbox triage workflow”Here’s a realistic pattern for an agent that triages an inbox:
# 1. Get unread messagesnylas email list --unread --limit 20 --json
# 2. Read the full content of a message that looks importantnylas email read <MESSAGE_ID> --json
# 3. (Agent classifies the message using its LLM)
# 4. Reply to urgent messagesnylas email send \ --subject "Re: Server outage" \ --body "Looking into this now. Will update within the hour." \ --yes
# 5. Mark processed messages as readnylas email mark read <MESSAGE_ID>Using MCP instead
Section titled “Using MCP instead”If your agent supports Model Context Protocol (Claude Code, Cursor, Windsurf, VS Code, Codex CLI), you can register the CLI as an MCP server instead of calling commands directly:
nylas mcp install --assistant claude-codeThis gives your agent typed tools for email operations without subprocess calls. See the MCP docs for details.
What’s next
Section titled “What’s next”- Give your agent calendar access — manage events and check availability
- Give your agent call recordings — record meetings and get transcripts
- AI agents quickstart — full CLI setup and command reference
- CLI guides — 85+ step-by-step guides for email, calendar, and more