> ## 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 message

> Retrieve and parse one Gmail message, including its headers, bodies, labels, and attachments.

`getMessage` retrieves one message by its immutable Gmail message ID. Use it after a search or another Gmail operation returns a `messageId` and you need the complete message content.

Attachments are always downloaded and returned as `File` objects. If you only need identifiers, use [Search messages](/reference/integrations/gmail/actions/search-messages) instead.

## Example

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

export default automation("Read a Gmail message", () => {
  getMessage({
    messageId: "18f2c7a9b4d12345",
  })
})
```

## Inputs

| Property    | Type                                              | Required | Description                                                                              |
| ----------- | ------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------- |
| `messageId` | `string`                                          | Yes      | Immutable Gmail message ID. This is not the RFC 5322 `Message-ID` header.                |
| `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<Message>` with the parsed message:

```ts theme={null}
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
}
```

`text` is derived from `html` when the source message has no plain-text alternative. `receivedAt` is Gmail's mailbox timestamp; `sentAt` comes from the sender-supplied `Date` header.

<Note>
  Keep `messageId` and `rfc822MessageId` separate. Gmail actions expect the
  immutable Gmail `messageId`; `rfc822MessageId` is the value from the email's
  `Message-ID` header.
</Note>
