Read and follow chats
Read your chats from the CLI or the HTTP API. Add --json to a wx command when a script will parse the output. With several accounts, add --account ID or an alias.
List and read chats
-
List recent chats. Each row shows unread counts:
Terminal window wx chats list --limit 20Name Chat ID Kind Unread Last messageBook club books@chatroom group 2 See you FridayIf another page is available, the output shows a cursor. Pass it with
--cursor CURSOR. -
Read one chat, including its muted and pinned settings:
Terminal window wx chats get CHAT_ID -
Read messages in a chat. The newest come first. Page with
--cursor:Terminal window wx messages list CHAT_ID --limit 50The table shows the sender, a preview, the time and a short message ID. A note appears below it if history is partial. Add
--jsonfor full text and IDs.
-
List chats. Each item includes
muted,pinnedand alastMessagepreview:Terminal window curl -H "Authorization: Bearer $TOKEN" "$WX/accounts/$ACCOUNT/threads?limit=20" -
Read messages in one chat:
Terminal window curl -H "Authorization: Bearer $TOKEN" "$WX/accounts/$ACCOUNT/threads/filehelper/messages?limit=50"
Lists return { "items": [...], "nextCursor": "..." }. Pass cursor= with the same query to get the next page.
filehelper is your File Transfer chat, which is handy for testing. For contacts, see Find and manage contacts; for groups and their members, see Manage groups.
Search
Find a chat by its name or ID:
wx chats find "Book club"The CLI has no command for searching message text. Use the HTTP API for that.
Search the saved messages of every chat in the account:
curl -H "Authorization: Bearer $TOKEN" "$WX/accounts/$ACCOUNT/messages?query=invoice"Search ignores letter case, and every word must match, so invoice march finds messages containing both words.
Pin chats
wx chats pin CHAT_ID --idempotency-key pin-001wx chats unpin CHAT_ID --idempotency-key unpin-001If the response is lost, run the same command again with the same key.
curl -X PUT -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -H "Idempotency-Key: pin-001" -d '{"pinned": true}' \ "$WX/accounts/$ACCOUNT/threads/CHAT_ID/pin"The token needs admin scope. The response is an operation. Pinned chats appear first in a new chat list.
Pinning works on ordinary direct chats and groups already in your chat list. To mute a direct chat, use wx chats mute or wx chats unmute with the same key option; for groups, see Manage groups.
Follow new messages
Print events as they arrive:
wx events watch --cursor-file ~/.cache/wx-events.cursorAdd --json for one JSON event per line. The first run starts from the newest event, and the cursor file lets the next run resume. To use a cursor you saved yourself, pass --after CURSOR. To list recent events without watching, run wx events list.
-
Open the event stream:
Terminal window curl -N -H "Authorization: Bearer $TOKEN" "$WX/accounts/$ACCOUNT/events/stream?newest=true" -
A new message arrives as a
message.committedevent. Fetch it withGET /messages/{messageId}. -
After you’ve handled events, save your progress with
POST /consumers/{name}/ackand a body of{"cursor": "..."}. To resume after a disconnect, reconnect with?after=CURSOR. Always start the first request withnewest=true: without a cursor the stream starts at the beginning of the log and fails withevent_cursor_expiredonce there are more than 10,000 events.
Mark a chat read
-
Read the chat to get its current read-state version:
Terminal window wx chats get CHAT_ID -
Mark the whole chat read, passing that version:
Terminal window wx chats read CHAT_ID --expected-version VERSION
-
Read the chat. Its
readStateVersionis the version to send. -
Mark it read:
Terminal window curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \-d '{"expectedVersion": "VERSION"}' \"$WX/accounts/$ACCOUNT/threads/CHAT_ID/read-state"
This marks the whole chat read on your other devices too. If the chat changed since you read it, the request is refused. Read the chat again and retry.