> ## Documentation Index
> Fetch the complete documentation index at: https://docs.molesignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 调整路由规则的顺序

> 按给出的 ID 重排告警路由规则。

```http theme={null}
PUT /api/v1/alerts/routing/rules/order
```

按给出的顺序重排组织的[路由规则](https://docs.molesignal.com/zh-Hans/alerting/routing.md#路由规则)，需要 `alerts.routing.manage`。列出的规则按给出的顺序排在前面，没列出的保持原来的先后排在后面；不是本组织规则的 ID 被忽略。

| 字段 | 类型 | 说明 |
| - | - | - |
| `ids` | array | 必填，规则 ID，先比的在前。 |

```bash cURL theme={null}
curl -X PUT http://localhost:5080/api/v1/alerts/routing/rules/order \
  -H "authorization: Bearer $MS_TOKEN" \
  -H "content-type: application/json" \
  -d '{"ids": ["<rule-id-2>", "<rule-id-1>"]}'
```

响应是按新顺序排好的全部规则，`position` 从 0 起连续编号，字段见[规则字段](https://docs.molesignal.com/zh-Hans/api/alerting/list-routing-rules.md#规则字段)。

**错误**

| 状态码 | 原因 |
| - | - |
| `403` | Token 缺少 `alerts.routing.manage`。 |
| `422` | 缺少 `ids`，或带了别的字段。响应为纯文本。 |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.