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

更新指定用户套餐

PUT/v1/user-packages/{package_id}

更新一个已购买套餐的名称、线路、CNAME、资源额度、开关或到期时间,也可通过 duration 为套餐续费。普通用户只能更新自己的套餐中无需管理员权限的字段;资源额度、价格、CNAME 主机名、到期时间及启用状态仅管理员可改。传入 package 时执行更换基础套餐并立即完成,不能与其他修改字段组合处理。

身份认证

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

请求参数

参数位置类型必填说明与约束
package_idpathinteger必填

要更新的用户套餐 ID。套餐必须存在;普通用户只能操作自己的套餐。

完整参数定义
{
  "name": "package_id",
  "in": "path",
  "required": true,
  "schema": {
    "type": "integer",
    "minimum": 1,
    "example": 8
  },
  "description": "要更新的用户套餐 ID。套餐必须存在;普通用户只能操作自己的套餐。"
}

请求体 · 必填

application/json

object

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

管理员专用。指定续费、优惠和余额处理所使用的用户 ID;必须存在。该字段不会转移用户套餐归属。

约束 / 默认值 / 示例
{
  "minimum": 1,
  "example": 12
}
packageinteger可选

更换目标基础套餐定义 ID。不能与当前套餐相同;传入后立即执行换套餐,其他请求字段不会继续处理。

约束 / 默认值 / 示例
{
  "minimum": 1,
  "example": 3
}
namestring可选

套餐显示名称;会进行 XSS 过滤。

约束 / 默认值 / 示例
{
  "minLength": 1,
  "example": "我的标准套餐"
}
durationstring可选

续费期限。续费会按套餐及已购升级包价格扣除当前用户余额并延长到期时间;管理员续费不扣费。

约束 / 默认值 / 示例
{
  "enum": [
    "month",
    "quarter",
    "year"
  ],
  "example": "month"
}
coupon_codestring可选

续费时使用的优惠码;仅在同时传入 duration 时参与价格计算。

约束 / 默认值 / 示例
{
  "example": "WELCOME10"
}
region_idinteger可选

区域 ID。更新时线路组必须属于该区域;变更会同步使用套餐 CNAME 的网站和四层转发。

约束 / 默认值 / 示例
{
  "minimum": 1,
  "example": 1
}
node_group_idinteger可选

主线路组 ID,不能为空,且必须属于当前区域。

约束 / 默认值 / 示例
{
  "minimum": 1,
  "example": 2
}
backup_node_groupinteger可选

备用线路组 ID;传空值可清除。若设置,必须属于当前区域且不能与主线路组相同。

约束 / 默认值 / 示例
{
  "minimum": 1,
  "nullable": true,
  "example": 3
}
cname_domaininteger可选

CNAME 域名配置 ID,必须存在。变更会更新套餐及相关网站、四层转发的 CNAME 记录。

约束 / 默认值 / 示例
{
  "minimum": 1,
  "example": 4
}
cname_modestring可选

CNAME 归属模式:site 为网站或转发各自使用 CNAME,package 为跟随用户套餐。

约束 / 默认值 / 示例
{
  "enum": [
    "site",
    "package"
  ],
  "example": "package"
}
cname_hostnamestring可选

管理员专用。套餐 CNAME 主机名;每个以点分隔的标签都必须是合法主机名,且在用户套餐中唯一。

约束 / 默认值 / 示例
{
  "example": "user-12.example.invalid"
}
trafficinteger可选

管理员专用。流量额度;-1 表示不限。提高额度或改为不限时会解除流量超额状态。

约束 / 默认值 / 示例
{
  "minimum": -1,
  "example": 100
}
bandwidthstring可选

管理员专用。带宽额度;-1 表示不限,其他值必须为数字加 Mbps 或 Gbps。

约束 / 默认值 / 示例
{
  "example": "100Mbps"
}
connectioninteger可选

管理员专用。并发连接数额度;-1 表示不限。

约束 / 默认值 / 示例
{
  "minimum": -1,
  "example": 1000
}
domaininteger可选

管理员专用。域名数量额度;-1 表示不限。

约束 / 默认值 / 示例
{
  "minimum": -1,
  "example": 10
}
main_domaininteger可选

管理员专用。主域名数量额度;-1 表示不限。

约束 / 默认值 / 示例
{
  "minimum": -1,
  "example": 5
}
http_portinteger可选

管理员专用。HTTP 非标准端口数量额度;-1 表示不限。

