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

> Retrieve the untouched base64url-encoded RFC 5322 source of a Gmail message.

`getRawMessage` retrieves Gmail's raw RFC 5322 message source. Use this escape hatch when a protocol, signature verifier, or specialized mail parser needs the original message instead of Automate.ax's parsed message fields.

Most automations should use [Get message](/reference/integrations/gmail/actions/get-message).

## Example

```ts automations/get-raw-message.automation.ts theme={null}
import { automation } from "automate.ax"
import { getRawMessage } from "automate.ax/gmail"

export default automation("Get raw Gmail source", () => {
  getRawMessage({
    messageId: "18f2c7a9b4d12345",
  })
})
```

## Inputs

| Property    | Type                                              | Required | Description                                                                              |
| ----------- | ------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------- |
| `messageId` | `string`                                          | Yes      | Immutable Gmail message 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<string>` containing the base64url-encoded RFC 5322 message. Decode it before passing it to a parser that expects raw message bytes or text.

```ts theme={null}
const source = Buffer.from(encodedMessage, "base64url")
```

<Warning>
  The output can contain message bodies, recipient data, and attachment
  contents. Treat it as sensitive mailbox data.
</Warning>
