> ## 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 not spam

> Move one or many Gmail messages out of Spam and into the inbox.

`markAsNotSpam` removes Gmail's `SPAM` system label and adds `INBOX` in one request. Use it to restore messages that an automation has identified as legitimate mail.

## Example

Restore up to 100 messages from a trusted sender:

```ts theme={null}
import { automation, branch } from "automate.ax"
import { markAsNotSpam, searchMessages } from "automate.ax/gmail"

export default automation("Restore trusted Gmail messages", () => {
  const messages = searchMessages({
    includeSpamTrash: true,
    limit: 100,
    query: "in:spam from:billing@example.com",
  })

  branch(
    messages.length.transform((length) => length > 0),
    () => {
      markAsNotSpam({
        messageIds: messages.transform((results) =>
          results.map((message) => message.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 derives message IDs from `searchMessages`.

## Output

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

This action requests both state changes together: remove `SPAM` and add `INBOX`. Other system and user labels remain untouched. It operates on individual messages, even when Gmail displays them as a conversation.