约束 / 默认值 / 示例
{
  "minimum": -1,
  "example": 3
}
stream_portinteger可选

管理员专用。四层转发端口数量额度;-1 表示不限。

约束 / 默认值 / 示例
{
  "minimum": -1,
  "example": 2
}
custom_cc_ruleinteger可选

管理员专用。是否允许自定义 CC 规则。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ],
  "example": 1
}
websocketinteger可选

管理员专用。是否允许 WebSocket。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ],
  "example": 1
}
http3integer可选

管理员专用。是否允许 HTTP/3。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ],
  "example": 1
}
enable_ipv6integer可选

是否启用 IPv6;变更会创建 CNAME 更新任务。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ],
  "example": 1
}
month_priceinteger可选

管理员专用。用户套餐的月付价格。

约束 / 默认值 / 示例
{
  "minimum": 0,
  "example": 1000
}
quarter_priceinteger可选

管理员专用。用户套餐的季付价格。

约束 / 默认值 / 示例
{
  "minimum": 0,
  "example": 2700
}
year_priceinteger可选

管理员专用。用户套餐的年付价格。

约束 / 默认值 / 示例
{
  "minimum": 0,
  "example": 10000
}
end_atstring可选

管理员专用。直接设置到期时间,格式 YYYY-MM-DD HH:mm:ss。

约束 / 默认值 / 示例
{
  "pattern": "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$",
  "example": "2026-12-31 23:59:59"
}
enableinteger可选

管理员专用。套餐启用状态;设为 0 时必须同时提供 reason,设为 1 会恢复相关网站和转发。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ],
  "example": 1
}
reasonstring可选

当 enable 为 0 时必填,表示禁用原因。

约束 / 默认值 / 示例
{
  "enum": [
    "到期",
    "流量用完",
    "锁定"
  ],
  "example": "锁定"
}
sync-itemstring可选

可选。将套餐配置同步到关联网站和四层转发的项目。可传 cname_mode,或以英文逗号组合 node_group_id、cname_domain、cname_mode。

