---
title: "Получить правило автоматизации"
method: GET
path: "/api/v1/automation/rules/{id}"
tags: ["Automation"]
---

# Получить правило автоматизации

`GET /api/v1/automation/rules/{id}`

## Request

- Base URL: `https://erp.akeda.ru`
- URL: `https://erp.akeda.ru/api/v1/automation/rules/{id}`
- Auth: one of:
  - HTTP bearer
  - OAuth 2 (authorization code, authorization URL `https://erp.akeda.ru/oauth2/authorize`, token URL `https://erp.akeda.ru/oauth2/token`, scopes: `akeda:delegate`)

Одно правило кабинета документом в той же форме, что у списка правил:
событие, условие, действия, исполнитель, включено ли и `version` —
её передают в `expected_version` при изменении правила.

## Response `200`

Правило

- AutomationRuleDocument
  - `id` string, uuid, required
  - `name` string, required
  - `event_type` string, required
  - `condition` string, required: Выражение вычислителя; у правила из конструктора собрано из conditions
  - `conditions` object[], required
    - `field` string, required
    - `op` string, required
    - `value` string
    - `value_to` string
    - `of` string
    - `group` integer
  - `actions` AutomationRuleBlock[], required: Путь «Если да»: действия и паузы по порядку (ERP-1932)
    - `id` string
    - `kind` 'action' | 'wait': Пусто — действие
    - `command` string
    - `inputs` object
    - `wait` object: Пауза: after_event — через amount единиц unit от начала паузы; relative_to_field — до даты поля field (± amount); cancel_on — события, факт которых по той же записи прекращает правило
      - `kind` 'after_event' | 'relative_to_field'
      - `amount` integer
      - `unit` 'minutes' | 'hours' | 'days' | 'working_days'
      - `direction` 'before' | 'after'
      - `field` string
      - `at` string
      - `cancel_on` string[]
  - `branches` AutomationRuleBranch[]: «Если ещё …»: до трёх путей со своим условием, проверяются по порядку
    - `id` string
    - `condition` string: Выражение, собранное сервером из conditions
    - `conditions` object[], required
      - `field` string, required
      - `op` string, required
      - `value` string
      - `value_to` string
      - `of` string
      - `group` integer
    - `actions` AutomationRuleBlock[], required
      - `id` string
      - `kind` 'action' | 'wait': Пусто — действие
      - `command` string
      - `inputs` object
      - `wait` object: Пауза: after_event — через amount единиц unit от начала паузы; relative_to_field — до даты поля field (± amount); cancel_on — события, факт которых по той же записи прекращает правило
        - `kind` 'after_event' | 'relative_to_field'
        - `amount` integer
        - `unit` 'minutes' | 'hours' | 'days' | 'working_days'
        - `direction` 'before' | 'after'
        - `field` string
        - `at` string
        - `cancel_on` string[]
  - `otherwise` AutomationRuleBlock[]: «Иначе»: блоки, когда не подошло ни одно условие; пусто — правило промолчит
    - `id` string
    - `kind` 'action' | 'wait': Пусто — действие
    - `command` string
    - `inputs` object
    - `wait` object: Пауза: after_event — через amount единиц unit от начала паузы; relative_to_field — до даты поля field (± amount); cancel_on — события, факт которых по той же записи прекращает правило
      - `kind` 'after_event' | 'relative_to_field'
      - `amount` integer
      - `unit` 'minutes' | 'hours' | 'days' | 'working_days'
      - `direction` 'before' | 'after'
      - `field` string
      - `at` string
      - `cancel_on` string[]
  - `after_rule_id` string: Очередь (ERP-1613): правило ждёт, пока выполнится правило с этим id на тот же факт; пусто — сразу
  - `doc_version` integer: Версия языка документа правила (rule.schema.json); 2 — пути, паузы и результаты шагов
  - `executor_user_id` integer, required
  - `is_enabled` boolean, required
  - `origin` 'manual' | 'configuration', required
  - `version` integer, required
  - `created_by` integer
  - `created_at` string, date-time
  - `updated_at` string, date-time

## Other responses

- `401`: Сессия, ключ или кабинет не подтверждены
- `403`: Текущая роль не имеет требуемого права
- `404`: Запись не найдена или не видима текущему пользователю

---

[API](https://skmtc.dev/akeda/apis/akeda-erp-client-api.md) · [All operations](https://skmtc.dev/akeda/apis/akeda-erp-client-api/llms.txt) · [OpenAPI document](https://skmtc.dev/akeda/apis/akeda-erp-client-api/revisions/a99574d597cc?raw)
