Python SDK: Mail

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

client.attachments.download

Python

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

Sends 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

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

Sends 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

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

Sends 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

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, 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

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

Sends 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

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, 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

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

Sends 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

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, 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

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

Sends 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

client.messages.html(message_id: str) -> str

Sends 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

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

Sends 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

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

Sends 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

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

Sends 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

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

Sends 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

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

Sends 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

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

Sends 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

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

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

Up Down to move, Enter to open, Esc to close