Skip to main content

Message Search

Search across all your notifications — emails, push notifications, SMS, and in-app messages — from a single endpoint. Full-text search with filtering, faceted counts, and result highlighting.

Overview

FeatureDescription
Full-Text SearchSearch message content, subjects, and metadata
Multi-ChannelSearch across email, push, SMS, and in-app simultaneously
FilteringFilter by channel, status, tags, date range, and metadata
Faceted CountsGet filter counts for building search UIs
HighlightingMatched terms highlighted in results
SuggestionsAutocomplete suggestions as users type

Quick Start

Search Messages

curl -X POST https://api.zyphr.dev/v1/search/messages \
-H "X-API-Key: zy_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"query": "password reset",
"channels": ["email"],
"highlight": true
}'
const results = await zyphr.search.messages({
query: 'password reset',
channels: ['email'],
highlight: true,
});

Search API

POST Search (Full Options)

Use POST for complex queries with multiple filters:

curl -X POST https://api.zyphr.dev/v1/search/messages \
-H "X-API-Key: zy_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"query": "welcome",
"channels": ["email", "push"],
"statuses": ["delivered", "sent"],
"tags": ["onboarding"],
"start_date": "2026-02-01T00:00:00Z",
"end_date": "2026-02-28T23:59:59Z",
"metadata": {
"campaign": "february-launch"
},
"page": 1,
"per_page": 25,
"highlight": true
}'

Search Parameters

ParameterTypeRequiredDescription
querystringYesFull-text search query
channelsstring[]NoFilter by channels: email, push, sms, in_app
statusesstring[]NoFilter by delivery statuses
tagsstring[]NoFilter by message tags
start_datestringNoStart of date range (ISO 8601)
end_datestringNoEnd of date range (ISO 8601)
metadataobjectNoFilter by custom metadata key-value pairs
pagenumberNoPage number (default: 1)
per_pagenumberNoResults per page (default: 25, max: 100)
highlightbooleanNoHighlight matched terms in results (default: false)

GET Search (Simple)

For simpler queries, use the GET endpoint with query parameters:

curl "https://api.zyphr.dev/v1/search/messages?q=welcome&channels=email,push&highlight=true&page=1&per_page=25" \
-H "X-API-Key: zy_live_your_api_key"

Query Parameters

ParameterTypeDescription
qstringSearch query (required, min 1 character)
channelsstringComma-separated channels
statusesstringComma-separated statuses
tagsstringComma-separated tags
start_datestringStart of date range
end_datestringEnd of date range
pagenumberPage number
per_pagenumberResults per page
highlightbooleanEnable highlighting

Response Format

{
"data": {
"results": [
{
"id": "msg_abc123",
"channel": "email",
"subject": "Welcome to Zyphr",
"body_preview": "Thanks for signing up...",
"status": "delivered",
"recipient": "user@example.com",
"created_at": "2026-02-15T10:30:00Z",
"tags": ["onboarding"],
"highlights": {
"subject": "**Welcome** to Zyphr",
"body": "Thanks for signing up to **Zyphr**..."
}
}
],
"total": 142,
"page": 1,
"per_page": 25
}
}

Get filter counts alongside search results — ideal for building search UIs with dynamic filter counts:

curl -X POST https://api.zyphr.dev/v1/search/messages/faceted \
-H "X-API-Key: zy_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"query": "welcome",
"channels": ["email"]
}'

Faceted Response

{
"data": {
"results": [...],
"total": 142,
"facets": {
"channels": {
"email": 98,
"push": 32,
"sms": 8,
"in_app": 4
},
"statuses": {
"delivered": 120,
"sent": 15,
"failed": 7
},
"tags": {
"onboarding": 45,
"transactional": 67,
"marketing": 30
}
}
}
}

Use facets to show users how many results match each filter option before they click.

Search Suggestions

Get autocomplete suggestions as users type:

curl "https://api.zyphr.dev/v1/search/suggestions?prefix=wel&limit=5" \
-H "X-API-Key: zy_live_your_api_key"

Query Parameters

ParameterTypeRequiredDescription
prefixstringYesSearch prefix (minimum 2 characters)
limitnumberNoMaximum suggestions (default: 10)

Response

{
"data": {
"suggestions": [
"welcome email",
"welcome series",
"welcome back"
]
}
}

Best Practices

Search Query Tips

  • Use quotes for exact phrases: "password reset"
  • Search is case-insensitive
  • Combine with filters for precise results

Performance

  • Use date range filters to narrow the search window
  • Use channel filters when you know which channel to search
  • Limit per_page to what you need — smaller pages are faster
  • Use the GET endpoint for simple queries; POST for complex filters

Building Search UIs

  1. Start with the suggestions endpoint for autocomplete
  2. Use faceted search for the main results page with filter counts
  3. Update facets as users apply filters to show remaining counts

API Reference

MethodEndpointDescription
POST/v1/search/messagesFull-text search with filters
GET/v1/search/messagesSimple search with query params
POST/v1/search/messages/facetedSearch with faceted counts
GET/v1/search/suggestionsAutocomplete suggestions

Next Steps