itecdn 5.x / 用户 API
新增用户配置
POST
/v1/user-configs创建用户默认配置。配置项由 type、name 和作用域唯一确定;value 为字符串,其内容按配置类型和名称进行服务端校验。默认作用域为全局,默认启用。普通用户创建自己的配置;管理员可通过 uid 为指定用户创建。
身份认证
access-token
api-key + api-secret
认证定义
{
"AccessToken": {
"type": "apiKey",
"in": "header",
"name": "access-token",
"description": "通过登录接口获得的短期访问令牌。"
},
"ApiKey": {
"type": "apiKey",
"in": "header",
"name": "api-key",
"description": "API Key;必须和 api-secret 同时发送。"
},
"ApiSecret": {
"type": "apiKey",
"in": "header",
"name": "api-secret",
"description": "API Secret;必须和 api-key 同时发送。"
}
}请求参数
未定义路径、查询或请求头参数。
请求体 · 必填
application/json
object
| 字段 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|
name | string | 必填 | 必填。配置项名称;会进行 XSS 过滤,并决定 约束 / 默认值 / 示例 |
value | string | 必填 | 必填。配置值字符串;例如 约束 / 默认值 / 示例 |
type | string | 必填 | 必填。配置类型:网站、四层转发或证书。 约束 / 默认值 / 示例 |
scope_name | string | 可选 | 作用域名称;未传时为 约束 / 默认值 / 示例 |
scope_id | integer | 可选 | 作用域 ID;全局作用域固定为 0。分组作用域时,site 类型必须是现有网站组 ID,stream 类型必须是现有转发组 ID。 约束 / 默认值 / 示例 |
enable | integer | 可选 | 是否启用;未传时为 1。 约束 / 默认值 / 示例 |
uid | integer | 可选 | 管理员专用。指定配置归属用户 ID。 约束 / 默认值 / 示例 |
完整 Schema
{
"type": "object",
"required": [
"name",
"value",
"type"
],
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"minLength": 1,
"description": "必填。配置项名称;会进行 XSS 过滤,并决定 `value` 的具体校验规则。",
"example": "proxy_cache"
},
"value": {
"type": "string",
"description": "必填。配置值字符串;例如 `proxy_cache` 要求 JSON 数组,`white_ip`/`black_ip` 为 IP/CIDR 列表,`block_time`/`white_time` 为 601 至 604800 秒。其他名称也按服务端对应规则验证。",
"example": "[]"
},
"type": {
"type": "string",
"enum": [
"site",
"stream",
"cert"
],
"description": "必填。配置类型:网站、四层转发或证书。",
"example": "site"
},
"scope_name": {
"type": "string",
"enum": [
"global",
"group"
],
"default": "global",
"description": "作用域名称;未传时为 `global`。`group` 表示按网站组或转发组生效。",
"example": "global"
},
"scope_id": {
"type": "integer",
"minimum": 0,
"default": 0,
"description": "作用域 ID;全局作用域固定为 0。分组作用域时,site 类型必须是现有网站组 ID,stream 类型必须是现有转发组 ID。",
"example": 0
},
"enable": {
"type": "integer",
"enum": [
0,
1
],
"default": 1,
"description": "是否启用;未传时为 1。",
"example": 1
},
"uid": {
"type": "integer",
"minimum": 1,
"description": "管理员专用。指定配置归属用户 ID。",
"example": 12
}
},
"example": {
"name": "proxy_cache",
"value": "[]",
"type": "site",
"scope_name": "global",
"scope_id": 0,
"enable": 1
}
}请求体示例
{
"name": "proxy_cache",
"value": "[]",
"type": "site",
"scope_name": "global",
"scope_id": 0,
"enable": 1
}响应
HTTP 200
请求已被处理。成功时 code 为 0、msg 为“用户配置添加成功”、data 为新建配置 ID;名称、值、作用域无效或配置重复时仍返回 HTTP 200。
application/json
object
| 字段 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|
code | integer | 必填 | 业务状态码;成功为 0。 约束 / 默认值 / 示例 |
msg | string | 必填 | 处理结果说明。 约束 / 默认值 / 示例 |
data | integer | 必填 | 成功时的新建配置 ID;失败时为空字符串。 约束 / 默认值 / 示例 |
完整 Schema
{
"type": "object",
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "业务状态码;成功为 0。",
"example": 0
},
"msg": {
"type": "string",
"description": "处理结果说明。",
"example": "用户配置添加成功"
},
"data": {
"type": "integer",
"description": "成功时的新建配置 ID;失败时为空字符串。",
"example": 9
}
}
}示例
{
"code": 0,
"msg": "用户配置添加成功",
"data": 9
}创建成功
{
"code": 0,
"msg": "用户配置添加成功",
"data": 9
}配置重复
{
"code": "user_config-18",
"msg": "存在重复的设置项",
"data": ""
}cURL 示例
根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。
curl --request POST \
"https://master.example.invalid/v1/user-configs" \
--header "access-token: YOUR_ACCESS_TOKEN" \
--header "Content-Type: application/json" \
--data '{"name": "proxy_cache", "value": "[]", "type": "site", "scope_name": "global", "scope_id": 0, "enable": 1}'