TypeScript SDK: Mail
The methods of the TypeScript client under Mail. Threads, messages, raw and HTML bodies, attachments and their extracted text.
client.inboxes.threads.list
client.inboxes.threads.list(inboxId: string, params: ListThreadsParams = {}): Promise<ThreadPage>Sends inboxes.threads.list: GET /v1/inboxes/{inboxId}/threads
The inbox's threads, newest activity first. Trashed threads are left out.
Access any: any API key, or a console session. An app token needs mail:read.
client.inboxes.threads.listBySeen
client.inboxes.threads.listBySeen(inboxId: string, params: ListThreadsBySeenParams): Promise<ThreadPage>Sends inboxes.threads.listBySeen: GET /v1/inboxes/{inboxId}/threads/by-seen
The threads a person has, or has not, looked at in the console. Needs a console session.
Access session: a console session only; an API key gets 403 session_required. App tokens are refused.
client.inboxes.threads.iterate
client.inboxes.threads.iterate(inboxId: string, params: ListThreadsParams = {}): AsyncGenerator<Thread, void, undefined>Every thread of the inbox, page by page.
client.inboxes.messages.list
client.inboxes.messages.list(inboxId: string, params: ListMessagesParams = {}): Promise<MessageList>Sends inboxes.messages.list: GET /v1/inboxes/{inboxId}/messages
The inbox's messages across threads, newest first.
Access any: any API key, or a console session. An app token needs mail:read.
client.inboxes.messages.iterate
client.inboxes.messages.iterate(inboxId: string, params: ListMessagesParams = {}): AsyncGenerator<Message, void, undefined>Every message of the inbox, page by page.
client.threads.get
client.threads.get(threadId: string): Promise<Thread>Sends threads.get: GET /v1/threads/{threadId}
One thread's summary.
Access any: any API key, or a console session. An app token needs mail:read.
client.threads.update
client.threads.update(threadId: string, body: UpdateThread): Promise<Thread>Sends threads.update: PATCH /v1/threads/{threadId}
Read state, replacement metadata or replacement labels. Omitted fields are preserved.
Access any: any API key, or a console session. An app token needs mail:write and mail:read.
client.threads.trash
client.threads.trash(threadId: string): Promise<void>Sends threads.trash: DELETE /v1/threads/{threadId}
The thread and its messages leave every list and read.
Access any: any API key, or a console session. An app token needs mail:write and mail:read.
client.threads.restore
client.threads.restore(threadId: string): Promise<Thread>Sends threads.restore: POST /v1/threads/{threadId}/restore
Takes a trashed thread back out of the trash. Needs a console session; mail that was held or discarded is not restored.
Access session: a console session only; an API key gets 403 session_required. App tokens are refused.
client.threads.seen
client.threads.seen(threadId: string, body: SetThreadSeen): Promise<Thread>Sends threads.seen: PUT /v1/threads/{threadId}/seen
A person's own mark that they looked at the thread. Needs a console session; isRead does not move.
Access session: a console session only; an API key gets 403 session_required. App tokens are refused.
client.threads.messages
client.threads.messages(threadId: string): Promise<ThreadMessages>Sends threads.messages: GET /v1/threads/{threadId}/messages
The thread and its messages in order, oldest first.
Access any: any API key, or a console session. An app token needs mail:read.
client.messages.get
client.messages.get(messageId: string): Promise<Message>Sends messages.get: GET /v1/messages/{messageId}
One message with its text, headers, classification and attachments.
Access any: any API key, or a console session. An app token needs mail:read.
client.messages.raw
client.messages.raw(messageId: string): Promise<Uint8Array>Sends messages.raw: GET /v1/messages/{messageId}/raw
The original message as it arrived (message/rfc822), as bytes. Outbound messages have none.
Access any: any API key, or a console session. An app token needs mail:read.
client.messages.html
client.messages.html(messageId: string): Promise<string>Sends messages.html: GET /v1/messages/{messageId}/html
The stored HTML body as text. 404 when the message has none.
Access any: any API key, or a console session. An app token needs mail:read.
client.attachments.download
client.attachments.download(messageId: string, filename: string): Promise<Uint8Array>Sends attachments.download: GET /v1/attachments/{messageId}/{filename}
The attachment's bytes.
Access any: any API key, or a console session. An app token needs mail:read.
client.attachments.text
client.attachments.text(messageId: string, filename: string): Promise<AttachmentText>Sends attachments.text: GET /v1/attachments/{messageId}/{filename}/text
The extracted text and how it was obtained, or why it was not.
Access any: any API key, or a console session. An app token needs mail:read.

