> ## Documentation Index
> Fetch the complete documentation index at: https://docs.automate.ax/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# Get thread

> Retrieve a Gmail thread with every message fully parsed.

`getThread` retrieves one Gmail conversation and parses every message in it. Use it when the relationship between replies matters, rather than loading a single message.

Pass the `threadId` returned by a message, trigger, or [thread search](/reference/integrations/gmail/actions/search-threads). A thread ID is not interchangeable with a message ID.

## Example

```ts automations/read-thread.automation.ts theme={null}
import { automation } from "automate.ax"
import { getThread } from "automate.ax/gmail"

export default automation("Read a Gmail thread", () => {
  getThread({
    threadId: "18f2c7a9b4d12345",
  })
})
```

## Inputs

| Property   | Type                                              | Required | Description                                                                              |
| ---------- | ------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------- |
| `threadId` | `string`                                          | Yes      | Immutable Gmail thread ID.                                                               |
| `account`  | `string \| IntegrationAccountReference<"google">` | No       | Google account binding to use. Defaults to the project's default Google account binding. |

Each input can also be a compatible `Signal` from an earlier trigger or action.

## Output

Returns a `Signal<GmailThread>`:

```ts theme={null}
interface GmailThread {
  threadId: string
  historyId?: string
  messages: Message[]
}

interface Message {
  messageId: string
  threadId: string
  historyId?: string
  labelIds: string[]
  attachments: Attachment[]
  bcc: Mailbox[]
  cc: Mailbox[]
  deliveredTo?: string
  from?: Mailbox
  headers: { name: string; value: string }[]
  html?: string
  inReplyTo?: string
  receivedAt: Date | null
  references: string[]
  replyTo: Mailbox[]
  returnPath?: string
  rfc822MessageId?: string
  sender?: Mailbox
  sentAt?: Date
  sizeEstimate?: number
  snippet?: string
  subject: string
  text?: string
  to: Mailbox[]
}

interface Mailbox {
  address: string
  name?: string
}

interface Attachment {
  contentId?: string
  description?: string
  disposition?: "attachment" | "inline"
  file: File
  filename: string
  mimeType: string
  related: boolean
}
```

`messages` follows Gmail's returned message order. Attachments for every message are downloaded as `File` objects.
