# List email messages

Returns email messages, one page at a time.

```http
GET https://api.pozy.ai/v1/email/messages
```

- Area: Email, calendar & files / Email
- Auth: Authorization: Bearer pz_live_...

## Query parameters

- `accountId` (string, required)
- `folder` (string)
- `unread` (boolean)
- `starred` (boolean)
- `hasAttachment` (boolean)
- `subject` (string)
- `from` (string)
- `to` (string)
- `cc` (string)
- `bcc` (string)
- `anyEmail` (string)
- `after` (string (date-time))
- `before` (string (date-time))
- `searchQueryNative` (string)
- `sortOrder` (string): one of asc, desc
- `cursor` (string)
- `limit` (integer)

## Example request

```bash
curl -X GET "https://api.pozy.ai/v1/email/messages?accountId=696e0b682d0a31188e7a2ba9&limit=50" \
  -H "Authorization: Bearer $POZY_API_KEY"
```

```ts
const res = await fetch("https://api.pozy.ai/v1/email/messages?accountId=696e0b682d0a31188e7a2ba9&limit=50", {
  headers: { Authorization: `Bearer ${process.env.POZY_API_KEY}` },
});
const data = await res.json();
if (!res.ok) throw new Error(data?.error ?? `Request failed with status ${res.status}`);
console.log(data);
```

```python
import os
import requests

resp = requests.get(
    "https://api.pozy.ai/v1/email/messages",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    params={
        "accountId": "696e0b682d0a31188e7a2ba9",
        "limit": 50,
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 200

- `data`, array of object
  - `id`, string
  - `threadId`, string
  - `accountId`, string
  - `provider`, string: One of `google`, `microsoft`
  - `folders`, array of string
  - `from`, object
    - one of: Email Address
      - `email`, string (email), required
      - `name`, string: Can be null
  - `to`, array of object
    - `email`, string (email), required
    - `name`, string: Can be null
  - `cc`, array of object
    - `email`, string (email), required
    - `name`, string: Can be null
  - `bcc`, array of object
    - `email`, string (email), required
    - `name`, string: Can be null
  - `replyTo`, array of object
    - `email`, string (email), required
    - `name`, string: Can be null
  - `subject`, string
  - `snippet`, string
  - `text`, string: Can be null
  - `html`, string: Can be null
  - `attachments`, array of object
    - `id`, string
    - `filename`, string
    - `contentType`, string
    - `size`, integer
    - `isInline`, boolean
    - `contentId`, string: Can be null
  - `headers`, map of string
  - `raw`, string
  - `date`, string (date-time)
  - `unread`, boolean
  - `starred`, boolean
  - `metadata`, map of string
- `pagination`, object
  - `hasMore`, boolean
  - `nextCursor`, string: Can be null
- `meta`, object
  - `filteredClientSide`, array of string

```json
{
  "data": [
    {
      "id": "6bfebd43ddc270f6d2c56fc5",
      "threadId": "60186572e25ff711298bf12e",
      "accountId": "696e0b682d0a31188e7a2ba9",
      "provider": "google",
      "folders": [
        "string"
      ],
      "from": {
        "email": "alex@example.com",
        "name": "Acme"
      },
      "to": [
        {
          "email": "alex@example.com",
          "name": "Acme"
        }
      ],
      "cc": [
        {
          "email": "alex@example.com",
          "name": "Acme"
        }
      ],
      "bcc": [
        {
          "email": "alex@example.com",
          "name": "Acme"
        }
      ],
      "replyTo": [
        {
          "email": "alex@example.com",
          "name": "Acme"
        }
      ],
      "subject": "string",
      "snippet": "string",
      "text": "Hello from Pozy",
      "html": "string",
      "attachments": [
        {
          "id": "6bfebd43ddc270f6d2c56fc5",
          "filename": "photo.jpg",
          "contentType": "image/jpeg",
          "size": 482133,
          "isInline": true,
          "contentId": "6e56e1ad0e43e2da5ef935a5"
        }
      ],
      "headers": {
        "key": "string"
      },
      "raw": "string",
      "date": "2026-10-02T09:00:00.000Z",
      "unread": true,
      "starred": true,
      "metadata": {
        "key": "string"
      }
    }
  ],
  "pagination": {
    "hasMore": true,
    "nextCursor": "string"
  },
  "meta": {
    "filteredClientSide": [
      "string"
    ]
  }
}
```
