# messages.list()

Canonical URL: https://developers.iagenify.com/sdk/ref/mailbox/messages/list/
Language: en

`mailbox.messages.list({ folder?, limit?, cursor?, unread? }) → Promise<Page>`

A folder, newest first. The cursor is a date, not a page number — so a message arriving while you read shifts nothing.

Status: free · 40 by default · summaries, not bodies

```javascript
const { messages, nextCursor, unreadCount } =
  await box.messages.list({ folder: "inbox", limit: 40, unread: true });

while (nextCursor) {
  const page = await box.messages.list({ folder: "inbox", cursor: nextCursor });
}
```

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `folder` | string | inbox | `inbox` · `sent` · `drafts` · `spam` · `trash`. |
| `limit` | integer | 40 | How many. |
| `cursor` | string |  | From the previous page's `nextCursor`. |
| `unread` | boolean | false | Only unread. |

## A date, not a page number {#cursor}

> **Paging by number double-counts on a moving list**
>
> A message arriving between two pages pushes everything down, so page two repeats the last of page one. A date cursor is immune: it means « older than this », and new mail lands above it.

## A summary is not the message {#summaries}

Sender, subject, date, flags, and the sender's picture. No body, no HTML, and `attachments` is a count — a page of forty full messages would be enormous for a list nobody reads in full.

## The sender's picture is in the list {#avatar}

Which is where it is most useful. It is resolved when the message is delivered, not when it is read — so reading a folder is a read of our own data, with nothing fetched from outside.

## unreadCount is for the folder {#unread}

Not for the page. It is the number a badge should show.

- [messages.get()](/sdk/ref/mailbox/messages/get): The whole message.
- [messages.search()](/sdk/ref/mailbox/messages/search): Finding one.

```python
page = box.messages.list(folder="inbox", limit=40, unread=True)
messages, next_cursor, unread_count = page["messages"], page.get("nextCursor"), page.get("unreadCount")

while next_cursor:
    page = box.messages.list(folder="inbox", cursor=next_cursor)
    next_cursor = page.get("nextCursor")
```
