Sample - Slack Web API
GET/search.messages

Search messages

Searches messages matching the required query string. Use count and page to control result pages, sort and sort_dir to order matches, and highlight to include query highlight markers. The response confirms whether the search request completed successfully.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

7 parameters
tokenstringrequired
Authentication token with the `search:read` scope.
countintegeroptional
The number of results to request per page. Maximum 100.
highlightbooleanoptional
Set to true to enable query highlight markers in matching results.
pageintegeroptional
The result page to retrieve.
querystringrequired
The message search query.
sortstringoptional
Sort matches by `score` or `timestamp`.
sort_dirstringoptional
Sort results in ascending (`asc`) or descending (`desc`) order.

2 status codes
200Returns a successful search response. Depending on the method response mode, the body may contain only the `ok` flag or additional search result details.
okbooleanrequired
Allowed:true
defaultTypical error response
okbooleanrequired
Allowed:false

Error handling

The token must grant the search:read scope, and query must contain the search expression. count must not exceed 100, sort must be score or timestamp, and sort_dir must be asc or desc when supplied.