For the complete documentation index, see llms.txt. This page is also available as Markdown.

Search messages

Search messages in a folder. Filters in body; pagination and sort via query (page, perPage, sort).

Search messages

post

Search messages in a folder. Filters in body; pagination and sort via query (page, perPage, sort).

Authorizations
AuthorizationstringRequired

Bearer authentication using API tokens in the Authorization header.

Path parameters
mailboxResourceIdstringRequired

Resource ID of the managed mailbox the bearer token is authorized for.

Example: AC1a2b3c4d5e6f7g
folderstringRequired

Folder path (URL-encoded).

Example: INBOX
Query parameters
pageinteger · min: 1Optional

Page number (1-based).

Default: 1
perPageinteger · min: 1 · max: 100Optional

Items per page (max 100).

Default: 25
sortstringOptional

Sort field with optional - prefix for descending. Allowed: uid, date, size.

Default: -uid
Body

Search 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.

sincestring · dateOptional

Only messages received on or after this date (YYYY-MM-DD).

Example: 2024-01-01
beforestring · dateOptional

Only messages received before this date (YYYY-MM-DD).

Example: 2024-12-31
flagsstring[]Optional

Only messages carrying all of these IMAP flags, e.g. \Seen, \Flagged, \Answered, $forwarded.

Example: ["\\Seen","\\Flagged"]
uidstringOptional

IMAP UID set: single UID, range (1:100), open range (100:*), or comma-separated list.

Example: 1:100
subjectstring · max: 1024Optional

Case-insensitive substring match on the Subject header. OR-combined with from/to/cc/body.

Example: meeting
fromstring · max: 320Optional

Case-insensitive substring match on the From header. OR-combined with subject/to/cc/body.

Example: john@example.com
tostring · max: 320Optional

Case-insensitive substring match on the To header. OR-combined with subject/from/cc/body.

Example: jane@example.com
ccstring · max: 320Optional

Case-insensitive substring match on the Cc header. OR-combined with subject/from/to/body.

Example: team@example.com
bodystring · max: 1024Optional

Case-insensitive substring match on the message body only (headers excluded). OR-combined with subject/from/to/cc.

Example: important
headerstring · max: 1024Optional

Match a specific header as Name:value, e.g. X-Custom-Header:value. Value match is a substring.

Example: X-Custom-Header:value
largerintegerOptional

Only messages larger than this size in bytes.

Example: 1024
smallerintegerOptional

Only messages smaller than this size in bytes.

Example: 1048576
textstring · max: 1024Optional

Case-insensitive substring match across headers and body.

Example: urgent
Responses
200

Paginated list of matching messages.

application/json

Paginated list of messages.

post/api/v1/mailboxes/{mailboxResourceId}/folders/{folder}/messages/search
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?