> ## 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.

# 更换订阅产品

> 更换当前订阅订单绑定的产品（即将推出）

更换当前活跃订阅订单所绑定的产品。

```
POST /v1/actions/subscription-order/change-product
```

**认证方式：** Session Token — 见 [Customer Endpoints](/zh/api-reference/endpoints/auth/customer-endpoints)（customer 角色）

<Warning>
  **即将推出** — 此端点尚未实现，当前调用一律返回 `501 Not Implemented`。下方请求签名为暂定版本，GA 前可能调整。在未实现期间路由处于锁定状态：调用不会引起任何订阅状态变更。
</Warning>

## 请求体

| 字段                | 类型     | 必需 | 说明                               |
| ----------------- | ------ | -- | -------------------------------- |
| `orderId`         | string | 是  | 当前订阅订单 ID（Short ID 格式 `ORD_xxx`） |
| `targetProductId` | string | 是  | 目标产品 ID（Short ID 格式 `PROD_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.changeSubscriptionProduct({
    orderId: "ORD_2aUyqjCzEIiEcYMKj7TZtw",
    targetProductId: "PROD_36ZqlJPatGOsjz7AtYqAwj",
  });
  ```

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

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

  ```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","targetProductId":"PROD_36ZqlJPatGOsjz7AtYqAwj"}' \
    "https://api.waffo.ai/v1/actions/subscription-order/change-product"
  ```
</CodeGroup>

## 当前响应 (501)

```json theme={"system"}
{
  "data": null,
  "errors": [
    {
      "message": "Not implemented",
      "layer": "order"
    }
  ]
}
```

### 响应字段（规划中）

| 字段        | 类型     | 说明                |
| --------- | ------ | ----------------- |
| `orderId` | string | 订阅订单 ID（Short ID） |
| `status`  | string | 更换产品后的订单状态        |

## 错误响应

> **重试策略**：4xx 一律不要重试 — 修正请求后重发。5xx 指数退避重试（起步 5s，最多 3 次）。

| 状态码 | `errors[0].message`                       | 含义                       | 推荐处理                        |
| --- | ----------------------------------------- | ------------------------ | --------------------------- |
| 400 | `Missing required field: orderId`         | 请求体未提供 `orderId`         | 修正请求体后重新提交                  |
| 400 | `Missing required field: targetProductId` | 请求体未提供 `targetProductId` | 修正请求体后重新提交                  |
| 400 | `Expected format: ORD_xxx, got "..."`     | `orderId` Short ID 解码失败  | 修正 `orderId` 格式后重新提交        |
| 401 | `Authentication failed`                   | Session token 无效、过期或格式错误 | 通过 Issue Session Token 重新签发 |
| 403 | `Order does not belong to user`           | 归属校验失败                   | 验证调用方拥有该订单                  |
| 404 | `Order not found`                         | 订单不存在                    | 验证 order ID                 |
| 501 | `Not implemented`                         | 端点尚未可用                   | 等待 GA — 不要重试                |
| 500 | `Internal server error`                   | 服务端意外失败                  | 指数退避重试（起步 5s，最多 3 次）        |
