---
title: "获取 API 额度包付款链接 / Get a checkout link for an API credit pack"
method: POST
path: "/api/billing/api-pack/checkout"
tags: ["Billing"]
---

# 获取 API 额度包付款链接 / Get a checkout link for an API credit pack

`POST /api/billing/api-pack/checkout`

## Request

- Base URL: `https://api.musicsforyou.com`
- URL: `https://api.musicsforyou.com/api/billing/api-pack/checkout`
- Auth: one of:
  - HTTP bearer
  - OAuth 2 (authorization code, authorization URL `https://www.musicsforyou.com/oauth/authorize`, token URL `https://api.musicsforyou.com/oauth/token`, scopes: `music`)

余额不足时调用：返回一个 Stripe 付款页链接，用户在浏览器付款后额度自动到账（通常 1 分钟内）。packId：api-10-usd（US$9.9 / 10 次）、api-50-usd（US$39 / 50 次）、api-100（¥300 / 100 次）。

Call when credits run out. Returns a Stripe Checkout URL; after the user pays in a browser the credits are added automatically (usually within a minute).

## Request body

- object
  - `packId` 'api-10-usd' | 'api-50-usd' | 'api-100', required

## Response `200`

付款链接 / Checkout link

- object
  - `success` boolean
  - `url` string, uri
  - `orderId` string
  - `packId` string
  - `credits` integer
  - `amount` integer: 最小货币单位（分 / 美分）
  - `currency` 'cny' | 'usd'

## Other responses

- `400`: 参数不合法 / Invalid parameters（code: INVALID_PARAMS 或 SPEC_INVALID，details 为 diagnostics）
- `401`: 未登录或 Key 无效 / Not authenticated（LOGIN_REQUIRED、INVALID_API_KEY）

---

[API](https://skmtc.dev/musicsforyou/apis/taoyuan-music-api.md) · [All operations](https://skmtc.dev/musicsforyou/apis/taoyuan-music-api/llms.txt) · [OpenAPI document](https://skmtc.dev/musicsforyou/apis/taoyuan-music-api/revisions/65b8919a4d82?raw)
