curl -X POST https://api.llmgenerator.com/api/v1/subscriptions/cancel \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/cancel', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
}
});
const data = await response.json();
if (data.success) {
console.log('Subscription will end on:', data.cancellationDate);
}
import requests
response = requests.post(
'https://api.llmgenerator.com/api/v1/subscriptions/cancel',
headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'}
)
data = response.json()
if data['success']:
print(f"Subscription will end on: {data['cancellationDate']}")
{
"success": true,
"message": "Subscription cancelled successfully",
"cancellationDate": "2024-02-15T00:00:00Z"
}
{
"message": "No active subscription to cancel"
}
订阅
取消订阅
在当前计费周期结束时取消用户的活跃订阅。
POST
/
subscriptions
/
cancel
curl -X POST https://api.llmgenerator.com/api/v1/subscriptions/cancel \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/cancel', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
}
});
const data = await response.json();
if (data.success) {
console.log('Subscription will end on:', data.cancellationDate);
}
import requests
response = requests.post(
'https://api.llmgenerator.com/api/v1/subscriptions/cancel',
headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'}
)
data = response.json()
if data['success']:
print(f"Subscription will end on: {data['cancellationDate']}")
{
"success": true,
"message": "Subscription cancelled successfully",
"cancellationDate": "2024-02-15T00:00:00Z"
}
{
"message": "No active subscription to cancel"
}
概述
取消用户订阅。订阅在当前计费周期结束前仍然有效,到期后不再续费。需要 JWT 访问令牌。**第三方集成:**请改用
POST /subscriptions/cancel/api 并以 API Key 鉴权。本操作安排在账期结束时取消。用户在
currentPeriodEnd 之前仍保有访问权限。如需立即终止,请使用账单门户。认证
string
必填
JWT 访问令牌。格式:
Bearer YOUR_ACCESS_TOKENcurl -X POST https://api.llmgenerator.com/api/v1/subscriptions/cancel \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/cancel', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
}
});
const data = await response.json();
if (data.success) {
console.log('Subscription will end on:', data.cancellationDate);
}
import requests
response = requests.post(
'https://api.llmgenerator.com/api/v1/subscriptions/cancel',
headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'}
)
data = response.json()
if data['success']:
print(f"Subscription will end on: {data['cancellationDate']}")
{
"success": true,
"message": "Subscription cancelled successfully",
"cancellationDate": "2024-02-15T00:00:00Z"
}
{
"message": "No active subscription to cancel"
}
响应字段
boolean
取消请求是否成功受理。
string
可读状态说明。
string
订阅将结束的 UTC 时间(ISO 8601,仅在成功时返回)。
错误响应
错误请求——无活跃订阅可取消,或无法通过 API 取消当前订阅。
未授权——令牌无效或缺失。
取消后的行为
| 场景 | 行为 |
|---|---|
| 活跃订阅 | 标记为周期结束时取消 |
| 已取消 | 返回错误 |
| 无订阅 | 返回错误 |
| 无 Stripe 订阅 ID | 返回错误(无法通过 API 取消) |
重新订阅
用户若需恢复订阅,可以:- 使用账单门户(
/subscriptions/portal) - 或在当前订阅结束后重新订阅
最佳实践
- 二次确认:取消前应弹出确认
- 收集原因:可询问取消原因以改进产品
- 挽留策略:可考虑折扣或暂停选项
- 清晰提示:明确展示权益截止日期
POST /subscriptions/cancel/api
使用 API Key 取消订阅,适合第三方集成。认证
需要 API Key:Authorization: Bearer llmgen_your_api_key_here
响应
与/subscriptions/cancel 相同。
curl -X POST https://api.llmgenerator.com/api/v1/subscriptions/cancel/api \
-H "Authorization: Bearer llmgen_your_api_key_here"
const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/cancel/api', {
method: 'POST',
headers: {
'Authorization': 'Bearer llmgen_your_api_key_here'
}
});
const data = await response.json();
if (data.success) {
console.log('Subscription will end on:', data.cancellationDate);
}
import requests
response = requests.post(
'https://api.llmgenerator.com/api/v1/subscriptions/cancel/api',
headers={'Authorization': 'Bearer llmgen_your_api_key_here'}
)
data = response.json()
if data['success']:
print(f"Subscription will end on: {data['cancellationDate']}")
此页面对您有帮助吗?
⌘I