---
title: "创建微规则"
method: POST
path: "/api/v1/micro-rules"
tags: ["规则管理"]
---

# 创建微规则

`POST /api/v1/micro-rules`

创建一个新的WAF微规则，用于匹配和过滤请求

## Request body

- DtoMicroRuleCreateRequest — 创建微规则的请求参数
  - `condition` object, required — 规则条件
  - `name` string, required — 规则名称
  - `priority` integer, required — 优先级字段，数字越大优先级越高
  - `status` 'enabled' | 'disabled', required — 规则状态
  - `type` 'whitelist' | 'blacklist', required — 规则类型

## Response `200`

微规则创建成功

- object — 成功的API响应标准格式
  - `code` integer
  - `data` DtoMicroRuleResponse — 微规则响应参数
    - `condition` object — 规则条件
    - `id` string
    - `name` string — 规则名称
    - `priority` integer — 优先级字段，数字越大优先级越高
    - `status` 'enabled' | 'disabled' — 规则状态
    - `type` 'whitelist' | 'blacklist' — 规则类型
  - `message` string
  - `requestId` string
  - `success` boolean
  - `timestamp` string

## Other responses

- `400` — 请求参数错误
- `401` — 未授权访问
- `403` — 禁止访问
- `409` — 微规则名称已存在
- `500` — 服务器内部错误

---

[API](https://skmtc.net/labring/apis/ruiqi-waf-api.md) · [All operations](https://skmtc.net/labring/apis/ruiqi-waf-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/labring/ruiqi-waf-api/revisions/aaacd7e06a88/schema)
