---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://yandex.ru/dev/api360/doc/ru/ref/RoutingService/RoutingService_SetRules.md
  - href: ru/ref/RoutingService/RoutingService_SetRules.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.ru/dev/api360/doc/ru/llms.txt

<div class="openapi">

# Задать список правил

<!-- markdownlint-disable-file -->

Создает или обновляет список правил обработки писем.

{% note info %}

Чтобы выполнить запрос, приложению требуется разрешение на управление правилами обработки почты для домена.
Убедитесь, что вы включили его при [настройке приложения](https://yandex.ru/dev/api360/doc/ru/access.md) на OAuth-сервере Яндекса.

{% endnote %}

## Request

<div class="openapi__requests">

<div class="openapi__request__wrapper" style="--method: var(--dc-openapi-methods-put);margin-bottom: 12px">

<div class="openapi__request">

PUT {.openapi__method}
```text translate=no
https://api360.yandex.net/admin/v1/org/{orgId}/mail/routing/rules
```

</div>

</div>

</div>

### Path parameters

#|
|| **Name** | **Description** ||
||

_orgId_{.json-schema-reset .json-schema-property .json-schema-required}
{.table-cell}|
**Type**: integer

Идентификатор организации.
{.table-cell}
||
|#{.json-schema-properties}

<div class="openapi-entity">

### Body

{% cut "application/json" %}

```json translate=no
{
  "rules": [
    {
      "condition": {
        "address:from": "spam@example.com"
      },
      "actions": [
        {
          "action": "drop"
        }
      ],
      "scope": {
        "direction": "inbound"
      },
      "terminal": true
    }
  ]
}
```

{% endcut %}

#|
|| **Name** | **Description** ||
||

_rules_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [v1RuleParams](#entity-v1RuleParams)[]

Список правил обработки писем.

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
[
  {
    "terminal": true,
    "condition": null,
    "actions": [
      {
        "action": "drop",
        "data": {
          "email": "example"
        }
      }
    ],
    "scope": {
      "direction": "inbound"
    }
  }
]
```

{% endcut %}
{.table-cell}
||
|#{.json-schema-properties}

</div>

<div class="openapi-entity">

### RuleActionParamsRuleAction {#entity-RuleActionParamsRuleAction}

 - drop: не доставлять письмо получателю — удалить входящее письмо или не производить отправку исходящего.
 - forward: переслать копию письма на адрес, заданный в параметре `email`.

**Type**: string

_Default:_{.json-schema-reset .json-schema-value} `drop`

_Enum:_{.json-schema-reset .json-schema-value} `drop`, `forward`

</div>

<div class="openapi-entity">

### v1RuleActionData {#entity-v1RuleActionData}

#|
|| **Name** | **Description** ||
||

_email_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Адрес, на который нужно переслать письмо. Используется, если параметр `action` имеет значение `forward`.

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
|#{.json-schema-properties}

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
{
  "email": "example"
}
```

{% endcut %}

</div>

<div class="openapi-entity">

### v1RuleActionParams {#entity-v1RuleActionParams}

#|
|| **Name** | **Description** ||
||

_action_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [RuleActionParamsRuleAction](#entity-RuleActionParamsRuleAction)

Действие над письмом.

 - drop: не доставлять письмо получателю — удалить входящее письмо или не производить отправку исходящего.
 - forward: переслать копию письма на адрес, заданный в параметре `email`.

_Default:_{.json-schema-reset .json-schema-value} `drop`

_Enum:_{.json-schema-reset .json-schema-value} `drop`, `forward`
{.table-cell}
||
||

_data_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [v1RuleActionData](#entity-v1RuleActionData)

Дополнительные данные для действия.

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
{
  "email": "example"
}
```

{% endcut %}
{.table-cell}
||
|#{.json-schema-properties}

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
{
  "action": "drop",
  "data": {
    "email": "example"
  }
}
```

{% endcut %}

</div>

<div class="openapi-entity">

### RuleScopeParamsRuleDirection {#entity-RuleScopeParamsRuleDirection}

 - inbound: правило должно применяться для входящей почты.
 - outbound: правило должно применяться для исходящей почты.

**Type**: string

_Default:_{.json-schema-reset .json-schema-value} `inbound`

_Enum:_{.json-schema-reset .json-schema-value} `inbound`, `outbound`

</div>

<div class="openapi-entity">

### v1RuleScopeParams {#entity-v1RuleScopeParams}

#|
|| **Name** | **Description** ||
||

_direction_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [RuleScopeParamsRuleDirection](#entity-RuleScopeParamsRuleDirection)

Параметр, который задает, будет ли применяться правило для входящей или для исходящей почты.

 - inbound: правило должно применяться для входящей почты.
 - outbound: правило должно применяться для исходящей почты.

_Default:_{.json-schema-reset .json-schema-value} `inbound`

_Enum:_{.json-schema-reset .json-schema-value} `inbound`, `outbound`
{.table-cell}
||
|#{.json-schema-properties}

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
{
  "direction": "inbound"
}
```

{% endcut %}

</div>

<div class="openapi-entity">

### v1RuleParams {#entity-v1RuleParams}

#|
|| **Name** | **Description** ||
||

_actions_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [v1RuleActionParams](#entity-v1RuleActionParams)[]

Действия, которые необходимо выполнить при срабатывании правила.

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
[
  {
    "action": "drop",
    "data": {
      "email": "example"
    }
  }
]
```

{% endcut %}
{.table-cell}
||
||

_condition_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: unknown

Условие (составное условие), которое проверяет соответствие письма текущему правилу. [Подробное описание параметра](https://yandex.ru/dev/api360/doc/ru/routing.md).

_Example:_{.json-schema-reset .json-schema-example} `null`
{.table-cell}
||
||

_scope_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [v1RuleScopeParams](#entity-v1RuleScopeParams)

Параметр, который задает область применения правила.

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
{
  "direction": "inbound"
}
```

{% endcut %}
{.table-cell}
||
||

_terminal_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: boolean

Признак, который определяет нужно ли прекратить применение последующих правил при срабатывании данного.
{.table-cell}
||
|#{.json-schema-properties}

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
{
  "terminal": true,
  "condition": null,
  "actions": [
    {
      "action": "drop",
      "data": {
        "email": "example"
      }
    }
  ],
  "scope": {
    "direction": "inbound"
  }
}
```

{% endcut %}

</div>

## Responses

<div class="openapi__response__code__200">

## 200 OK

Запрос успешно выполнен.

<div class="openapi-entity">

### Body

{% cut "application/json" %}

```json translate=no
{}
```

{% endcut %}

**Type**: object

</div>

</div>

<div class="openapi__response__code__400">

## 400 Bad Request

Некорректный запрос.

<div class="openapi-entity">

### Body

{% cut "application/json" %}

```json translate=no
{
  "code": 0,
  "message": "example",
  "details": [
    {
      "@type": "example"
    }
  ]
}
```

{% endcut %}

#|
|| **Name** | **Description** ||
||

_code_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: integer

Код ошибки.
{.table-cell}
||
||

_details_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [protobufAny](#entity-protobufAny)[]

Дополнительные сведения об ошибке.

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
[
  {
    "@type": "example"
  }
]
```

{% endcut %}
{.table-cell}
||
||

_message_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Описание ошибки.

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
|#{.json-schema-properties}

</div>

<div class="openapi-entity">

### protobufAny {#entity-protobufAny}

#|
|| **Name** | **Description** ||
||

_@type_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
||

_[additional]_{.json-schema-reset .json-schema-additional-property}
{.table-cell}|
**Type**: unknown

_Example:_{.json-schema-reset .json-schema-example} `null`
{.table-cell}
||
|#{.json-schema-properties}

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
{
  "@type": "example"
}
```

{% endcut %}

</div>

</div>

<div class="openapi__response__code__401">

## 401 Unauthorized

Пользователь не авторизован.

<div class="openapi-entity">

### Body

{% cut "application/json" %}

```json translate=no
{
  "code": 0,
  "message": "example",
  "details": [
    {
      "@type": "example"
    }
  ]
}
```

{% endcut %}

#|
|| **Name** | **Description** ||
||

_code_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: integer

Код ошибки.
{.table-cell}
||
||

_details_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [protobufAny](#entity-protobufAny)[]

Дополнительные сведения об ошибке.

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
[
  {
    "@type": "example"
  }
]
```

{% endcut %}
{.table-cell}
||
||

_message_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Описание ошибки.

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
|#{.json-schema-properties}

</div>

</div>

<div class="openapi__response__code__403">

## 403 Forbidden

У пользователя или приложения нет прав на доступ к ресурсу, запрос отклонен.

<div class="openapi-entity">

### Body

{% cut "application/json" %}

```json translate=no
{
  "code": 0,
  "message": "example",
  "details": [
    {
      "@type": "example"
    }
  ]
}
```

{% endcut %}

#|
|| **Name** | **Description** ||
||

_code_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: integer

Код ошибки.
{.table-cell}
||
||

_details_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [protobufAny](#entity-protobufAny)[]

Дополнительные сведения об ошибке.

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
[
  {
    "@type": "example"
  }
]
```

{% endcut %}
{.table-cell}
||
||

_message_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Описание ошибки.

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
|#{.json-schema-properties}

</div>

</div>

<div class="openapi__response__code__404">

## 404 Not Found

Запрашиваемый ресурс не найден.

<div class="openapi-entity">

### Body

{% cut "application/json" %}

```json translate=no
{
  "code": 0,
  "message": "example",
  "details": [
    {
      "@type": "example"
    }
  ]
}
```

{% endcut %}

#|
|| **Name** | **Description** ||
||

_code_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: integer

Код ошибки.
{.table-cell}
||
||

_details_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [protobufAny](#entity-protobufAny)[]

Дополнительные сведения об ошибке.

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
[
  {
    "@type": "example"
  }
]
```

{% endcut %}
{.table-cell}
||
||

_message_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Описание ошибки.

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
|#{.json-schema-properties}

</div>

</div>

<div class="openapi__response__code__500">

## 500 Internal Server Error

Внутренняя ошибка сервиса. Попробуйте повторно отправить запрос через некоторое время.

<div class="openapi-entity">

### Body

{% cut "application/json" %}

```json translate=no
{
  "code": 0,
  "message": "example",
  "details": [
    {
      "@type": "example"
    }
  ]
}
```

{% endcut %}

#|
|| **Name** | **Description** ||
||

_code_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: integer

Код ошибки.
{.table-cell}
||
||

_details_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [protobufAny](#entity-protobufAny)[]

Дополнительные сведения об ошибке.

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
[
  {
    "@type": "example"
  }
]
```

{% endcut %}
{.table-cell}
||
||

_message_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Описание ошибки.

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
|#{.json-schema-properties}

</div>

</div>

</div>

[*Deprecated]: No longer supported, please use an alternative and newer version.