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

# TypeScript SDK: Mail

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

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

## client.inboxes.threads.list

TypeScript:
```ts
client.inboxes.threads.list(inboxId: string, params: ListThreadsParams = {}): Promise<ThreadPage>
```

Operation [`inboxes.threads.list`](https://doorman.fyi/docs/reference/mail.md#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

TypeScript:
```ts
client.inboxes.threads.listBySeen(inboxId: string, params: ListThreadsBySeenParams): Promise<ThreadPage>
```

Operation [`inboxes.threads.listBySeen`](https://doorman.fyi/docs/reference/mail.md#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

TypeScript:
```ts
client.inboxes.threads.iterate(inboxId: string, params: ListThreadsParams = {}): AsyncGenerator<Thread, void, undefined>
```

Every thread of the inbox, page by page.

## client.inboxes.messages.list

TypeScript:
```ts
client.inboxes.messages.list(inboxId: string, params: ListMessagesParams = {}): Promise<MessageList>
```

Operation [`inboxes.messages.list`](https://doorman.fyi/docs/reference/mail.md#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

TypeScript:
```ts
client.inboxes.messages.iterate(inboxId: string, params: ListMessagesParams = {}): AsyncGenerator<Message, void, undefined>
```

Every message of the inbox, page by page.

## client.threads.get

TypeScript:
```ts
client.threads.get(threadId: string): Promise<Thread>
```

Operation [`threads.get`](https://doorman.fyi/docs/reference/mail.md#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

TypeScript:
```ts
client.threads.update(threadId: string, body: UpdateThread): Promise<Thread>
```

Operation [`threads.update`](https://doorman.fyi/docs/reference/mail.md#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

TypeScript:
```ts
client.threads.trash(threadId: string): Promise<void>
```

Operation [`threads.trash`](https://doorman.fyi/docs/reference/mail.md#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

TypeScript:
```ts
client.threads.restore(threadId: string): Promise<Thread>
```

Operation [`threads.restore`](https://doorman.fyi/docs/reference/mail.md#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

TypeScript:
```ts
client.threads.seen(threadId: string, body: SetThreadSeen): Promise<Thread>
```

Operation [`threads.seen`](https://doorman.fyi/docs/reference/mail.md#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

TypeScript:
```ts
client.threads.messages(threadId: string): Promise<ThreadMessages>
```

Operation [`threads.messages`](https://doorman.fyi/docs/reference/mail.md#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

TypeScript:
```ts
client.messages.get(messageId: string): Promise<Message>
```

Operation [`messages.get`](https://doorman.fyi/docs/reference/mail.md#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

TypeScript:
```ts
client.messages.raw(messageId: string): Promise<Uint8Array>
```

Operation [`messages.raw`](https://doorman.fyi/docs/reference/mail.md#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

TypeScript:
```ts
client.messages.html(messageId: string): Promise<string>
```

Operation [`messages.html`](https://doorman.fyi/docs/reference/mail.md#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

TypeScript:
```ts
client.attachments.download(messageId: string, filename: string): Promise<Uint8Array>
```

Operation [`attachments.download`](https://doorman.fyi/docs/reference/mail.md#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

TypeScript:
```ts
client.attachments.text(messageId: string, filename: string): Promise<AttachmentText>
```

Operation [`attachments.text`](https://doorman.fyi/docs/reference/mail.md#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`.
