> For the complete documentation index, see [llms.txt](https://reno.gitbook.io/smtp-py/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://reno.gitbook.io/smtp-py/messages/usage.md).

# List Messages

Retrieves the collection of Message resources for a given mailbox.

### Mục lục nhanh

* [Ví dụ](#vi-du)
* [Tham số](#tham-so)
* [Giá trị trả về](#gia-tri-tra-ve)

### Ví dụ

```python
from smtppy import SMTPDevClient

client = SMTPDevClient(api_key="YOUR_API_KEY")

messages = client.list_messages(
    account_id="acc_123",
    mailbox_id="mbx_inbox",
    page=1,
)

print(messages)
```

### Tham số

| Tên          | Kiểu  | Bắt buộc | Mặc định | Mô tả                    |
| ------------ | ----- | -------- | -------- | ------------------------ |
| `account_id` | `str` | ✅        | -        | Account identifier.      |
| `mailbox_id` | `str` | ✅        | -        | Mailbox identifier.      |
| `page`       | `int` | ❌        | `1`      | Số trang của collection. |

### Giá trị trả về

`dict[str, Any]` (JSON do API trả về).

```json
{
  "member": [
    {
      "id": "string",
      "msgid": "string",
      "from": {
        "name": "string",
        "address": "string"
      },
      "to": [
        {
          "name": "string",
          "address": "string"
        }
      ],
      "subject": "string",
      "intro": "string",
      "isRead": true,
      "isFlagged": true,
      "hasAttachments": true,
      "size": 0,
      "downloadUrl": "string",
      "createdAt": "2025-04-01T00:00:00.000Z",
      "updatedAt": "2025-04-01T00:00:00.000Z"
    }
  ],
  "totalItems": 0,
  "view": {
    "id": "string",
    "type": "string",
    "first": "string",
    "last": "string",
    "previous": "string",
    "next": "string"
  },
  "search": {
    "type": "string",
    "template": "string",
    "variableRepresentation": "string",
    "mapping": [
      {
        "type": "string",
        "variable": "string",
        "property": "string",
        "required": true
      }
    ]
  }
}
```
