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

关闭 API Key

DELETE/v1/api-key

关闭并删除当前登录用户的 API Key 配置;管理员可通过 uid 关闭指定用户。删除的是整条配置记录,包括 API Key、API Secret 和来源 IP 白名单;事务提交后旧凭证立即无法用于后续 API 认证。目标用户必须已经开通 API Key。

身份认证

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 同时发送。"
  }
}

请求参数

参数位置类型必填说明与约束
uidqueryinteger (int64)可选

要关闭 API Key 的用户 ID。省略时关闭当前登录用户的密钥;仅管理员可指定其他用户。

完整参数定义
{
  "name": "uid",
  "in": "query",
  "required": false,
  "description": "要关闭 API Key 的用户 ID。省略时关闭当前登录用户的密钥;仅管理员可指定其他用户。",
  "schema": {
    "type": "integer",
    "format": "int64",
    "minimum": 1
  },
  "example": 2
}

响应

HTTP 200

业务结果通过 HTTP 200 返回。API Key 配置删除并提交后返回确认消息;目标用户未开通、普通用户尝试指定 uid 或认证无效时返回字符串业务错误码,删除事务会回滚。

application/json

oneOf

oneOf · 1 · object
字段类型必填说明与约束
codeinteger必填

成功状态码,API Key 配置删除成功时固定为 0。

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

API Key 配置删除并提交事务后返回的确认消息。

约束 / 默认值 / 示例
{
  "enum": [
    "api_key关闭成功"
  ]
}
datastring必填

关闭成功时没有额外业务数据,固定为 null。

约束 / 默认值 / 示例
{
  "nullable": true,
  "enum": [
    null
  ]
}
oneOf · 2 · object
字段类型必填说明与约束
codestring必填

业务错误码:api-key-4 表示目标用户尚未开通 API Key,message-28 表示普通用户尝试关闭指定用户的密钥,login_required 表示登录态或 API Key 认证无效。

约束 / 默认值 / 示例
{
  "enum": [
    "api-key-4",
    "message-28",
    "login_required"
  ]
}
msgstring必填

与业务错误码对应的中文未开通、权限或认证失败原因。

datastring必填

业务错误时固定为空字符串。

约束 / 默认值 / 示例
{
  "enum": [
    ""
  ]
}
完整 Schema
{
  "oneOf": [
    {
      "type": "object",
      "required": [
        "code",
        "msg",
        "data"
      ],
      "properties": {
        "code": {
          "type": "integer",
          "enum": [
            0
          ],
          "description": "成功状态码,API Key 配置删除成功时固定为 0。"
        },
        "msg": {
          "type": "string",
          "enum": [
            "api_key关闭成功"
          ],
          "description": "API Key 配置删除并提交事务后返回的确认消息。"
        },
        "data": {
          "type": "string",
          "nullable": true,
          "enum": [
            null
          ],
          "description": "关闭成功时没有额外业务数据,固定为 null。"
        }
      },
      "additionalProperties": false
    },
    {
      "type": "object",
      "required": [
        "code",
        "msg",
        "data"
      ],
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "api-key-4",
            "message-28",
            "login_required"
          ],
          "description": "业务错误码:`api-key-4` 表示目标用户尚未开通 API Key,`message-28` 表示普通用户尝试关闭指定用户的密钥,`login_required` 表示登录态或 API Key 认证无效。"
        },
        "msg": {
          "type": "string",
          "description": "与业务错误码对应的中文未开通、权限或认证失败原因。"
        },
        "data": {
          "type": "string",
          "enum": [
            ""
          ],
          "description": "业务错误时固定为空字符串。"
        }
      },
      "additionalProperties": false
    }
  ]
}

示例

{
  "code": 0,
  "msg": "api_key关闭成功",
  "data": null
}

cURL 示例

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

curl --request DELETE \
  "https://master.example.invalid/v1/api-key" \
  --header "access-token: YOUR_ACCESS_TOKEN"

查看完整接口 JSON