Search messages
Search messages in a folder. Filters in body; pagination and sort via query (page, perPage, sort).
Search messages in a folder. Filters in body; pagination and sort via query (page, perPage, sort).
Bearer authentication using API tokens in the Authorization header.
Resource ID of the managed mailbox the bearer token is authorized for.
AC1a2b3c4d5e6f7gFolder path (URL-encoded).
INBOXPage number (1-based).
1Items per page (max 100).
25Sort field with optional - prefix for descending. Allowed: uid, date, size.
-uidSearch criteria. All fields optional. subject, from, to, cc and body are alternatives (a message matching any one of them qualifies); all other fields are combined with AND.
Only messages received on or after this date (YYYY-MM-DD).
2024-01-01Only messages received before this date (YYYY-MM-DD).
2024-12-31Only messages carrying all of these IMAP flags, e.g. \Seen, \Flagged, \Answered, $forwarded.
["\\Seen","\\Flagged"]IMAP UID set: single UID, range (1:100), open range (100:*), or comma-separated list.
1:100Case-insensitive substring match on the Subject header. OR-combined with from/to/cc/body.
meetingCase-insensitive substring match on the From header. OR-combined with subject/to/cc/body.
john@example.comCase-insensitive substring match on the To header. OR-combined with subject/from/cc/body.
jane@example.comCase-insensitive substring match on the Cc header. OR-combined with subject/from/to/body.
team@example.comCase-insensitive substring match on the message body only (headers excluded). OR-combined with subject/from/to/cc.
importantMatch a specific header as Name:value, e.g. X-Custom-Header:value. Value match is a substring.
X-Custom-Header:valueOnly messages larger than this size in bytes.
1024Only messages smaller than this size in bytes.
1048576Case-insensitive substring match across headers and body.
urgentPaginated list of matching messages.
Paginated list of messages.
Missing or invalid credentials.
Token is not authorized to manage the requested mailbox.
Request payload failed validation. params maps field name to an array of error messages.
Server-side failure.
Upstream service is unavailable or returned an unexpected response.
Upstream service did not respond within the configured timeout.
POST /api/v1/mailboxes/{mailboxResourceId}/folders/{folder}/messages/search HTTP/1.1
Host: api.mail.hostinger.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 283
{
"since": "2024-01-01",
"before": "2024-12-31",
"flags": [
"\\Seen",
"\\Flagged"
],
"uid": "1:100",
"subject": "meeting",
"from": "john@example.com",
"to": "jane@example.com",
"cc": "team@example.com",
"body": "important",
"header": "X-Custom-Header:value",
"larger": 1024,
"smaller": 1048576,
"text": "urgent"
}{
"data": [
{
"uid": 123,
"path": "INBOX",
"date": "2024-01-15T10:30:00.000Z",
"flags": [
"\\Seen",
"\\Flagged"
],
"unseen": false,
"size": 2048,
"subject": "Test Email Subject",
"from": {
"name": "John Doe",
"address": "john@example.com"
},
"to": [
{
"name": "John Doe",
"address": "john@example.com"
}
],
"cc": [
{
"name": "John Doe",
"address": "john@example.com"
}
],
"bcc": [
{
"name": "John Doe",
"address": "john@example.com"
}
],
"messageId": "<1234567890@example.com>",
"inReplyTo": "<0987654321@example.com>",
"attachments": [
{
"id": "YXR0YWNobWVudDpJTkJPWDoxMjM6MS4y",
"contentType": "application/pdf",
"sizeBytes": 1024,
"inline": false,
"filename": "document.pdf",
"contentId": "<attachment@example.com>"
}
]
}
],
"pagination": {
"page": 1,
"perPage": 25,
"total": 137,
"totalPages": 6
}
}Last updated
Was this helpful?