pm-cli is designed for AI agent workflows. All commands support --json output and the full command schema is available via --help-json.
# Get full command schema
pm-cli --help-json
# All operations return JSON
pm-cli mail list --json
pm-cli mail read 123 --json
pm-cli mailbox list --jsonRetrieve the complete command schema:
pm-cli --help-jsonReturns:
{
"name": "pm-cli",
"version": "0.1.0",
"description": "ProtonMail CLI via Proton Bridge IMAP/SMTP",
"commands": [...],
"global_flags": [...]
}pm-cli mail list --unread --jsonResponse:
{
"mailbox": "INBOX",
"count": 5,
"messages": [
{
"uid": 123,
"seq_num": 123,
"from": "sender@example.com",
"subject": "Important update",
"date": "2024-01-15 10:30",
"seen": false,
"flagged": false
}
]
}pm-cli mail read 123 --json
pm-cli mail read uid:456 --json
pm-cli mail read 123 --unread --jsonResponse:
{
"uid": 123,
"seq_num": 123,
"message_id": "<abc@example.com>",
"from": "sender@example.com",
"to": ["recipient@example.com"],
"subject": "Important update",
"date": "2024-01-15 10:30:00",
"flags": ["\\Seen"],
"body": "Plain text content...",
"html_body": "<html>..."
}pm-cli mail send -t recipient@example.com -s "Subject" -b "Body" --jsonResponse:
{
"success": true,
"message": "Email sent successfully",
"to": ["recipient@example.com"],
"subject": "Subject"
}pm-cli mail search "invoice" --from accounts@example.com --jsonpm-cli mail flag 123 --read --json
pm-cli mail flag 123 --star --jsonpm-cli mail move 123 Archive --json
pm-cli mail archive 123 --jsonpm-cli mail delete 123 --json
pm-cli mail delete 123 --permanent --jsonErrors return JSON with success: false:
{
"success": false,
"error": "IMAP login failed: authentication error"
}Exit codes:
0: Success1: Error (check JSON error field)
Messages are identified by sequence number (seq_num), which is the ID shown in mail list. Use this number for mail read, mail delete, mail move, and mail flag.
Note: Sequence numbers can change when messages are deleted. For persistent identification, use the uid field and pass IDs as uid:<uid> (for example pm-cli mail read uid:456 --json).
Common Proton Bridge mailboxes:
INBOX- Primary inboxSent- Sent messagesDrafts- Draft messagesTrash- Deleted messagesSpam- Spam folderArchive- Archived messagesAll Mail- All messagesStarred- Flagged messagesLabels/*- Proton labelsFolders/*- Custom folders
List all with:
pm-cli mailbox list --jsonCommands designed specifically for AI/LLM processing:
pm-cli mail summarize 123 --jsonResponse:
{
"id": "123",
"from": "sender@example.com",
"subject": "Meeting Request",
"summary": "Request to schedule a meeting next Tuesday at 2pm",
"sentiment": "neutral",
"priority": "normal",
"action_required": true
}pm-cli mail extract 123 --jsonResponse:
{
"emails": ["alice@example.com", "bob@example.com"],
"urls": ["https://example.com/doc"],
"dates": ["2024-01-18", "next Tuesday"],
"phone_numbers": ["+1-555-123-4567"],
"action_items": ["Review document", "Confirm attendance"]
}Prevent duplicate sends with idempotency keys:
pm-cli mail send -t user@example.com -s "Alert" -b "..." --idempotency-key "alert-2024-01-15" --jsonKeys are stored locally with 24-hour TTL. Duplicate key returns error without sending.
JSON output includes date_iso field for consistent parsing:
{
"date": "2024-01-15 10:30",
"date_iso": "2024-01-15T10:30:00Z"
}- Always use
--jsonfor programmatic access - Check
successfield in responses - Handle rate limiting - add delays between rapid requests
- Use
uidfor persistence -seq_numchanges on delete - Use
date_isofor date parsing (RFC3339 format) - Use idempotency keys for send operations to prevent duplicates
- Use semantic commands for email triage and data extraction
- Proton Bridge must be running
- Account must be logged in via Bridge
- pm-cli must be configured:
pm-cli config init
pm-cli mailbox list --jsonIf this returns mailboxes, the connection is working.
When ending a work session, you MUST complete ALL steps below. Work is NOT complete until git push succeeds.
MANDATORY WORKFLOW:
- File issues for remaining work - Create issues for anything that needs follow-up
- Run quality gates (if code changed) - Tests, linters, builds
- Update issue status - Close finished work, update in-progress items
- PUSH TO REMOTE - This is MANDATORY:
git pull --rebase bd sync git push git status # MUST show "up to date with origin" - Clean up - Clear stashes, prune remote branches
- Verify - All changes committed AND pushed
- Hand off - Provide context for next session
CRITICAL RULES:
- Work is NOT complete until
git pushsucceeds - NEVER stop before pushing - that leaves work stranded locally
- NEVER say "ready to push when you are" - YOU must push
- If push fails, resolve and retry until it succeeds