このエンドポイントには customer 側の session-token フローもあります:サブスクリプションのキャンセル(Customer) を参照。
キャンセル動作
| 現在のステータス | アクション | 結果ステータス |
|---|---|---|
pending | 即時キャンセル | canceled |
active | 期間終了時にキャンセル(PSP 経由) | canceling -> 期間終了時に canceled |
- pending: 直接キャンセルされ、ステータスは
canceledになります - active: PSP キャンセルがトリガーされます(請求期間の終了時に有効)。ローカルステータスは
cancelingになり、期間終了時に Webhook 経由でcanceledに更新されます
リクエストボディ
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
orderId | string | Yes | サブスクリプション注文 ID(Short ID フォーマット ORD_xxx) |
リクエスト例
成功レスポンス (200) — 有効なサブスクリプション
成功レスポンス (200) — 保留中のサブスクリプション
レスポンスフィールド
| フィールド | 型 | 説明 |
|---|---|---|
orderId | string | 注文 ID(Short ID) |
status | string | 新しい注文ステータス(canceling または canceled) |
エラー
リトライポリシー:4xx は一切リトライしない — リクエストを修正してから再送信。5xx は指数バックオフでリトライ(5s 開始、最大 3 回)。
| ステータス | errors[0].message | 意味 | 推奨処理 |
|---|---|---|---|
| 400 | Missing X-Context-Merchant-Id header | API Key 認証下で merchant コンテキストが欠落 | 認証パイプラインを確認 |
| 400 | Missing required field: orderId | リクエストボディに orderId が含まれていない | リクエストボディを修正してから再送信 |
| 400 | Expected format: ORD_xxx, got "..." | orderId Short ID のデコード失敗 | orderId のフォーマットを修正してから再送信 |
| 400 | Subscription cannot be canceled, current status: X | 注文ステータスが pending または active ではない(canceled、canceling、expired など) | サブスクリプションはキャンセル不可 |
| 401 | Authentication failed | API Key 署名が無効 | 認証ヘッダーを確認 |
| 403 | Order does not belong to user | 所有権チェック失敗 | 呼び出し元が注文を所有しているか確認 |
| 404 | Order not found | 注文が存在しない | order ID を確認 |
| 500 | Internal server error | サーバ側の予期しない障害 | 指数バックオフでリトライ(5s 開始、最大 3 回) |
| 502 | Failed to cancel subscription | ローカル更新または PSP キャンセル失敗 | 指数バックオフでリトライ(5s 開始、最大 3 回) |