Update User Plan
把用户切换到指定 API 套餐(同时覆盖限流值、可选重置积分、刷新到期时间)。
参数: body.plan_id: 目标套餐,必须是 plan_type='api' 且 is_active 的套餐, 否则 404,避免把用户挂到已下架/非 API 套餐上。 body.reset_credits: 是否把积分重置为套餐额度(按 monthly_limit 换算)。 body.validity_period: 有效期档位,未传则用套餐自带档位,再兜底 "1m"。
副作用:一次事务内改 User + 追加 CreditLog 后 commit;随后清用户鉴权缓存和 C 端看板缓存,最后(如需)把积分增量同步进 Redis。Redis 失败只记日志不抛错, 与 adjust_credits 的取舍一致:MySQL 为准,Redis 是加速层。
事务边界:所有字段改动都攒到同一次 commit,中间不落库;因此下面的 validity_period 校验失败直接 return 时,本次会话里的改动不会被提交(被丢弃)。
post/admin/users/{user_id}/plan
Request
- Base URL: https://api.twtapi.com (the document declares no server; this is the origin it was published from)
- URL: https://api.twtapi.com/admin/users/{user_id}/plan
- Auth: none declared
Path parameters
user_idinteger required
Request body
Response
Successful Response
unknown required
Changes
No recorded changes to this operation across all 2 revisions of this API.