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

# Archive

> Archive one or many Gmail messages by removing them from the inbox.

`archive` removes Gmail's `INBOX` system label from one or many messages. Use it when an automation has finished handling inbox mail but the messages should remain available in Gmail.

## Example

Archive each new message after applying a record-keeping label:

```ts theme={null}
import { automation } from "automate.ax"
import { addLabel, archive, onNewEmail } from "automate.ax/gmail"

export default automation("Archive processed Gmail messages", () => {
  const email = onNewEmail()
  const labeledMessageIds = addLabel({
    label: "Processed",
    messageIds: email.messageId,
  })

  archive({ messageIds: labeledMessageIds })
})
```

## Inputs

| Name         | Type                                 | Required | Description                                                                      |
| ------------ | ------------------------------------ | -------- | -------------------------------------------------------------------------------- |
| `messageIds` | `string \| string[]`                 | Yes      | One or up to 1,000 immutable Gmail message IDs.                                  |
| `account`    | `string \| Google account reference` | No       | Google account binding to use. Defaults to the project's default Google account. |

Every input field also accepts a compatible `Signal`; the example chains the output of `addLabel` into `archive`.

## Output

The action returns a `Signal<string[]>` containing the modified message IDs in input order.

Gmail does not have a separate Archive folder. Archiving removes `INBOX`; it does not trash or delete the messages, and other labels remain applied. The action changes the supplied messages rather than every message in their threads.