约束 / 默认值 / 示例
{
  "example": "node_group_id,cname_domain"
}
完整 Schema
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "uid": {
      "type": "integer",
      "minimum": 1,
      "description": "管理员专用。指定续费、优惠和余额处理所使用的用户 ID;必须存在。该字段不会转移用户套餐归属。",
      "example": 12
    },
    "package": {
      "type": "integer",
      "minimum": 1,
      "description": "更换目标基础套餐定义 ID。不能与当前套餐相同;传入后立即执行换套餐,其他请求字段不会继续处理。",
      "example": 3
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "description": "套餐显示名称;会进行 XSS 过滤。",
      "example": "我的标准套餐"
    },
    "duration": {
      "type": "string",
      "enum": [
        "month",
        "quarter",
        "year"
      ],
      "description": "续费期限。续费会按套餐及已购升级包价格扣除当前用户余额并延长到期时间;管理员续费不扣费。",
      "example": "month"
    },
    "coupon_code": {
      "type": "string",
      "description": "续费时使用的优惠码;仅在同时传入 duration 时参与价格计算。",
      "example": "WELCOME10"
    },
    "region_id": {
      "type": "integer",
      "minimum": 1,
      "description": "区域 ID。更新时线路组必须属于该区域;变更会同步使用套餐 CNAME 的网站和四层转发。",
      "example": 1
    },
    "node_group_id": {
      "type": "integer",
      "minimum": 1,
      "description": "主线路组 ID,不能为空,且必须属于当前区域。",
      "example": 2
    },
    "backup_node_group": {
      "type": "integer",
      "minimum": 1,
      "nullable": true,
      "description": "备用线路组 ID;传空值可清除。若设置,必须属于当前区域且不能与主线路组相同。",
      "example": 3
    },
    "cname_domain": {
      "type": "integer",
      "minimum": 1,
      "description": "CNAME 域名配置 ID,必须存在。变更会更新套餐及相关网站、四层转发的 CNAME 记录。",
      "example": 4
    },
    "cname_mode": {
      "type": "string",
      "enum": [
        "site",
        "package"
      ],
      "description": "CNAME 归属模式:site 为网站或转发各自使用 CNAME,package 为跟随用户套餐。",
      "example": "package"
    },
    "cname_hostname": {
      "type": "string",
      "description": "管理员专用。套餐 CNAME 主机名;每个以点分隔的标签都必须是合法主机名,且在用户套餐中唯一。",
      "example": "user-12.example.invalid"
    },
    "traffic": {
      "type": "integer",
      "minimum": -1,
      "description": "管理员专用。流量额度;-1 表示不限。提高额度或改为不限时会解除流量超额状态。",
      "example": 100
    },
    "bandwidth": {
      "type": "string",
      "description": "管理员专用。带宽额度;-1 表示不限,其他值必须为数字加 Mbps 或 Gbps。",
      "example": "100Mbps"
    },
    "connection": {
      "type": "integer",
      "minimum": -1,
      "description": "管理员专用。并发连接数额度;-1 表示不限。",
      "example": 1000
    },
    "domain": {
      "type": "integer",
      "minimum": -1,
      "description": "管理员专用。域名数量额度;-1 表示不限。",
      "example": 10
    },
    "main_domain": {
      "type": "integer",
      "minimum": -1,
      "description": "管理员专用。主域名数量额度;-1 表示不限。",
      "example": 5
    },
    "http_port": {
      "type": "integer",
      "minimum": -1,
      "description": "管理员专用。HTTP 非标准端口数量额度;-1 表示不限。",
      "example": 3
    },
    "stream_port": {
      "type": "integer",
      "minimum": -1,
      "description": "管理员专用。四层转发端口数量额度;-1 表示不限。",
      "example": 2
    },
    "custom_cc_rule": {
      "type": "integer",
      "enum": [
        0,
        1
      ],
      "description": "管理员专用。是否允许自定义 CC 规则。",
      "example": 1
    },
    "websocket": {
      "type": "integer",
      "enum": [
        0,
        1
      ],
      "description": "管理员专用。是否允许 WebSocket。",
      "example": 1
    },
    "http3": {
      "type": "integer",
      "enum": [
        0,
        1
      ],
      "description": "管理员专用。是否允许 HTTP/3。",
      "example": 1
    },
    "enable_ipv6": {
      "type": "integer",
      "enum": [
        0,
        1
      ],
      "description": "是否启用 IPv6;变更会创建 CNAME 更新任务。",
      "example": 1
    },
    "month_price": {
      "type": "integer",
      "minimum": 0,
      "description": "管理员专用。用户套餐的月付价格。",
      "example": 1000
    },
    "quarter_price": {
      "type": "integer",
      "minimum": 0,
      "description": "管理员专用。用户套餐的季付价格。",
      "example": 2700
    },
    "year_price": {
      "type": "integer",
      "minimum": 0,
      "description": "管理员专用。用户套餐的年付价格。",
      "example": 10000
    },
    "end_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$",
      "description": "管理员专用。直接设置到期时间,格式 YYYY-MM-DD HH:mm:ss。",
      "example": "2026-12-31 23:59:59"
    },
    "enable": {
      "type": "integer",
      "enum": [
        0,
        1
      ],
      "description": "管理员专用。套餐启用状态;设为 0 时必须同时提供 reason,设为 1 会恢复相关网站和转发。",
      "example": 1
    },
    "reason": {
      "type": "string",
      "enum": [
        "到期",
        "流量用完",
        "锁定"
      ],
      "description": "当 enable 为 0 时必填,表示禁用原因。",
      "example": "锁定"
    },
    "sync-item": {
      "type": "string",
      "description": "可选。将套餐配置同步到关联网站和四层转发的项目。可传 cname_mode,或以英文逗号组合 node_group_id、cname_domain、cname_mode。",
      "example": "node_group_id,cname_domain"
    }
  },
  "example": {
    "name": "我的标准套餐",
    "node_group_id": 2,
    "backup_node_group": 3,
    "cname_mode": "package",
    "enable_ipv6": 1
  }
}

请求体示例

{
  "name": "我的标准套餐",
  "node_group_id": 2,
  "backup_node_group": 3,
  "cname_mode": "package",
  "enable_ipv6": 1
}

响应

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_package-87",
  "msg": "需要管理员权限",
  "data": ""
}

续费余额不足

{
  "code": "user_package-13",
  "msg": "余额不足",
  "data": ""
}

cURL 示例

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

curl --request PUT \
  "https://master.example.invalid/v1/user-packages/{package_id}" \
  --header "access-token: YOUR_ACCESS_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{"name": "我的标准套餐", "node_group_id": 2, "backup_node_group": 3, "cname_mode": "package", "enable_ipv6": 1}'

查看完整接口 JSON