---
title: "Python SDK: Mail"
description: "The methods of the Python client under Mail. Threads, messages, raw and HTML bodies, attachments and their extracted text."
url: https://doorman.fyi/docs/python/reference/mail
markdown: https://doorman.fyi/docs/python/reference/mail.md
area: "SDKs and tools"
section: "Python SDK"
---

# Python SDK: Mail

The methods of the Python client under Mail. Threads, messages, raw and HTML bodies, attachments and their extracted text.

Source: https://doorman.fyi/docs/python/reference/mail

## client.attachments.download

Python:
```python
client.attachments.download(message_id: str, filename: str) -> bytes
```

Operation [`attachments.download`](https://doorman.fyi/docs/reference/mail.md#attachments-download): `GET /v1/attachments/{messageId}/{filename}`

Download an attachment.

Access `any`: any API key, or a console session. An app token needs `mail:read`.

## client.attachments.text

Python:
```python
client.attachments.text(message_id: str, filename: str) -> models.AttachmentText
```

Operation [`attachments.text`](https://doorman.fyi/docs/reference/mail.md#attachments-text): `GET /v1/attachments/{messageId}/{filename}/text`

Read an attachment's text.

Access `any`: any API key, or a console session. An app token needs `mail:read`.

## client.inboxes.messages.list

Python:
```python
client.inboxes.messages.list(inbox_id: str, *, direction: Literal['inbound', 'outbound'] | None = None, limit: int | None = None, offset: int | None = None) -> models.MessageList
```

Operation [`inboxes.messages.list`](https://doorman.fyi/docs/reference/mail.md#inboxes-messages-list): `GET /v1/inboxes/{inboxId}/messages`

List messages.

Access `any`: any API key, or a console session. An app token needs `mail:read`.

## client.inboxes.messages.iterate

Python:
```python
client.inboxes.messages.iterate(inbox_id: str, *, direction: Literal['inbound', 'outbound'] | None = None, limit: int | None = None, offset: int | None = None) -> Iterator[models.Message]
```

Every item of [`client.inboxes.messages.list`](https://doorman.fyi/docs/python/reference/mail.md#inboxes-messages-list), one page at a time: the next page is asked for when the loop reaches it. A page that does not advance raises `ApiError`.

## client.inboxes.threads.list

Python:
```python
client.inboxes.threads.list(inbox_id: str, *, is_read: bool | None = None, q: str | None = None, label: str | None = None, limit: int | None = None, offset: int | None = None) -> models.ThreadPage
```

Operation [`inboxes.threads.list`](https://doorman.fyi/docs/reference/mail.md#inboxes-threads-list): `GET /v1/inboxes/{inboxId}/threads`

List threads.

Access `any`: any API key, or a console session. An app token needs `mail:read`.

## client.inboxes.threads.iterate

Python:
```python
client.inboxes.threads.iterate(inbox_id: str, *, is_read: bool | None = None, q: str | None = None, label: str | None = None, limit: int | None = None, offset: int | None = None) -> Iterator[models.Thread]
```

Every item of [`client.inboxes.threads.list`](https://doorman.fyi/docs/python/reference/mail.md#inboxes-threads-list), one page at a time: the next page is asked for when the loop reaches it. A page that does not advance raises `ApiError`.

## client.inboxes.threads.list_by_seen

Python:
```python
client.inboxes.threads.list_by_seen(inbox_id: str, *, is_seen: bool, q: str | None = None, label: str | None = None, limit: int | None = None, offset: int | None = None) -> models.ThreadPage
```

Operation [`inboxes.threads.listBySeen`](https://doorman.fyi/docs/reference/mail.md#inboxes-threads-listBySeen): `GET /v1/inboxes/{inboxId}/threads/by-seen`

List threads a person has or has not seen.

Access `session`: a console session only; an API key gets 403 `session_required`. App tokens are refused.

## client.inboxes.threads.iterate_list_by_seen

Python:
```python
client.inboxes.threads.iterate_list_by_seen(inbox_id: str, *, is_seen: bool, q: str | None = None, label: str | None = None, limit: int | None = None, offset: int | None = None) -> Iterator[models.Thread]
```

Every item of [`client.inboxes.threads.list_by_seen`](https://doorman.fyi/docs/python/reference/mail.md#inboxes-threads-listBySeen), one page at a time: the next page is asked for when the loop reaches it. A page that does not advance raises `ApiError`.

## client.messages.get

Python:
```python
client.messages.get(message_id: str) -> models.Message
```

Operation [`messages.get`](https://doorman.fyi/docs/reference/mail.md#messages-get): `GET /v1/messages/{messageId}`

Read a message.

Access `any`: any API key, or a console session. An app token needs `mail:read`.

## client.messages.html

Python:
```python
client.messages.html(message_id: str) -> str
```

Operation [`messages.html`](https://doorman.fyi/docs/reference/mail.md#messages-html): `GET /v1/messages/{messageId}/html`

Read the HTML body.

Access `any`: any API key, or a console session. An app token needs `mail:read`.

## client.messages.raw

Python:
```python
client.messages.raw(message_id: str) -> bytes
```

Operation [`messages.raw`](https://doorman.fyi/docs/reference/mail.md#messages-raw): `GET /v1/messages/{messageId}/raw`

Download the original message.

Access `any`: any API key, or a console session. An app token needs `mail:read`.

## client.threads.get

Python:
```python
client.threads.get(thread_id: str) -> models.Thread
```

Operation [`threads.get`](https://doorman.fyi/docs/reference/mail.md#threads-get): `GET /v1/threads/{threadId}`

Read a thread.

Access `any`: any API key, or a console session. An app token needs `mail:read`.

## client.threads.messages

Python:
```python
client.threads.messages(thread_id: str) -> models.ThreadMessages
```

Operation [`threads.messages`](https://doorman.fyi/docs/reference/mail.md#threads-messages): `GET /v1/threads/{threadId}/messages`

Read a thread's messages.

Access `any`: any API key, or a console session. An app token needs `mail:read`.

## client.threads.restore

Python:
```python
client.threads.restore(thread_id: str) -> models.Thread
```

Operation [`threads.restore`](https://doorman.fyi/docs/reference/mail.md#threads-restore): `POST /v1/threads/{threadId}/restore`

Restore a trashed thread.

Access `session`: a console session only; an API key gets 403 `session_required`. App tokens are refused.

## client.threads.seen

Python:
```python
client.threads.seen(thread_id: str, body: models.SetThreadSeen) -> models.Thread
```

Operation [`threads.seen`](https://doorman.fyi/docs/reference/mail.md#threads-seen): `PUT /v1/threads/{threadId}/seen`

Mark a thread seen.

Access `session`: a console session only; an API key gets 403 `session_required`. App tokens are refused.

## client.threads.trash

Python:
```python
client.threads.trash(thread_id: str) -> None
```

Operation [`threads.trash`](https://doorman.fyi/docs/reference/mail.md#threads-trash): `DELETE /v1/threads/{threadId}`

Trash a thread.

Access `any`: any API key, or a console session. An app token needs `mail:write` and `mail:read`.

## client.threads.update

Python:
```python
client.threads.update(thread_id: str, body: models.UpdateThread) -> models.Thread
```

Operation [`threads.update`](https://doorman.fyi/docs/reference/mail.md#threads-update): `PATCH /v1/threads/{threadId}`

Update a thread.

Access `any`: any API key, or a console session. An app token needs `mail:write` and `mail:read`.
