> ## Documentation Index
> Fetch the complete documentation index at: https://docs.r28.ai/charter/llms.txt
> Use this file to discover all available pages before exploring further.

# search_messages

> Search messages across the workspace. Supports Slack search modifiers such as 'in:#channel', 'from:@user' and 'after:YYYY-MM-DD'. Requires a user token with the search:read scope — a bot token cannot call this.

<div className="tool-route"><span className="tool-row-method" data-method="GET">GET</span><code>{"https://slack.com/api/search.messages"}</code></div>

```python slack_search_messages.py theme={null}
from charter.packs import slack

result = await slack.search_messages.ainvoke({"query": ...})
```

<Note>
  Requires `chat:write`, `channels:read`, `groups:read`, `im:read`, `mpim:read`, `channels:history`, `groups:history`, `im:history`, `mpim:history`, `users:read`, `reactions:write`. Pages by cursor: `response_metadata.next_cursor` is sent back as `cursor`.
</Note>

## Query parameters

<div className="reference-table">
  | Field                                                         | Type                                                               | Description                                                                                                                            |
  | ------------------------------------------------------------- | ------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
  | `query` <span className="required" title="required">\*</span> | `string`                                                           | Search query. Supports Slack's search modifiers, e.g. 'in:#engineering from:@ada after:2026-01-01'.                                    |
  | `count`                                                       | `integer`                                                          | Number of items to return per page. Maximum of 100. <span className="field-constraints">≥ 1; ≤ 100; defaults to `20`</span>            |
  | `page`                                                        | `integer`                                                          | Page number of results to return. <span className="field-constraints">≥ 1; ≤ 100; defaults to `1`</span>                               |
  | `cursor`                                                      | `string`                                                           | Use this when getting results with cursormark pagination. Set to '\*' for the first call and use the value of next\_cursor thereafter. |
  | `sort`                                                        | [SearchSort](/charter/charter/packs/slack/search/objects#searchsort)       | Return matches sorted by either 'score' or 'timestamp'.                                                                                |
  | `sortDir`                                                     | [SearchSortDir](/charter/charter/packs/slack/search/objects#searchsortdir) | Change sort direction to ascending ('asc') or descending ('desc').                                                                     |
  | `highlight`                                                   | `boolean`                                                          | Pass a value to enable query highlight markers.                                                                                        |
  | `teamId`                                                      | `string`                                                           | Encoded team id to search in. Required if the token belongs to an org-wide app.                                                        |
</div>
