POST/api/v1/subscriptions创建订阅(HTTP 镜像)
Try it 面板需要启用 JavaScript。
创建周期订阅。业务服务经 NATS subject payment.subscription.create 创建;本 HTTP 端点供内部工具使用,语义相同。
Request
| Name | Data Type | Required | Description |
| Authorization | string | Yes | 会话令牌认证,格式 `Bearer <sessionToken>` |
| Content-Type | string | Yes | 请求体内容类型(默认值 "application/json") |
type RequestHeaders = {
/** 会话令牌认证,格式 `Bearer <sessionToken>` */
Authorization: string
/** 请求体内容类型,默认值 "application/json" */
Content-Type: string
}
{
"Authorization": "Bearer st_7c1f9e05b28d4a63",
"Content-Type": "application/json"
}
Body
| Name | Data Type | Required | Description |
| userId | string | Yes | 用户 ID |
| title | string | Yes | 订阅标题 |
| businessService | string | Yes | 业务服务标识 |
| amount | number | Yes | 周期金额 |
| currency | string | Yes | 币种 |
| interval | string | Yes | 周期:monthly / yearly |
| defaultMethodId | string | No | 扣款支付方式(可选,缺省用用户默认支付方式) |
type RequestBody = {
/** 用户 ID */
userId: string
/** 订阅标题 */
title: string
/** 业务服务标识 */
businessService: string
/** 周期金额 */
amount: number
/** 币种 */
currency: string
/** 周期:monthly / yearly */
interval: string
/** 扣款支付方式(可选,缺省用用户默认支付方式) */
defaultMethodId?: string
}
{
"userId": "01JD8SEGQ0P9N2XK4L7VDH3T6C",
"title": "Xeegam Cloud · 专业版",
"businessService": "cloud",
"amount": 28,
"currency": "USD",
"interval": "monthly"
}
Response
Body
| Name | Data Type | Required | Description |
| subscriptionId | string | Yes | 订阅 ID |
| userId | string | Yes | 用户 ID |
| title | string | Yes | 订阅标题 |
| businessService | string | Yes | 业务服务 |
| amount | number | Yes | 周期金额 |
| currency | string | Yes | 币种 |
| interval | string | Yes | 周期 |
| status | string | Yes | 固定为 active |
| nextRenewalAt | string | Yes | 下次续订时间 |
| createdAt | string | Yes | 创建时间 |
type ResponseBody = {
/** 订阅 ID */
subscriptionId: string
/** 用户 ID */
userId: string
/** 订阅标题 */
title: string
/** 业务服务 */
businessService: string
/** 周期金额 */
amount: number
/** 币种 */
currency: string
/** 周期 */
interval: string
/** 固定为 active */
status: string
/** 下次续订时间 */
nextRenewalAt: string
/** 创建时间 */
createdAt: string
}
{
"subscriptionId": "01JD8SOBHV0C3D9JD",
"userId": "01JD8SEGQ0P9N2XK4L7VDH3T6C",
"title": "Xeegam Cloud · 专业版",
"businessService": "cloud",
"amount": 28,
"currency": "USD",
"interval": "monthly",
"status": "active",
"nextRenewalAt": "2026-11-13T09:00:00Z",
"createdAt": "2026-10-14T15:30:00Z"
}
HTTP Code
| HTTP Status |
Meaning |
Notes |
| 200 |
成功 |
返回新订阅 |
Response Code
响应使用统一信封 {id, code, messages, result},其 code 字段:
| code |
Meaning |
Notes |
| 0 |
成功 |
返回新订阅 |
| 2803 |
缺少可用支付方式 |
用户既无指定支付方式也无默认支付方式 |
Examples
POST /api/v1/subscriptions
Authorization: Bearer st_7c1f9e05b28d4a63
Content-Type: application/json
{
"userId": "01JD8SEGQ0P9N2XK4L7VDH3T6C",
"title": "Xeegam Cloud · 专业版",
"businessService": "cloud",
"amount": 28,
"currency": "USD",
"interval": "monthly"
}
{
"id": "01JD8SSUKP9K7MF",
"code": 0,
"messages": [],
"result": {
"subscriptionId": "01JD8SOBHV0C3D9JD",
"userId": "01JD8SEGQ0P9N2XK4L7VDH3T6C",
"title": "Xeegam Cloud · 专业版",
"businessService": "cloud",
"amount": 28,
"currency": "USD",
"interval": "monthly",
"status": "active",
"nextRenewalAt": "2026-11-13T09:00:00Z",
"createdAt": "2026-10-14T15:30:00Z"
}
}