API 调用
概述
JXWAF 云 WAF 管理控制台提供 Admin API(/admin_api/),用于自动化运维与二次开发,包括子账号(业务部门)批量开通、网站接入配置管理、域名接入、全局名单维护、业务数据查询等。
用户控制台对接接口(/user/ API)详见 用户控制台定制开发指南。
一、启用与认证
1.1 启用配置
| 环境变量 | 默认值 | 说明 |
|---|---|---|
ADMIN_API_ENABLE | false | 是否启用 Admin API,设为 true 才可访问 |
ADMIN_API_WHITELIST | agent.jxwaf.com | 调用方白名单(IP/域名,逗号分隔) |
- 管理控制台出厂
docker-compose.yml默认已设ADMIN_API_ENABLE: "false",生产环境如需调用请改为"true" - 白名单项可为 IP 或域名;域名会被解析为 IP 后匹配,解析结果缓存 300 秒
1.2 认证方式
通过 HTTP 请求头 jxwaf-waf-auth 携带主账号 waf_auth:
jxwaf-waf-auth: <waf_auth_token>
waf_auth 可在管理控制台 系统管理 → 基础配置 查看。请求头名称使用连字符(下划线请求头会被丢弃)。
1.3 请求与响应格式
- Method:
POST(约定使用 POST) - Content-Type:
application/json - Body:JSON 格式,参数通过 JSON Body 传递
请求示例:
curl -X POST http://<host>/admin_api/get_sub_account_list \
-H "jxwaf-waf-auth: <your_waf_auth>" \
-H "Content-Type: application/json" \
-d '{"page": 1}'
响应格式(统一 HTTP 200,通过 result 判断成败):
| 响应类型 | 格式 |
|---|---|
| 操作成功 | {"result": true, "message": "create success"} |
| 操作失败 | {"result": false, "message": "错误原因"} |
| 分页列表 | {"result": true, "records": [...], "page": 1, "total_pages": 5, "total_records": 250} |
| 单条详情 | {"result": true, "message": {记录对象}} |
通用错误响应:
| 场景 | 响应 Body |
|---|---|
| Admin API 未启用 | {"result": false, "message": "admin api is not enabled"} |
| 客户端 IP 不在白名单 | {"result": false, "message": "ip not allowed"} |
| waf_auth 缺失或无效 | {"result": false, "message": "waf_auth fail"} |
| 必填参数缺失 | {"result": false, "message": "param is null"} |
二、接口清单
以下接口路径前需加
/admin_api前缀。除特别说明外,所有接口均需jxwaf-waf-auth认证。
子账号管理
| 接口路径 | 说明 |
|---|---|
/get_sub_account_list | 子账号列表(分页,含域名数/证书数/引擎状态) |
/get_sub_account_search_list | 搜索子账号列表 |
/get_sub_account | 获取单个子账号详情 |
/create_sub_account | 创建子账号 |
/delete_sub_account | 删除子账号 |
/edit_sub_account | 编辑子账号 |
/edit_sub_account_waf_auth | 重置子账号 waf_auth |
/api_get_sub_account_list | 批量获取所有子账号(无分页,含 waf_auth) |
/reset_sub_account_otp | 主账号代重置子账号 OTP 密钥 |
网站接入配置管理
| 接口路径 | 说明 |
|---|---|
/get_website_access_conf_list / /api_get_website_access_conf_list | 接入配置列表(后者含全部字段) |
/get_website_access_conf | 获取单个接入配置 |
/create_website_access_conf / /edit_website_access_conf / /delete_website_access_conf | 创建/编辑/删除接入配置 |
/website_access_conf_connect_test | DNS 凭据连接测试 |
/get_resource_quota_template | 获取资源配额模板 |
/get_domain_cname_ip_list / /domain_cname_edit / /website_access_conf_update_sync | CNAME IP 与同步管理 |
域名管理
| 接口路径 | 说明 |
|---|---|
/get_domain_list / /get_domain_search_list | 域名列表 / 搜索 |
/get_domain / /api_get_domain_list | 域名详情 / 批量获取 |
/create_domain / /edit_domain / /delete_domain | 创建(CNAME 自动接入)/ 编辑 / 删除 |
防护配置(子账号维度)
| 接口路径 | 说明 |
|---|---|
/get_sub_account_web_engine_protection / /edit_... | Web 防护引擎 |
/get_sub_account_web_rule_protection_list / create / edit / delete / edit_status / exchange_priority | Web 防护规则 |
/get_sub_account_web_white_rule_* | Web 白名单规则 |
/get_sub_account_web_page_tamper_proof_* | 网页防篡改 |
/get_sub_account_flow_engine_protection / /edit_... | 流量防护引擎 |
/get_sub_account_flow_rule_protection_* | 流量防护规则 |
/get_sub_account_flow_white_rule_* | 流量白名单规则 |
/get_sub_account_flow_ip_region_block / /edit_... | IP 区域封禁 |
自定义配置(子账号维度):/get_sub_account_custom_request_header_*、/get_sub_account_custom_response_header_*、/get_sub_account_custom_response_content_*、/get_sub_account_custom_upstream_address_*(每类含 list/get/create/edit/delete/edit_status/exchange_priority)
SSL 证书:/get_sub_account_ssl_manage_list、/create_sub_account_ssl_manage、/request_wildcard_cert、/retry_sub_account_ssl_cert、/edit_sub_account_ssl_cert_config 等
缓存管理:/get_sub_account_cache_policy_*、/get_sub_account_no_cache_policy_*、/get_sub_account_cache_bypass_policy_*、/create_cache_warmup_task、/get_cache_warmup_list、/create_cache_refresh_task、/get_cache_refresh_list 等
全局名单与防护组件
| 接口路径 | 说明 |
|---|---|
/get_global_name_list_list / create / edit / delete / edit_status / exchange_priority | 全局名单 |
/get_name_list_item_list_list / create_global_name_list_item / delete_global_name_list_item / search_global_name_list_item | 名单条目 |
/get_component_list / create / edit / delete / edit_status / exchange_priority | 防护组件 |
/get_global_ssl_protection / /edit_global_ssl_protection | 全局 SSL 协议防护 |
系统配置:/get_sys_log_conf / /edit_sys_log_conf(日志传输)、/get_sys_report_conf_conf / /edit_sys_report_conf_conf / /test_sys_report_conf_conf(日志查询)、/get_sys_custom_page_conf / /edit_sys_custom_page_conf(拦截页面)、/get_sys_webtds_check_conf / /edit_sys_webtds_check_conf(WebTDS)、/waf_conf_backup / /waf_conf_load(配置备份/加载)
SOC 安全运营:/get_soc_usage_stat_*、/get_soc_web_attack_*、/get_soc_flow_attack_*、/get_soc_attack_event_list、/get_soc_log_query_list、/get_soc_network_ip_* 等
节点监控:/get_node_monitor_list、/delete_node_monitor
三、关键接口详解
3.1 创建子账号
接口地址:POST /admin_api/create_sub_account
请求参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| sub_user_name | string | 是 | 子账号用户名(唯一) |
| user_password | string | 是 | 子账号密码(MD5 后存库) |
| sub_otp_auth | string | 是 | 是否启用 OTP("true" / "false") |
| website_access_conf | string | 是 | 绑定的网站接入配置名(需提前创建,不能为空) |
请求示例:
curl -X POST http://<host>/admin_api/create_sub_account \
-H "jxwaf-waf-auth: <your_waf_auth>" \
-H "Content-Type: application/json" \
-d '{
"sub_user_name": "client01",
"user_password": "password123",
"sub_otp_auth": "false",
"website_access_conf": "default_conf"
}'
返回示例:
{
"result": true,
"message": "create success"
}
当 sub_otp_auth 为 "true" 时,返回额外包含 OTP 绑定信息:
{
"result": true,
"message": "create success",
"otp_secret_key": "<base32密钥>",
"otp_auth_url": "otpauth://totp/..."
}
错误示例:
| 响应 Body | 说明 |
|---|---|
{"result": false, "message": "sub_user_name is exist"} | 子账号名已存在 |
{"result": false, "message": "website_access_conf is required"} | 接入配置为空 |
3.2 获取子账号列表
接口地址:POST /admin_api/get_sub_account_list
请求参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | integer | 是 | 页码,pageSize 固定 50 |
返回参数:
| 参数名 | 类型 | 说明 |
|---|---|---|
| result | boolean | 是否成功 |
| records | array | 子账号列表 |
| records[].sub_user_name | string | 子账号用户名 |
| records[].waf_auth | string | 子账号认证密钥 |
| records[].sub_otp_auth | string | 是否启用 OTP |
| records[].website_access_conf | string | 绑定的接入配置名 |
| records[].domain_count | integer | 域名数量 |
| records[].ssl_cert_count | integer | SSL 证书数量 |
| records[].web_engine_status | string | Web 防护引擎状态 |
| records[].flow_engine_status | string | 流量防护引擎状态 |
| page / total_pages / total_records | integer | 分页信息 |
返回示例:
{
"result": true,
"records": [
{
"sub_user_name": "client01",
"waf_auth": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"sub_otp_auth": "false",
"website_access_conf": "default_conf",
"domain_count": 3,
"ssl_cert_count": 2,
"web_engine_status": "true",
"flow_engine_status": "false"
}
],
"page": 1,
"total_pages": 1,
"total_records": 1
}
如需一次性获取全部子账号(无分页),可调用
/admin_api/api_get_sub_account_list(无需page参数),返回 records 含user_name, sub_user_name, sub_otp_auth, waf_auth, website_access_conf。
3.3 重置子账号 waf_auth
接口地址:POST /admin_api/edit_sub_account_waf_auth
请求参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| sub_user_name | string | 是 | 子账号用户名 |
返回示例:
{
"result": true,
"message": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
新 waf_auth 通过
message字段返回。重置后,原 waf_auth 立即失效,使用该子账号的用户控制台会话需重新登录。
3.4 创建网站接入配置
接口地址:POST /admin_api/create_website_access_conf
请求参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| website_access_conf_name | string | 是 | 配置名称(唯一,不能为 none) |
| website_access_conf_detail | string | 是 | 配置描述 |
| website_access_conf_type | string | 是 | DNS 服务商:aliyun / tencent / cloudflare |
| website_access_conf_api_key | string | 是 | DNS API Key(阿里云 AccessKey ID / 腾讯云 SecretId / Cloudflare API Token) |
| website_access_conf_api_secret | string | 是 | DNS API Secret(Cloudflare 可空) |
| website_access_conf_domain | string | 是 | 接入域名(CNAME 记录使用的根域名,如 acc.jxwaf.com) |
| website_access_conf_ip_list | string | 是 | 接入节点 IP 列表(JSON 数组串,如 ["1.1.1.1","2.2.2.2"]) |
| website_access_conf_ttl | string | 是 | DNS 记录 TTL(秒,默认 600) |
| resource_quota_enable | string | 是 | 是否启用资源配额("true" / "false") |
| resource_quota | string | 否 | 配额配置 JSON(仅 resource_quota_enable="true" 时有效,缺省 {}) |
返回示例:
{
"result": true,
"message": "create success"
}
创建接入配置后可调用
/admin_api/website_access_conf_connect_test(参数同上)验证 DNS 凭据是否有效。
3.5 创建域名
接口地址:POST /admin_api/create_domain
请求参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| sub_user_name | string | 是 | 所属子账号 |
| domain | string | 是 | 域名/IP,支持通配符(如 *.jxwaf.com) |
| http | string | 是 | 是否启用 HTTP("true"/"false") |
| https | string | 是 | 是否启用 HTTPS |
| ssl_domain | string | 是 | HTTPS 绑定的证书域名 |
| source_ip | string | 是 | 回源地址(JSON 数组串,支持 IP 与域名) |
| source_http_port | string | 是 | HTTP 回源端口 |
| source_https_port | string | 是 | HTTPS 回源端口 |
| origin_protocol | string | 是 | 回源协议:http / https / follow |
| balance_type | string | 是 | 负载均衡:round_robin / ip_hash |
| pre_proxy | string | 是 | WAF 前是否存在代理("true"/"false") |
| real_ip_conf | string | 是 | 真实 IP 请求头(X-Real-IP / X-Forwarded-For) |
| connect_timeout | string | 是 | 连接超时(秒) |
| send_timeout | string | 是 | 发送超时(秒) |
| read_timeout | string | 是 | 读取超时(秒) |
| detail | string | 是 | 网站描述 |
返回示例:
{
"result": true,
"message": "create success"
}
创建域名时,系统自动完成 WAF 侧 DNS 配置并生成 CNAME 接入值。子账号必须已绑定接入配置。
错误示例:
| 响应 Body | 说明 |
|---|---|
{"result": false, "message": "domain is exist"} | 域名已存在 |
{"result": false, "message": "domain resolver ip count is 0"} | 回源地址解析失败 |
{"result": false, "message": "dns api create a record failed: <err>"} | 云 DNS 创建 A 记录失败 |
3.6 获取域名列表
接口地址:POST /admin_api/get_domain_list
请求参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | integer | 是 | 页码,pageSize 固定 50 |
| sub_user_name | string | 是 | 所属子账号 |
返回 records 字段:
| 字段 | 说明 |
|---|---|
| sub_user_name, domain, detail | 子账号、域名、描述 |
| http, https, ssl_domain | 协议与证书 |
| source_ip, waf_update_source_ip | 原始回源地址、解析后的 IP 数组 |
| source_http_port, source_https_port, origin_protocol, balance_type, pre_proxy, real_ip_conf | 回源与负载均衡配置 |
| connect_timeout, send_timeout, read_timeout | 超时配置 |
| cname | CNAME 接入值(格式 <域名>.cname.<接入域名>) |
| cname_status, cname_check_time | 接入状态("true" 已接入 / "false" 未接入)、检查时间 |
3.7 全局名单管理
创建全局名单
接口地址:POST /admin_api/create_global_name_list
请求参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| name_list_name | string | 是 | 名单名称(唯一) |
| name_list_detail | string | 是 | 名单描述 |
| name_list_rule | string | 是 | 匹配规则(匹配参数组合) |
| name_list_action | string | 是 | 执行动作(如 block / reject_response / bot_check / network_block / watch 等) |
| action_value | string | 是 | 动作附加参数(如网络封禁持续时间) |
| name_list_expire | string | 是 | 是否过期("false" 永久 / "true" 自定义) |
| name_list_expire_time | integer | 是 | 过期时间(秒,name_list_expire="false" 时传 0) |
返回示例:
{
"result": true,
"message": "create success"
}
添加名单条目
接口地址:POST /admin_api/create_global_name_list_item
请求参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| name_list_name | string | 是 | 目标名单名称 |
| name_list_item | string | 是 | 条目内容(如 IP 地址) |
返回示例:
新增成功:
{"result": true, "message": "create_success"}
条目已存在(刷新过期时间):
{"result": true, "message": "edit_success"}
错误示例:
{"result": false, "message": "name_list_name 不存在"}
获取名单条目列表
接口地址:POST /admin_api/get_name_list_item_list_list
请求参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | integer | 是 | 页码,pageSize 固定 50 |
| name_list_name | string | 是 | 名单名称 |
返回参数:
| 参数名 | 类型 | 说明 |
|---|---|---|
| result | boolean | 是否成功 |
| records | array | 名单条目列表 |
| records[].name_list_name | string | 所属名单名称 |
| records[].name_list_item | string | 条目内容 |
| records[].name_list_expire | string | 过期时间配置("false" 表示永不过期) |
| records[].name_list_item_expire_time | integer | 条目过期时间戳(Unix 秒,0 表示永不过期) |
返回示例:
{
"result": true,
"records": [
{
"name_list_name": "blacklist",
"name_list_item": "192.168.1.100",
"name_list_expire": "86400",
"name_list_item_expire_time": 1735776000
}
],
"page": 1,
"total_pages": 1,
"total_records": 1
}
删除名单条目
接口地址:POST /admin_api/delete_global_name_list_item
请求参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| name_list_name | string | 是 | 名单名称 |
| name_list_item | string | 是 | 要删除的条目内容 |
返回示例:
{"result": true, "message": "删除成功"}
3.8 业务数据统计概览
接口地址:POST /admin_api/get_soc_usage_stat_overview
请求参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| from_time | string | 是 | 起始时间(YYYY-MM-DD HH:MM:SS) |
| to_time | string | 是 | 结束时间 |
| sub_user_name | string | 否 | 子账号(空则汇总所有子账号) |
| domain | string | 否 | 域名(空则汇总所有域名) |
返回参数:
| 参数名 | 类型 | 说明 |
|---|---|---|
| result | boolean | 是否成功 |
| overview | object | 统计概览 |
| overview.total_request | integer | 总请求数 |
| overview.traffic_in / traffic_out | integer | 入/出方向流量 |
| overview.status_2xx / 3xx / 4xx / 5xx | integer | 状态码计数 |
| overview.request_latency_avg / upstream_latency_avg | integer | 请求/回源平均时延(ms) |
| status_detail | object | 明细状态码计数({http_code: count}) |
返回示例:
{
"result": true,
"overview": {
"total_request": 125000,
"traffic_in": 5242880,
"traffic_out": 10485760,
"status_2xx": 120000,
"status_3xx": 2000,
"status_4xx": 2500,
"status_5xx": 500,
"request_latency_avg": 35,
"upstream_latency_avg": 120
},
"status_detail": {
"200": 118000,
"301": 2000,
"404": 2400,
"500": 500
},
"from_time": "2026-08-01 00:00:00",
"to_time": "2026-08-01 23:59:59"
}
3.9 节点状态列表
接口地址:POST /admin_api/get_node_monitor_list
请求参数:无(仅需 jxwaf-waf-auth 认证)
返回参数:
| 参数名 | 类型 | 说明 |
|---|---|---|
| result | boolean | 是否成功 |
| message | array | 节点列表(注意:数组位于 message 字段) |
| message[].node_uuid | string | 节点唯一标识 |
| message[].node_hostname | string | 节点主机名 |
| message[].node_ip | string | 节点 IP |
| message[].node_status | string | 健康状态("true" 正常 / "false" 异常,超过 10 分钟无心跳为异常) |
| message[].node_status_update_time | integer | 心跳时间 |
| message[].waf_conf_update_time | integer | 配置同步时间 |
返回示例:
{
"result": true,
"message": [
{
"node_uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"node_hostname": "node-01",
"node_ip": "1.1.1.1",
"node_status": "true",
"node_status_update_time": 1722470400,
"waf_conf_update_time": 1722470300
}
]
}
四、使用场景
场景1:批量开通部门
IT 运维团队通过 API 自动化开通部门:先创建接入配置,再创建子账号并绑定。
# 1. 创建网站接入配置
curl -X POST http://<host>/admin_api/create_website_access_conf \
-H "jxwaf-waf-auth: <your_waf_auth>" \
-H "Content-Type: application/json" \
-d '{
"website_access_conf_name": "default_conf",
"website_access_conf_detail": "默认接入配置",
"website_access_conf_type": "aliyun",
"website_access_conf_api_key": "<AccessKey ID>",
"website_access_conf_api_secret": "<AccessKey Secret>",
"website_access_conf_domain": "acc.jxwaf.com",
"website_access_conf_ip_list": "[\"1.1.1.1\",\"2.2.2.2\"]",
"website_access_conf_ttl": "600",
"resource_quota_enable": "false"
}'
# 2. 创建子账号并绑定接入配置
curl -X POST http://<host>/admin_api/create_sub_account \
-H "jxwaf-waf-auth: <your_waf_auth>" \
-H "Content-Type: application/json" \
-d '{
"sub_user_name": "client01",
"user_password": "password123",
"sub_otp_auth": "false",
"website_access_conf": "default_conf"
}'
场景2:通过外部系统自动封禁攻击 IP
当安全设备检测到攻击行为时,调用名单条目接口自动将攻击 IP 加入黑名单:
# 添加攻击 IP 到黑名单(已存在则刷新过期时间)
curl -X POST http://<host>/admin_api/create_global_name_list_item \
-H "jxwaf-waf-auth: <your_waf_auth>" \
-H "Content-Type: application/json" \
-d '{
"name_list_name": "auto_blacklist",
"name_list_item": "203.0.113.50"
}'
解封特定 IP:
curl -X POST http://<host>/admin_api/delete_global_name_list_item \
-H "jxwaf-waf-auth: <your_waf_auth>" \
-H "Content-Type: application/json" \
-d '{
"name_list_name": "auto_blacklist",
"name_list_item": "203.0.113.50"
}'
场景3:域名接入自动化
通过 Admin API 为子账号创建域名:
curl -X POST http://<host>/admin_api/create_domain \
-H "jxwaf-waf-auth: <your_waf_auth>" \
-H "Content-Type: application/json" \
-d '{
"sub_user_name": "client01",
"domain": "demo.jxwaf.com",
"http": "true",
"https": "true",
"ssl_domain": "demo.jxwaf.com",
"source_ip": "[\"1.2.3.4\"]",
"source_http_port": "80",
"source_https_port": "443",
"origin_protocol": "http",
"balance_type": "round_robin",
"pre_proxy": "false",
"real_ip_conf": "X-Real-IP",
"connect_timeout": "5",
"send_timeout": "60",
"read_timeout": "60",
"detail": "演示站点"
}'
创建后调用 /admin_api/get_domain_list 获取 cname 值。部门在用户控制台配置 DNS 自动接入后,系统自动完成 CNAME 解析。
场景4:查询业务运行数据
查询指定部门某时间段的业务统计概览:
curl -X POST http://<host>/admin_api/get_soc_usage_stat_overview \
-H "jxwaf-waf-auth: <your_waf_auth>" \
-H "Content-Type: application/json" \
-d '{
"from_time": "2026-08-01 00:00:00",
"to_time": "2026-08-01 23:59:59",
"sub_user_name": "client01"
}'
