Skip to main content
The ChatActions feature provides methods for managing chat organization through archiving, pinning, muting, starring messages, marking chats as read, deleting chats, and deleting individual messages. These operations sync across all your devices via WhatsApp’s app state sync mechanism.

Access

Access chat action operations through the client:

Archive

archive_chat

Archive a chat to hide it from the main chat list.
Parameters:
  • jid - The chat JID to archive
  • message_range - Optional message range for multi-device conflict resolution. Pass None in most cases
Example:

unarchive_chat

Unarchive a chat to show it in the main chat list.
Parameters:
  • jid - The chat JID to unarchive
  • message_range - Optional message range for multi-device conflict resolution. Pass None in most cases
Example:

Pin

pin_chat

Pin a chat to keep it at the top of the chat list.
Parameters:
  • jid - The chat JID to pin
Example:
WhatsApp limits the number of pinned chats. Attempting to pin too many chats may fail.

unpin_chat

Unpin a chat.
Parameters:
  • jid - The chat JID to unpin
Example:

Mute

mute_chat

Mute a chat indefinitely.
Parameters:
  • jid - The chat JID to mute
Example:

mute_chat_until

Mute a chat until a specific time.
Parameters:
  • jid - The chat JID to mute
  • mute_end_timestamp_ms - Unix timestamp in milliseconds when mute expires (must be in the future)
Example:

unmute_chat

Unmute a chat.
Parameters:
  • jid - The chat JID to unmute
Example:

Star messages

star_message

Star a message to mark it as important.
Parameters:
  • chat_jid - The chat containing the message
  • participant_jid - For group messages from others, pass Some(&sender_jid). For 1-on-1 chats or your own messages, pass None
  • message_id - The message ID to star
  • from_me - Whether the message was sent by you
Example:
For group messages not sent by you, participant_jid is required. The method will return an error if it’s not provided.

unstar_message

Remove the star from a message.
Parameters: Same as star_message. Example:

Mark chat as read

mark_chat_as_read

Mark a chat as read or unread. This is distinct from mark_as_read (IQ receipts) — it syncs the read/unread state across all linked devices.
Parameters:
  • jid - The chat JID to mark
  • read - true to mark as read, false to mark as unread
  • message_range - Optional message range for multi-device conflict resolution. Pass None in most cases
Example:
This syncs the read/unread badge across linked devices via app state sync (regular_low collection). To send read receipts to the sender, use client.mark_as_read() instead.

Delete chat

delete_chat

Delete a chat from the chat list across all linked devices.
Parameters:
  • jid - The chat JID to delete
  • delete_media - Whether to also delete downloaded media files
  • message_range - Optional message range for multi-device conflict resolution. Pass None in most cases
Example:
This operation is not reversible. The chat and optionally its media will be removed from all linked devices.

Clear chat

clear_chat

Clear a chat’s messages while keeping the chat itself (WhatsApp Web’s “Clear chat”). Unlike delete_chat, the chat stays in the list — only its messages are removed. Syncs across all linked devices.
Parameters:
  • jid - The chat JID to clear
  • delete_starred - Also remove starred messages
  • delete_media - Also remove downloaded media files
  • message_range - Optional message range for multi-device conflict resolution. Pass None in most cases
Both flags are encoded in the mutation index (not the proto body), matching WhatsApp Web’s clearChat action. Example:
A clear performed on another linked device arrives as an Event::ClearChatUpdate.

Save contact

save_contact

Save or rename a contact, syncing the name to your other linked devices (WhatsApp Web’s contact-sync action).
Parameters:
  • jid - The contact’s JID. Must be a bare phone-number JID — LIDs and device-specific JIDs are rejected (LID contacts use a separate path on WhatsApp Web).
  • full_name - Full display name, or None
  • first_name - Short name, or None (omitted when absent; WhatsApp Web derives no default)
  • save_on_primary_addressbook - Whether to save the name to the phone’s address book
Example:

Status mute

set_user_status_mute

Mute or unmute a contact, group, or channel’s status updates across linked devices (WhatsApp Web’s userStatusMute). This is distinct from mute_chat, which silences a chat’s message notifications.
Parameters:
  • jid - The entity whose status updates to mute/unmute
  • muted - true hides their status updates, false unmutes
Example:
A status-mute change on another linked device arrives as an Event::UserStatusMuteUpdate.

Delete message for me

delete_message_for_me

Delete a specific message locally (not for the other party). This is different from revoke_message which deletes for everyone.
Parameters:
  • chat_jid - The chat containing the message
  • participant_jid - For group messages from others, pass Some(&sender_jid). For 1-on-1 chats or your own messages, pass None
  • message_id - The ID of the message to delete
  • from_me - Whether the message was sent by you
  • delete_media - Whether to also delete the associated media file
  • message_timestamp - Optional timestamp of the message
Example:
For group messages not sent by you, participant_jid is required. The method will return an error if it’s not provided.
This only removes the message from your own devices. The other party can still see the message. To delete for everyone, use client.revoke_message() instead.

Helper functions

message_range

Construct a SyncActionMessageRange for multi-device conflict resolution. In most cases you can pass None instead — only WhatsApp Web with a full message database populates this.

message_key

Construct a MessageKey for use with message_range.

Generic app state action

send_app_state_action

Send any syncd (app state) Set action, driven by a generated schema from the whatsapp_rust::schemas registry. Use this as the escape hatch when there isn’t a dedicated helper yet (for example, clear_chat, favorites, quick_reply). The typed methods on ChatActions and Labels are thin wrappers over this same call.
Parameters:
  • schema — A &Schema constant from whatsapp_rust::schemas (re-exported from wacore::appstate::schemas). The schema decides the collection, action version, and index shape.
  • index_args — The non-literal index parts in the order declared by schema.index_parts. Literal slots (the action name prefix) are filled automatically.
  • value — A wa::SyncActionValue with the matching action sub-field set and a timestamp in epoch milliseconds.
When to use it:
  • The action you need does not have a typed helper on ChatActions or Labels.
  • You need to interoperate with a schema added to the registry without waiting for a new helper to land.
Prefer the typed wrappers (pin_chat, mute_chat, archive_chat, label methods, etc.) whenever they exist — they handle the timestamp, conflict-resolution fields, and index args for you. Example:
Index arguments are positional and must match schema.index_parts length and order, excluding IndexPart::Literal slots. Mismatched arity returns an error before any patch is sent.

App state sync

All chat actions are synced across devices using WhatsApp’s app state synchronization:
App state sync requires encryption keys to be available. These are typically obtained during initial sync after authentication. Actions may fail if called immediately after pairing before sync completes.

Events

Chat action changes are emitted as events that you can handle:

Error handling

All methods return Result<(), AppStateError>:
You’ll encounter these most often:
  • InvalidRequest — you passed an invalid timestamp to mute_chat_until or omitted participant_jid for a group operation
  • Internal — no app state sync key is available yet (sync not complete), or a network error occurred

Complete example

See also

  • Events - Handle chat action update events
  • Groups - Group management operations
  • Client - Core client API