itecdn 5.x用户文档
itecdn 5.x / 用户 API

创建用户

POST/v1/user

注册普通用户。是否开放注册,以及用户名、邮箱、手机和 QQ 是否必填、是否需要邮箱或手机验证码,均由系统的注册配置决定。无论配置如何,必须同意注册协议并提供符合规则的密码。

身份认证

无需身份认证。

请求参数

未定义路径、查询或请求头参数。

请求体 · 必填

application/json

object

字段类型必填说明与约束
usernamestring可选

当系统要求用户名时必填。仅允许中文、英文字母与数字,不能是手机号,且必须唯一。

约束 / 默认值 / 示例
{
  "example": "demo_user"
}
emailstring (email)可选

当系统要求邮箱时必填,且必须唯一;若系统配置邮箱验证,需同时提供 captcha。

约束 / 默认值 / 示例
{
  "format": "email",
  "example": "demo@example.invalid"
}
phonestring可选

当系统要求手机号时必填,且必须唯一;若系统配置手机验证,需同时提供 phone_captcha。

约束 / 默认值 / 示例
{
  "example": "13800000000"
}
qqstring可选

当系统要求 QQ 时必填,必须为合法 QQ 号。

约束 / 默认值 / 示例
{
  "example": "10001"
}
captchastring可选

邮箱验证码;仅在系统启用必填邮箱且要求邮箱验证时必填。

约束 / 默认值 / 示例
{
  "example": "123456"
}
phone_captchastring可选

手机验证码;仅在系统启用必填手机且要求手机验证时必填。

约束 / 默认值 / 示例
{
  "example": "123456"
}
accept_agreementinteger必填

必填。必须为 1,表示同意注册协议。

约束 / 默认值 / 示例
{
  "enum": [
    1
  ],
  "example": 1
}
passwordstring (password)必填

必填。至少 6 位,且必须同时包含英文字母和数字。

约束 / 默认值 / 示例
{
  "format": "password",
  "minLength": 6,
  "example": "Demo123456"
}
完整 Schema
{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "accept_agreement",
    "password"
  ],
  "properties": {
    "username": {
      "type": "string",
      "description": "当系统要求用户名时必填。仅允许中文、英文字母与数字,不能是手机号,且必须唯一。",
      "example": "demo_user"
    },
    "email": {
      "type": "string",
      "format": "email",
      "description": "当系统要求邮箱时必填,且必须唯一;若系统配置邮箱验证,需同时提供 `captcha`。",
      "example": "demo@example.invalid"
    },
    "phone": {
      "type": "string",
      "description": "当系统要求手机号时必填,且必须唯一;若系统配置手机验证,需同时提供 `phone_captcha`。",
      "example": "13800000000"
    },
    "qq": {
      "type": "string",
      "description": "当系统要求 QQ 时必填,必须为合法 QQ 号。",
      "example": "10001"
    },
    "captcha": {
      "type": "string",
      "description": "邮箱验证码;仅在系统启用必填邮箱且要求邮箱验证时必填。",
      "example": "123456"
    },
    "phone_captcha": {
      "type": "string",
      "description": "手机验证码;仅在系统启用必填手机且要求手机验证时必填。",
      "example": "123456"
    },
    "accept_agreement": {
      "type": "integer",
      "enum": [
        1
      ],
      "description": "必填。必须为 1,表示同意注册协议。",
      "example": 1
    },
    "password": {
      "type": "string",
      "format": "password",
      "minLength": 6,
      "description": "必填。至少 6 位,且必须同时包含英文字母和数字。",
      "example": "Demo123456"
    }
  },
  "example": {
    "username": "demo_user",
    "email": "demo@example.invalid",
    "phone": "13800000000",
    "captcha": "123456",
    "phone_captcha": "123456",
    "accept_agreement": 1,
    "password": "Demo123456"
  }
}

请求体示例

{
  "username": "demo_user",
  "email": "demo@example.invalid",
  "phone": "13800000000",
  "captcha": "123456",
  "phone_captcha": "123456",
  "accept_agreement": 1,
  "password": "Demo123456"
}

响应

HTTP 200

请求已被处理。注册成功时 code 为 0、msg 为“注册成功!”、data 为 null;注册关闭、字段缺失、格式错误、账号重复或验证码无效时仍返回 HTTP 200。

application/json

object

字段类型必填说明与约束
codeinteger必填

业务状态码;成功为 0。

约束 / 默认值 / 示例
{
  "example": 0
}
msgstring必填

处理结果说明。

约束 / 默认值 / 示例
{
  "example": "注册成功!"
}
datastring必填

注册成功时为 null;失败时为空字符串。

约束 / 默认值 / 示例
{
  "nullable": true,
  "example": null
}
完整 Schema
{
  "type": "object",
  "required": [
    "code",
    "msg",
    "data"
  ],
  "properties": {
    "code": {
      "type": "integer",
      "description": "业务状态码;成功为 0。",
      "example": 0
    },
    "msg": {
      "type": "string",
      "description": "处理结果说明。",
      "example": "注册成功!"
    },
    "data": {
      "type": "string",
      "nullable": true,
      "description": "注册成功时为 null;失败时为空字符串。",
      "example": null
    }
  }
}

示例

{
  "code": 0,
  "msg": "注册成功!",
  "data": null
}

注册成功

{
  "code": 0,
  "msg": "注册成功!",
  "data": null
}

未同意协议

{
  "code": "user-29",
  "msg": "请勾选同意协议再注册",
  "data": ""
}

注册关闭

{
  "code": "user-15",
  "msg": "目前已关闭注册!",
  "data": ""
}

cURL 示例

根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。

curl --request POST \
  "https://master.example.invalid/v1/user" \
  --header "Content-Type: application/json" \
  --data '{"username": "demo_user", "email": "demo@example.invalid", "phone": "13800000000", "captcha": "123456", "phone_captcha": "123456", "accept_agreement": 1, "password": "Demo123456"}'

查看完整接口 JSON