---
metadata:
  - name: generator
    content: Diplodoc Platform v5.64.0
alternate:
  - https://yandex.ru/dev/api360/doc/ru/ref/DomainPolicies/DomainPolicies_Set.md
  - href: https://yandex.ru/dev/api360/doc/ru/ref/DomainPolicies/DomainPolicies_Set.md
    type: text/markdown
    title: Markdown version
  - href: https://yandex.ru/dev/api360/doc/ru/llms.txt?revision=r21934284
    rel: describedby
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.ru/dev/api360/doc/ru/llms.txt?revision=r21934284

<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/policies
```

</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": [
    {
      "name": "example",
      "description": "example",
      "enabled": true,
      "condition": {
        "ip_filter": {
          "list": [
            null
          ]
        },
        "domain_filter": null,
        "email_from_filter": null
      },
      "action": {
        "type": "accept",
        "options": {
          "force": "spam"
        }
      }
    }
  ]
}
```

{% endcut %}

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

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

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

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

```json translate=no
[
  {
    "name": "example",
    "description": "example",
    "enabled": true,
    "condition": {
      "ip_filter": {
        "list": [
          "example"
        ]
      },
      "domain_filter": null,
      "email_from_filter": null
    },
    "action": {
      "type": "accept",
      "options": {
        "force": "spam"
      }
    }
  }
]
```

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

</div>

<div class="openapi-entity">

### v1domain_policiesList {#entity-v1domain_policiesList}

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

_list_{.json-schema-reset .json-schema-property .json-schema-required}
{.table-cell}|
**Type**: string[]

Перечень элементов списка заданного фильтра.

_Min items:_{.json-schema-reset .json-schema-assertion} `1`

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

```json translate=no
[
  "example"
]
```

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

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

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

{% endcut %}

</div>

<div class="openapi-entity">

### domain_policiesCondition {#entity-domain_policiesCondition}

Условие, при выполнении которого применяется правило.

В одном условии может быть указан только один из элементов `ip_filter`, `domain_filter` или `email_from_filter`.
Правило применяется, если отправитель письма прошел проверку на соответствие заданному фильтру: по почтовому адресу, домену, IP-адресу или маске подсети.

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

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

Список доменов.

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

Значения в этом списке могут содержать символ подстановки `*` для обозначения любых поддоменов для домена более высокого уровня.
Например, значению `*.com` соответствуют все электронные адреса на домене `com`,
а значению `*.yandex.ru`  — все адреса на любых поддоменах `yandex.ru`, кроме адресов непосредственно на головном домене `yandex.ru`.

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

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

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

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

Список электронных адресов.

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

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

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

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

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

Список IP.

Содержит перечень IPv4-адресов, IPv6-адресов, IPv4-масок подсети, IPv6-масок подсети, которым должен соответствовать IP-адрес отправителя письма, чтобы к нему применилось правило.

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

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

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

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

```json translate=no
{
  "ip_filter": {
    "list": [
      "example"
    ]
  },
  "domain_filter": null,
  "email_from_filter": null
}
```

{% endcut %}

</div>

<div class="openapi-entity">

### domain_policiesActionOptions {#entity-domain_policiesActionOptions}

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

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

Отметка письма.

Возможные значения:
- `spam` — пометить письмо как спам;
- `ham` — не считать письмо спамом, даже если Спамооборона Почты проставила ему отметку `spam`.

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

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

```json translate=no
{
  "force": "spam"
}
```

{% endcut %}

</div>

<div class="openapi-entity">

### domain_policiesAction {#entity-domain_policiesAction}

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

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

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

Возможные значения:
- `accept` — принять письмо;
- `reject` — отклонить письмо.

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

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

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

Указывается только для `type=accept` — если письмо принимается.

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

```json translate=no
{
  "force": "spam"
}
```

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

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

```json translate=no
{
  "type": "accept",
  "options": {
    "force": "spam"
  }
}
```

{% endcut %}

</div>

<div class="openapi-entity">

### v1domain_policiesRule {#entity-v1domain_policiesRule}

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

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

Действие над письмом, предусмотренное правилом.

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

```json translate=no
{
  "type": "accept",
  "options": {
    "force": "spam"
  }
}
```

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

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

Условие, при выполнении которого применяется правило.

Условие, при выполнении которого применяется правило.

В одном условии может быть указан только один из элементов `ip_filter`, `domain_filter` или `email_from_filter`.
Правило применяется, если отправитель письма прошел проверку на соответствие заданному фильтру: по почтовому адресу, домену, IP-адресу или маске подсети.

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

```json translate=no
{
  "ip_filter": {
    "list": [
      "example"
    ]
  },
  "domain_filter": null,
  "email_from_filter": null
}
```

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

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

Описание правила.

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

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

Признак активности правила:

- `true` — правило включено;
- `false` — правило выключено.

{.table-cell}
||
||

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

Название правила.

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

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

```json translate=no
{
  "name": "example",
  "description": "example",
  "enabled": true,
  "condition": {
    "ip_filter": {
      "list": [
        "example"
      ]
    },
    "domain_filter": null,
    "email_from_filter": null
  },
  "action": {
    "type": "accept",
    "options": {
      "force": "spam"
    }
  }
}
```

{% endcut %}

</div>

## Responses

<div class="openapi__response__code__200">

## 200 OK

`200 OK` — запрос выполнен успешно.

<div class="openapi-entity">

### Body

{% cut "application/json" %}

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

{% endcut %}

#|
|| **Name** | **Description** ||
|#{.json-schema-properties}

</div>

</div>

<div class="openapi__response__code__400">

## 400 Bad Request

`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

`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

`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

`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

`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.