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

# Mark as spam

> Move one or many Gmail messages into Spam.

`markAsSpam` adds Gmail's `SPAM` system label and removes `INBOX` in one request. Use it when your automation has positively identified unwanted mail.

## Example

Move newly received messages with a known unwanted subject marker to Spam:

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

export default automation("Move unwanted Gmail messages to Spam", () => {
  const unwanted = filter(onNewEmail(), (message) =>
    message.subject.includes("[UNWANTED]"),
  )

  markAsSpam({ messageIds: unwanted.messageId })
})
```

## 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 passes the filtered message ID signal directly.

## Output

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

This action requests both state changes together: add `SPAM` and remove `INBOX`. It does not delete the messages or remove unrelated labels. Use `markAsNotSpam` to reverse these two mailbox changes.
