> ## Documentation Index
> Fetch the complete documentation index at: https://docs.waffo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# サブスクリプションの再開

> 現在の期間末でキャンセル予約中のサブスクリプションを再開する

現在 `canceling` 状態のサブスクリプションを再開します。期間末でのキャンセル予約が解除され、サブスクリプションは元のスケジュール通り更新を継続します。

```
POST /v1/actions/subscription-order/reactivate-order
```

**認証：** Session Token — [Customer Endpoints](/ja/api-reference/endpoints/auth/customer-endpoints) を参照（customer または customer ロール）

## 再開動作

| 現在のステータス                                      | アクション                   | 結果ステータス  |
| --------------------------------------------- | ----------------------- | -------- |
| `canceling`                                   | 期間末でのキャンセル予約を解除（PSP 経由） | `active` |
| `canceled`                                    | 不可 — 既に完全にキャンセル済み       | —        |
| `pending` / `active` / `past_due` / `expired` | 不可 — `canceling` のみ再開可能 | —        |

<Note>
  * 再開可能なのは `canceling`（期間末のキャンセルが予約済み）状態のサブスクリプションのみ。
  * 完全にキャンセル済み（`canceled`）のサブスクリプションは再開できません — 新しいサブスクリプションを作成してください。
  * 追加課金なし — 現在の請求期間が継続し、元のスケジュールで更新が再開します。
</Note>

## リクエストボディ

| フィールド     | 型      | 必須 | 説明                                        |
| --------- | ------ | -- | ----------------------------------------- |
| `orderId` | string | 必須 | サブスクリプション注文 ID（Short ID フォーマット `ORD_xxx`） |

## リクエスト例

<CodeGroup>
  ```typescript TypeScript (SDK) theme={"system"}
  import { WaffoPancake } from "@waffo/pancake-ts";

  const client = new WaffoPancake({
    sessionToken: window.WAFFO_SESSION_TOKEN, // マーチャントのポータルから注入
    environment: "prod",
  });

  const result = await client.orders.reactivateSubscription({
    orderId: "ORD_2aUyqjCzEIiEcYMKj7TZtw",
  });

  console.log(result.orderId); // "ORD_2aUyqjCzEIiEcYMKj7TZtw"
  console.log(result.status);  // "active"
  ```

  ```typescript TypeScript (Manual) theme={"system"}
  const result = await fetch("https://api.waffo.ai/v1/actions/subscription-order/reactivate-order", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${SESSION_TOKEN}`,
      "Content-Type": "application/json",
      "X-Environment": "prod",
    },
    body: JSON.stringify({
      orderId: "ORD_2aUyqjCzEIiEcYMKj7TZtw",
    }),
  }).then(r => r.json());
  ```

  ```bash cURL theme={"system"}
  curl -X POST "https://api.waffo.ai/v1/actions/subscription-order/reactivate-order" \
    -H "Authorization: Bearer $SESSION_TOKEN" \
    -H "Content-Type: application/json" \
    -H "X-Environment: prod" \
    -d '{"orderId":"ORD_2aUyqjCzEIiEcYMKj7TZtw"}'
  ```

  ```bash wget theme={"system"}
  wget -qO- \
    --header="Authorization: Bearer $SESSION_TOKEN" \
    --header="Content-Type: application/json" \
    --header="X-Environment: prod" \
    --post-data='{"orderId":"ORD_2aUyqjCzEIiEcYMKj7TZtw"}' \
    "https://api.waffo.ai/v1/actions/subscription-order/reactivate-order"
  ```
</CodeGroup>

## 成功レスポンス (200)

```json theme={"system"}
{
  "data": {
    "orderId": "ORD_2aUyqjCzEIiEcYMKj7TZtw",
    "status": "active"
  }
}
```

### レスポンスフィールド

| フィールド     | 型      | 説明                   |
| --------- | ------ | -------------------- |
| `orderId` | string | 注文 ID（Short ID）      |
| `status`  | string | 新しい注文ステータス（`active`） |

## エラー

> **リトライポリシー**：4xx は一切リトライしない — リクエストを修正してから再送信。5xx は指数バックオフでリトライ（5s 開始、最大 3 回）。

| ステータス | `errors[0].message`                               | 意味                                                          | 推奨処理                        |
| ----- | ------------------------------------------------- | ----------------------------------------------------------- | --------------------------- |
| 400   | `Missing required field: orderId`                 | リクエストボディに `orderId` が含まれていない                                | リクエストボディを修正してから再送信          |
| 400   | `Expected format: ORD_xxx, got "..."`             | `orderId` Short ID のデコード失敗                                  | `orderId` のフォーマットを修正してから再送信 |
| 400   | `Only canceling subscriptions can be reactivated` | 注文ステータスが `canceling` ではない（`canceled`、`active`、`expired` など） | サブスクリプションは再開不可              |
| 401   | `Authentication failed`                           | Session token が無効、期限切れ、または不正な形式                             | Issue Session Token で再発行    |
| 403   | `Order does not belong to user`                   | 所有権チェック失敗                                                   | 呼び出し元が注文を所有しているか確認          |
| 404   | `Order not found`                                 | 注文が存在しない                                                    | order ID を確認                |
| 500   | `Internal server error`                           | サーバ側の予期しない障害                                                | 指数バックオフでリトライ（5s 開始、最大 3 回）  |
