Danger. Danger. High Voltage. Give your codex/claude access to WhatsApp
Danger. Danger. High Voltage. Give your codex/claude access to WhatsApp
For Humans & LLMs: This document covers the WhatsApp CLI tool: installation, usage, the API reference, examples, architecture, and troubleshooting. Humans and large language models can both read it.
Version: 1.3.2 Repository: https://github.com/vicentereig/whatsapp-cli License: MIT Language: Go 1.24+
WhatsApp CLI is a standalone command-line tool for WhatsApp. It uses the WhatsApp Web multidevice protocol. Every command returns structured JSON output. Use it for:
| Feature | Description |
|---|---|
| Zero Dependencies | Single compiled binary (21MB), no runtime required |
| JSON Output | All commands return structured JSON for easy parsing |
| Persistent Sessions | Authenticate once via QR code, auto-reconnect for ~20 days |
| Local Storage | SQLite database, no cloud dependencies |
| Full Messaging | Send, receive, search messages; manage contacts & chats |
| Group Support | Send/receive messages in group chats |
| TDD Implementation | 100% test coverage, production-ready |
brew install vicentereig/tap/whatsapp-cliOr tap first, then install:
brew tap vicentereig/tap
brew install whatsapp-cli…# Clone repository
git clone https://github.com/vicentereig/whatsapp-cli.git
cd whatsapp-cli
# Install dependencies
go mod download
# Build
go build -o whatsapp-cli .
# Install (optional)
sudo mv whatsapp-cli /usr/local/bin/
# Verify installation
whatsapp-cli --helpgo install github.com/vicentereig/whatsapp-cli@latestvMAJOR.MINOR.PATCH). For reproducible builds, use a specific tag, for example v1.0.0, with go install github.com/vicentereig/[email protected].checksums.txt. Before you install, run shasum -a 256 -c checksums.txt --ignore-missing to verify the archive.whatsapp-cli-- (Windows adds .exe). After you extract the file, mark it executable with chmod +x and place it in your PATH, for example /usr/local/bin/whatsapp-cli.checksums.txt, also has a Sigstore cosign signature (.sig) and certificate (.pem). To verify a file, run cosign verify-blob --certificate .pem --signature .sig . GitHub Actions uses OIDC identities, so you can enforce provenance during verification.docs/RELEASE.md. It covers go install, source builds, and GitHub Release automation.whatsapp-cli authWhat happens:
./store/whatsapp.dbOutput:
{
"success": true,
"data": {
"authenticated": true,
"message": "Successfully authenticated"
},
"error": null
}Session Duration: ~20 days before re-authentication required
Before you list or search messages, sync them from WhatsApp:
# Start syncing messages (run this in the background or a separate terminal)
whatsapp-cli sync
# Press Ctrl+C when done syncingWhat happens:
./store/messages.dbTip: Run sync in a tmux or screen session, or as a background service, so it keeps receiving messages.
# List your chats
whatsapp-cli chats list --limit 10
# Search for a contact
whatsapp-cli contacts search --query "John"
# Send a message
whatsapp-cli send --to 1234567890 --message "Hello from CLI!"
# Search messages
whatsapp-cli messages search --query "meeting"whatsapp-cli versionExample Output:
{
"success": true,
"data": {
"version": "v1.1.0"
},
"error": null
}All commands support these global flags:
| Flag | Type | Default | Description |
|---|---|---|---|
--store |
string | ./store |
Directory for session and message databases |
Example:
whatsapp-cli --store /var/lib/whatsapp chats listauthAuthenticate with WhatsApp via QR code.
Syntax:
whatsapp-cli authParameters: None
Returns:
{
"success": true,
"data": {
"authenticated": boolean,
"message": string
},
"error": null
}Behavior:
store/whatsapp.db with session dataExample:
whatsapp-cli auth
# Scan QR code with phone
# ✓ Successfully authenticated!sync⚠️ IMPORTANT: Run this command to fill the message database. If you do not run sync, messages list and messages search return empty results.
Sync messages from WhatsApp to the local database continuously. This command:
Syntax:
whatsapp-cli syncParameters: None
Returns: (on exit via Ctrl+C)
{
"success": true,
"data": {
"synced": true,
"messages_count": 1234
},
"error": null
}Behavior:
*events.Message for real-time messages*events.HistorySync for message history batchesstore/messages.dbProgress Output (stderr):
Starting WhatsApp sync...
✓ Connected to WhatsApp
Listening for messages... (Press Ctrl+C to stop)
Processing history sync (42 conversations)...
Synced 1234 messages...
^C
✓ Sync completed. Total messages synced: 1234Examples:
# Basic sync - run in foreground
whatsapp-cli sync
# Run in background (recommended for continuous syncing)
whatsapp-cli sync > sync.json 2> sync.log &
# Run in tmux/screen session
tmux new -s whatsapp
whatsapp-cli sync
# Detach with Ctrl+B D
# Run with custom storage directory
whatsapp-cli --store /var/lib/whatsapp sync
# Stop sync gracefully
kill -INT
# Or press Ctrl+C in foregroundUse Cases:
Notes:
messages listList messages from all chats or a specific chat.
Syntax:
whatsapp-cli messages list [OPTIONS]Parameters:
| Flag | Type | Required | Default | Description |
|---|---|---|---|---|
--chat |
string | No | - | Filter by chat JID (e.g., [email protected]) |
--limit |
int | No | 20 | Maximum number of messages to return |
--page |
int | No | 0 | Page number for pagination (0-indexed) |
Returns:
{
"success": true,
"data": [
{
"id": "msg_unique_id",
"chat_jid": "[email protected]",
"chat_name": "John Doe",
"sender": "1234567890",
"content": "Message text content",
"timestamp": "2025-10-26T10:30:00Z",
"is_from_me": false,
"media_type": ""
}
],
"error": null
}Examples:
# List 50 most recent messages across all chats
whatsapp-cli messages list --limit 50
# List messages from specific chat
whatsapp-cli messages list --chat [email protected]
# Pagination: Get second page of results
whatsapp-cli messages list --limit 20 --page 1
# Get JID first, then list messages
JID=$(whatsapp-cli contacts search --query "Alice" | jq -r '.data[0].jid')
whatsapp-cli messages list --chat "$JID" --limit 100Sorting: Messages returned in reverse chronological order (newest first)
messages searchSearch messages by content across all chats.
Syntax:
whatsapp-cli messages search --query TEXT [OPTIONS]Parameters:
| Flag | Type | Required | Default | Description |
|---|---|---|---|---|
--query |
string | Yes | - | Search term (case-insensitive, partial match) |
--limit |
int | No | 20 | Maximum number of results |
--page |
int | No | 0 | Page number for pagination |
Returns: Same format as messages list
Examples:
# Search for messages containing "meeting"
whatsapp-cli messages search --query "meeting"
# Search with more results
whatsapp-cli messages search --query "project" --limit 100
# Case-insensitive search
whatsapp-cli messages search --query "URGENT" # Finds "urgent", "Urgent", etc.Search Behavior:
contacts searchSearch contacts by name or phone number.
Syntax:
whatsapp-cli contacts search --query TEXTParameters:
| Flag | Type | Required | Default | Description |
|---|---|---|---|---|
--query |
string | Yes | - | Search term for name or phone number |
Returns:
{
"success": true,
"data": [
{
"phone_number": "1234567890",
"name": "John Doe"No open issues yet, or sync has not completed.