search_messages
Searches the text and captions of messages from the last 90 days, across all chats or within one chat, using full-text search. Returns { chats, senders?, messages }, newest first: each message has its id, timestamp, chat_jid, sender and text; chats maps each chat_jid to its chat and, for group messages, senders maps each sender_jid to that sender, both with the contact fields (name; name_source: address_book, push_name, group_subject, business, phone or unresolved; canonical_jid: the JID to pass to send_message and read_chat_history; phone_jid and lid_jid: the chat's phone-number and LID forms, null when unknown or for groups; phone_display: the number as +). Media shows up as e.g. "[voice note, 0:42]" or "[image] caption", but only captions are searchable. An edited message is found and shown by its latest text, with edited: true. Texts longer than about 300 characters are shortened around the match (text_truncated: true); read the chat with read_chat_history for the whole message. A page holds up to limit matches but stops early when they are long; when more may exist, the headline gives the before to pass for the next, older page. For messages older than 90 days or to browse a chat, use read_chat_history.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Optional. Maximum number of results to return (default 20, max 100). | |
| query | Yes | The text to search for. | |
| before | No | Optional. For the next page: the `id` of the last (oldest) message of the previous results, as the headline gives it. Keep the same query and filters. | |
| chat_jid | No | Optional. Filter by a specific chat: a JID, a phone number with country code, or a contact name. | |
| sender_jid | No | Optional. Filter by who sent the message: a JID (…@s.whatsapp.net or …@lid), a phone number with country code, or a contact name. Every form of the person's number matches. A name that matches several people returns an error listing them. |