# automation.set

Source: https://docs.lightair.app/developers/remote-api/automation.set

> Saves an automation, replacing the one with its id, or adds one from a recipe.

JSON-RPC 2.0 method of Lightair's Remote API (ws://localhost:4455/rpc). Group: Automations. Script plugins need the `project.write` permission.

An automation has `name`, `enabled`, a `trigger`, `conditions`, `steps`, and optionally `queue`, `cooldown` and `user_cooldown` (seconds). Without an `id`, it's a new one.

- **Triggers** (`on`): `event` (`kinds`: follow, sub, paid, cheer, raid; `min_amount`), `command` (`name` such as `!so`, `who`), `chat` (`contains`, `first_time`), `timer` (`minutes`, `min_messages`), `manual`.
- **Steps** (`do`): `chat`, `call` (a Lightair method and its `params`), `speak`, `sound`, `wait`, `var`, `points`, `if`, `random`, `run`, `http`, `stop`.

Text is a template: `{{ name }}`, `{{ message }}`, `{{ amount }}`, `{{ args.0 }}`, `{{ vars.x }}` and more.

## Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `automation` | `object` | no | The whole automation. |
| `recipe` | `string` | no | A recipe's key, instead of `automation`. |

## Result

| Name | Type | Required | Description |
|---|---|---|---|
| `(the automation)` | `object` | no | As saved, with its id. |

## Errors

Invalid params (-32602) without either, or for something that isn't an automation. Not found (-32004) for an unknown recipe.

## From an AI agent

The MCP server's `set_automation` reaches this method.

## Related

- [automation.list](https://docs.lightair.app/developers/remote-api/automation.list.md)
- [automation.run](https://docs.lightair.app/developers/remote-api/automation.run.md)
- [automation.remove](https://docs.lightair.app/developers/remote-api/automation.remove.md)
