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

> Retrieve and parse up to 100 Gmail messages in one action.

`getMessages` retrieves multiple messages by their immutable Gmail message IDs. Use it when a search or another action gives you a bounded set of IDs and you need full message content.

The action fetches messages concurrently and returns them in the same order as `messageIds`. Every attachment is returned as a `File`.

## Example

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

export default automation("Read Gmail messages", () => {
  getMessages({
    messageIds: ["18f2c7a9b4d12345", "18f2c7a9b4d67890"],
  })
})
```

## Inputs

| Property     | Type                                              | Required | Description                                                                              |
| ------------ | ------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------- |
| `messageIds` | `string[]`                                        | Yes      | One to 100 immutable Gmail message IDs.                                                  |
| `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. If a search can return more than 100 matches, limit or partition its identifiers before passing them here.

## Output

Returns a `Signal<Message[]>`. Each message contains:

```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
}
```

The action fails if Gmail cannot retrieve any requested message, so use IDs from the same connected mailbox.
