{
  "tags": [
    "用户默认配置"
  ],
  "description": "创建用户默认配置。配置项由 `type`、`name` 和作用域唯一确定；`value` 为字符串，其内容按配置类型和名称进行服务端校验。默认作用域为全局，默认启用。普通用户创建自己的配置；管理员可通过 `uid` 为指定用户创建。",
  "operationId": "user_post_v1_user_configs",
  "security": [
    {
      "AccessToken": []
    },
    {
      "ApiKey": [],
      "ApiSecret": []
    }
  ],
  "responses": {
    "200": {
      "description": "请求已被处理。成功时 `code` 为 0、`msg` 为“用户配置添加成功”、`data` 为新建配置 ID；名称、值、作用域无效或配置重复时仍返回 HTTP 200。",
      "content": {
        "application/json": {
          "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
              }
            }
          },
          "examples": {
            "success": {
              "summary": "创建成功",
              "value": {
                "code": 0,
                "msg": "用户配置添加成功",
                "data": 9
              }
            },
            "duplicate": {
              "summary": "配置重复",
              "value": {
                "code": "user_config-18",
                "msg": "存在重复的设置项",
                "data": ""
              }
            }
          },
          "example": {
            "code": 0,
            "msg": "用户配置添加成功",
            "data": 9
          }
        }
      }
    }
  },
  "x-python-handler": "config.UserConfigAPI",
  "x-python-route-line": 613,
  "x-audience": "user",
  "x-auth": "user",
  "x-reviewed": true,
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "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
          }
        }
      }
    }
  },
  "parameters": [],
  "x-itecdn-source-reviewed": true,
  "extensions": [
    {
      "key": "x-python-handler",
      "value": "config.UserConfigAPI"
    },
    {
      "key": "x-python-route-line",
      "value": 613
    },
    {
      "key": "x-audience",
      "value": "user"
    },
    {
      "key": "x-auth",
      "value": "user"
    },
    {
      "key": "x-reviewed",
      "value": true
    },
    {
      "key": "x-itecdn-source-reviewed",
      "value": true
    }
  ],
  "method": "post",
  "path": "/v1/user-configs",
  "servers": [
    {
      "url": "https://master.example.invalid",
      "description": "不可调用的示例地址；复制示例后替换为自己的主控域名。"
    }
  ],
  "securitySchemes": {
    "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 同时发送。"
    }
  },
  "jsonRequestBodyExample": {
    "name": "proxy_cache",
    "value": "[]",
    "type": "site",
    "scope_name": "global",
    "scope_id": 0,
    "enable": 1
  },
  "info": {
    "title": "itecdn v5 用户 API",
    "version": "5.x",
    "description": "itecdn v5.x Python 主控用户 API。本文档不适用于 v6 或其它实现。"
  },
  "postman": {
    "name": "新增用户配置",
    "description": {
      "content": "创建用户默认配置。配置项由 `type`、`name` 和作用域唯一确定；`value` 为字符串，其内容按配置类型和名称进行服务端校验。默认作用域为全局，默认启用。普通用户创建自己的配置；管理员可通过 `uid` 为指定用户创建。",
      "type": "text/plain"
    },
    "url": {
      "path": [
        "v1",
        "user-configs"
      ],
      "host": [
        "{{baseUrl}}"
      ],
      "query": [],
      "variable": []
    },
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      },
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "method": "POST",
    "body": {
      "mode": "raw",
      "raw": "",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "auth": {
      "type": "apikey",
      "apikey": [
        {
          "type": "any",
          "value": "access-token",
          "key": "key"
        },
        {
          "type": "any",
          "value": "{{apiKey}}",
          "key": "value"
        },
        {
          "type": "any",
          "value": "header",
          "key": "in"
        }
      ]
    }
  }
}