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

# On label removed

> Start an automation when Gmail removes a label from a message.

`onGmailLabelRemoved` subscribes an automation to user-label and system-label removals in the connected Gmail mailbox.

## Example

```ts automations/archive-resolved-email.automation.ts theme={null}
import { automation, filter } from "automate.ax"
import { archiveGmailMessages, onGmailLabelRemoved } from "automate.ax/gmail"

export default automation("Archive resolved email", () => {
  const resolved = filter(onGmailLabelRemoved(), ({ labels }) =>
    labels.some(({ name }) => name === "Needs reply"),
  )

  archiveGmailMessages({
    messageIds: resolved.message.messageId,
  })
})
```

## Options

| Property  | Type                                              | Required | Description                                                                                       |
| --------- | ------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------- |
| `account` | `string \| IntegrationAccountReference<"google">` | No       | Static Google account binding to watch. Defaults to the project's default Google account binding. |

The account selection must be static. Call `onGmailLabelRemoved()` without an options object to use the default Google binding.

## Trigger data

Returns a `Signal<GmailLabelChange>` with the fully parsed `message` and the labels removed in the same Gmail history change:

```ts theme={null}
interface GmailLabelChange {
  labels: {
    labelId: string
    name?: string
  }[]
  message: Message
}
```

See [Get message](/reference/integrations/gmail/actions/get-message) for the complete `Message` shape. Use `labelId` as the stable identity. `name` is omitted when Gmail can no longer resolve a removed label, such as after the user deletes that label.
