---
title: "Create / edit an automation rule"
locale: en
url: https://tlg.builera.app/en/docs/reference/rest/rules.save
verified: 2026-10-24
app_version: "2.0"
generated: true
---

# Create / edit an automation rule

When <trigger event> and <conditions: keywords / excludeKeywords (accent-aware whole words), accountIds, accountTags, stageIds, personTagsAny, temperatures, hours> then <actions: tag_add, tag_remove, set_stage, set_temperature, assign, add_to_list, add_to_campaign, send_template (a template people wrote), alert, webhook (emit rule.fired), hold (keep the chat for a person / agent)>. Fires at most once per event per person, at most 3 levels of rule-triggers-rule; sends still pass the safety gate and conversation lock. Updating needs expectedRevision.

When <trigger event> and <conditions: keywords / excludeKeywords (accent-aware whole words), accountIds, accountTags, stageIds, personTagsAny, temperatures, hours> then <actions: tag_add, tag_remove, set_stage, set_temperature, assign, add_to_list, add_to_campaign, send_template (a template people wrote), alert, webhook (emit rule.fired), hold (keep the chat for a person / agent)>. Fires at most once per event per person, at most 3 levels of rule-triggers-rule; sends still pass the safety gate and conversation lock. Updating needs expectedRevision.

## Overview

| Name | Value |
| --- | --- |
| Code | `rules.save` |
| Scope needed | `automation.write` |
| Risk | Write |
| May need confirmation | No |
| Runs as | Answers right away |
| Needs `Idempotency-Key` | No |
| Member roles allowed | `owner`, `manager` |
| In the app | Automation → Rules → Save |

## Input fields

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `uuid` | No |   |
| `name` | `text` | Yes |   |
| `enabled` | `true/false` | No |   |
| `trigger` | `"message.received" \| "message.read" \| "campaign.replied" \| "campaign.person_done" \| "keyword.signal" \| "group.joined" \| "person.stage_changed" \| "conversation.assigned" \| "account.status_changed" \| "account.safety_changed"` | Yes |   |
| `conditions` | `object` | No |   |
| `actions` | `object[]` | Yes |   |
| `expectedRevision` | `integer` | No |   |

## Example request

```bash
curl -X POST https://tlg.builera.app/api/public/v2/ops/rules.save \
  -H "Authorization: Bearer $TELEGRAM_AUTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"…","trigger":"message.received","actions":[]}'
```

## Output fields (`data`)

| Field | Type | Required |
| --- | --- | --- |
| `ok` | `true` | Yes |
| `id` | `text` | Yes |
| `revision` | `null \| number` | Yes |

## Example answer

```json
{
  "data": {
    "ok": true,
    "id": "00000000-0000-4000-8000-000000000000",
    "revision": 1
  }
}
```

## Using it over MCP

Not listed on any profile: call `tools_describe` then `tools_run` with `code: "rules.save"`. Tool name when listed: `rules_save`.
