# 查询通知规则

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

查询当前用户通知规则的开关、优先级、阈值和投递渠道。

```text
GET https://billing.moi.matrixorigin.cn/api/v1/taas/notification-rules
```

## 调用前准备

准备个人访问令牌。创建和管理方法参阅[创建和管理个人访问令牌](../../../../../guides/genesis/api-keys.md#创建和管理个人访问令牌)。

查询范围为当前用户有权访问的数据。

## 请求示例

将示例中的 `$MOI_PERSONAL_ACCESS_TOKEN` 替换为个人访问令牌。

```bash
curl --get "https://billing.moi.matrixorigin.cn/api/v1/taas/notification-rules" \
  -H "X-API-Key: $MOI_PERSONAL_ACCESS_TOKEN"
```

## 成功响应

返回 HTTP `200`，响应包含当前用户的通知规则配置。

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} 响应示例

```json
{
  "items": [
    {
      "rule_key": "usage_warning",
      "category": "usage",
      "title": "Usage warning",
      "description": "Usage threshold warning.",
      "enabled": true,
      "priority": "important",
      "threshold_value": "90",
      "threshold_unit": "percent",
      "threshold_readonly": true,
      "delivery_channels": [
        "in_app"
      ],
      "config_version": 1,
      "updated_at": 1788710400
    }
  ]
}
```

:::::
:::::{tab-item} 字段说明

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `items` | array of object | 通知规则列表。 |
| `items[].rule_key` | string | 规则标识。 |
| `items[].category` | string | 规则分类。 |
| `items[].title` | string | 规则标题。 |
| `items[].description` | string | 规则说明。 |
| `items[].enabled` | boolean | 规则是否启用。 |
| `items[].priority` | string | 通知优先级。 |
| `items[].threshold_value` | string | 阈值，十进制字符串；不适用时省略。 |
| `items[].threshold_unit` | string | 阈值单位；不适用时省略。 |
| `items[].threshold_readonly` | boolean | 阈值是否只读。 |
| `items[].scope` | object | 规则作用范围；键和值由具体规则定义，未设置时省略。 |
| `items[].delivery_channels` | array of string | 当前可投递的渠道标识。 |
| `items[].tip` | string | 规则提示；有值时返回。 |
| `items[].config_version` | integer | 规则配置版本。 |
| `items[].updated_at` | integer | 更新时间，Unix 秒。 |

字段路径中的 `[]` 表示数组中的每一项。

:::::
::::::
:::::::
