Skip to main content

Purchase Subscription with Wallet

POST /api/subscription/wallet/pay

Purchases the specified subscription plan using the wallet balance. An idempotency key is required to prevent duplicate charges.

Authentication

User console endpoint. Requires a logged-in user identity (session Cookie, or Authorization: Bearer <access_token>). This token is different from the sk- key used for model calls.

Request Body​

ParameterTypeRequiredDescription
plan_idintegerRequiredSubscription plan ID, must be greater than 0
idempotency_keystringRequiredIdempotency key to prevent duplicate charges
Request Example
{
"plan_id": 1,
"idempotency_key": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}

Response Fields(200)​

Field NameTypeDescription
successbooleanWhether the request succeeded
messagestringMessage
dataobjectPurchase result (subscription details)
Related subscription payment endpoints
  • Claim a free plan: POST /api/subscription/free/pay, body { "plan_id": <integer> }
  • Renew with wallet: POST /api/subscription/wallet/renew, body { "subscription_id": <integer>, "idempotency_key": <string> }
  • Alipay top-up (belongs to the top-up module, not subscriptions): POST /api/user/alipay/pay