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

> ## Agent Instructions
> Test in the sandbox first: base URL https://api-sandbox.y.uno (Test Mode in the Dashboard). Production is https://api.y.uno (Live Mode).
> Every API request needs the public-api-key and private-secret-key headers. Get them in the Dashboard at https://dashboard.y.uno/developers (Developers > Credentials); sandbox and production keys are different.
> Send an X-Idempotency-Key (a UUID) when creating payments, refunds and cancels, so retries do not create duplicates.
> Start with the Quickstart (https://docs.y.uno/docs/quickstart.md) and the agent guide (https://docs.y.uno/agents.md). To search these docs from a coding agent, connect the docs MCP server at https://docs.y.uno/mcp.

# 重新激活订阅

> 将已取消或已完成的订阅恢复为 ACTIVE，保留同一订阅及其历史记录。

此 endpoint 适用于客户挽回活动。调用它会将 `CANCELED` 或 `COMPLETED`
的订阅恢复为 `ACTIVE`（如果试用阶段覆盖重新激活后的周期，则恢复为 `TRIALING`），
并保留同一个 `id` 及其完整的支付历史。此调用从不创建后继订阅，
也从不设置 `previous_subscription_id`。调用本身不会产生任何收费。

> [!NOTE]
>
> **仅限已加入允许名单的组织**
>
> 重新激活功能按组织开放，并且会在检查订阅状态之前先进行此项检查。如果
> 您的调用返回 `409` `"Subscription reactivation is not enabled for this organization."`，
> 请联系您的 Yuno 代表为您启用该功能。

## 哪些订阅可以重新激活

| 当前 `status` | 结果 |
| - | - |
| `CANCELED` | 重新激活。 |
| `COMPLETED` | 如果仍有剩余计费周期，则重新激活，请参阅下文的 [计费周期用完时](#when-the-billing-cycles-are-used-up)。 |
| 其他任何状态 | `409` `INVALID_SUBSCRIPTION_STATUS`，并在 `current_status` 中注明当前状态。`PAUSED` 订阅应改用 [恢复订阅](https://docs.y.uno/zh-hans/reference/subscriptions/resume-subscription.md) 来恢复。 |

```json 409 — status is not CANCELED or COMPLETED theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "code": "INVALID_SUBSCRIPTION_STATUS",
  "messages": [
    "Only a CANCELED or COMPLETED subscription can be reactivated."
  ],
  "current_status": "ACTIVE"
}
```

`availability.finish_at` 已过的订阅，无论处于何种状态，都会被拒绝并返回 `400`
`INVALID_DATE`：

```json 400 — availability window already closed theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "code": "INVALID_DATE",
  "messages": [
    "The subscription can not be resume due to a conflict with the availability dates. Please update availability dates and try again if you want to keep using the subscription"
  ]
}
```

## 计费周期用完时

已用完 `billing_cycles.total` 中所有周期的 `COMPLETED` 订阅会被拒绝并返回 `409`
`INVALID_SUBSCRIPTION_STATUS`：

```json 409 — no billing cycles left theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "code": "INVALID_SUBSCRIPTION_STATUS",
  "messages": [
    "The subscription exhausted its 1 billing cycles. Send billing_cycles.total greater than 1 in the reactivate body."
  ],
  "current_status": "COMPLETED"
}
```

发送 `billing_cycles.total`，并使其值高于当前值，即可提高上限并
在同一调用中重新激活。这不会创建后继订阅，而是**在同一个
订阅上**提高上限，并完整保留其 `id` 和历史记录：

```json Raise the limit and reactivate theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "billing_cycles": { "total": 24 }
}
```

发送 `billing_cycles.total` 时：

| 条件 | 结果 |
| - | - |
| 不大于当前总数 | `400` `BAD_REQUEST`：`"billing_cycles.total must be greater than the current total (N)."` |
| 订阅根本没有计费周期上限 | `400` `BAD_REQUEST`：`"billing_cycles.total cannot be set on a subscription without a billing cycle limit."` |
| 不是正整数 | `400` `BAD_REQUEST`：`"billing_cycles.total must be a positive integer."` |

对于仍有剩余周期的订阅，发送 `billing_cycles.total` 也会以同样方式
被接受：它会提高上限，并不限于已用完周期的订阅。显式传入
`billing_cycles.total: null` 与省略该字段的效果相同：当前总数保持
不变。

## 选择下一个计费日期

`billing_cycle_behavior` 与恢复订阅和计划变更时使用的是同一个参数。

```json KEEP (default, or omitted) theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{ "billing_cycle_behavior": "KEEP" }

// billing_cycles.next_at -> unchanged while it is still in the future,
// otherwise rolled forward to its next future occurrence
```

```json RESTART theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{ "billing_cycle_behavior": "RESTART" }

// billing_cycles.next_at -> the reactivation instant plus the subscription's frequency
// frequency.monthly_billing_day -> stamped to the day of the reactivation,
// on a monthly subscription that had none
```

无论哪种方式，调用时都不会产生收费。无效值会返回 `400` `BAD_REQUEST`：
`"billing_cycle_behavior must be one of KEEP, RESTART."` 重新激活操作在 gateway 侧没有自己的验证：
相同的文本会经由 gateway 原样返回。

> [!NOTE]
>
> **RESTART 与月度计费日**
>
> 对于未设置 `frequency.monthly_billing_day` 的月度订阅，`RESTART` 会将该字段设为
> 重新激活当天的日期，与更新订阅和恢复订阅所应用的规则相同。
> 已声明计费日的订阅会保留该值。

## 支付方式

在重新激活订阅之前，会重新验证已存储的支付方式。如果该支付方式已
不再处于注册状态，调用会返回 `400` `PAYMENT_METHOD_STATUS_INVALID`，订阅不会
被修改：支付方式检查会在写入状态之前执行：

```json 400 — payment method no longer enrolled theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "code": "PAYMENT_METHOD_STATUS_INVALID",
  "messages": [
    "The payment method is a state that does not allow payments to be made."
  ]
}
```

## 重新激活会清除的内容

重新激活订阅会清除：

* `cancellation_time`
* `cancellation_source`
* `ending_time`
* `reason`
* 任何预定的取消（`cancel_scheduled`）
* 任何预定自动结束的暂停：重新激活后的订阅从不包含
  `pause_until`

`subscription.reactivate` webhook 只触发一次，携带重新激活后的订阅。

## 错误

| HTTP | `code` | 触发条件 |
| - | - | - |
| `409` | `INVALID_SUBSCRIPTION_STATUS` | 该组织未启用重新激活功能。 |
| `409` | `INVALID_SUBSCRIPTION_STATUS` | 订阅的状态不是 `CANCELED` 或 `COMPLETED`。 |
| `409` | `INVALID_SUBSCRIPTION_STATUS` | 订阅已用完 `billing_cycles.total` 中的所有计费周期，且请求未提高该上限。 |
| `400` | `INVALID_DATE` | `availability.finish_at` 已过。 |
| `400` | `BAD_REQUEST` | `billing_cycles.total` 不大于当前总数、发送给了没有周期上限的订阅，或不是正整数。 |
| `400` | `BAD_REQUEST` | `billing_cycle_behavior` 不是 `KEEP` 或 `RESTART`。 |
| `400` | `BAD_REQUEST` | 存在无法识别的顶层键，在调用到达引擎之前被 gateway 自身的 JSON 绑定捕获：`"Bad request"` |
| `400` | `BAD_REQUEST` | `billing_cycles` 中存在 `total` 以外的键，原样转发给引擎后在引擎处被拒绝：`"Unknown field(s): foo."` |
| `400` | `PAYMENT_METHOD_STATUS_INVALID` | 已存储的支付方式不再处于注册状态。 |
| `400` | `OPERATION_IN_PROCESS` | 针对同一订阅的另一个写入操作仍在进行中：`"Operation over the same subscription is already in process. Try again in a few seconds."` |


## OpenAPI

````yaml openapi/zh-hans/subscriptions/reactivate-subscription.json POST /subscriptions/{subscription_id}/reactivate
openapi: 3.1.0
info:
  title: subscription
  version: 1.0.2
servers:
  - url: https://api-sandbox.y.uno/v1
  - url: https://api.y.uno/v1
security:
  - sec0: []
    sec1: []
paths:
  /subscriptions/{subscription_id}/reactivate:
    post:
      summary: 重新激活订阅
      operationId: reactivate-subscription
      parameters:
        - name: subscription_id
          in: path
          description: 订阅的唯一标识符。
          schema:
            type: string
          required: true
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                billing_cycle_behavior:
                  type: string
                  enum:
                    - KEEP
                    - RESTART
                  description: >-
                    RESTART 将下一次扣款重新锚定到现在加上订阅的频率（并且对没有
                    frequency.monthly_billing_day 的按月订阅，写入该值）。KEEP
                    或省略：只要已存储的锚点仍在未来，就保持不变，否则向前推进到它的下一个未来时刻。无论哪种方式，此次调用都不会产生扣款。
                  example: RESTART
                billing_cycles:
                  type: object
                  description: 提高订阅的周期上限，使其可以被重新激活。只允许嵌套的 total。
                  properties:
                    total:
                      type: integer
                      description: >-
                        必须是大于订阅当前 billing_cycles.total
                        的正整数。对完全没有周期上限的订阅会被驳回。有效值会提高同一订阅上的上限。
                      example: 12
            examples:
              RESTART:
                value:
                  billing_cycle_behavior: RESTART
              RAISE THE BILLING CYCLES LIMIT:
                value:
                  billing_cycles:
                    total: 12
      responses:
        '200':
          description: '200'
          content:
            application/json:
              examples:
                REACTIVATE SUBSCRIPTION:
                  value:
                    id: 7304911d-5df9-429e-8488-ad41abea1a4c
                    name: SUB-111 merchant reactivate subject
                    account_id: 2404911d-5df9-429e-8488-ad41abea1a4b
                    country: CO
                    description: null
                    merchant_reference: pa-sub111-1789488115936-594232
                    status: ACTIVE
                    amount:
                      currency: COP
                      value: 45000
                    frequency:
                      type: MONTH
                      value: 1
                    billing_cycles:
                      total: 6
                      current: 2
                      paid: 0
                      next_at: '2026-10-15T16:01:56.709393Z'
                    customer_payer:
                      id: 3t04911d-5df9-429e-8488-ad41abea1a2c
                    payment_method:
                      type: CARD
                      vaulted_token: 6104911d-5df9-429e-8488-ad41abea1a4b
                      card:
                        installments: null
                        network_transaction_id: '615803391389209'
                        usage: USED
                    availability:
                      start_at: '2026-09-15T16:01:56.709393Z'
                      finish_at: null
                    retries:
                      retry_on_decline: false
                      amount: 6
                      strategy: SMART
                      schedule: null
                      stop_on_hard_decline: null
                      cancel_on_exhausted_retries: null
                    metadata: null
                    additional_data: null
                    trial_period:
                      billing_cycles: 1
                      amount:
                        value: 0
                        currency: ''
                    initial_payment_validation: false
                    reason: null
                    subscription_agreement_id: null
                    soft_descriptor: null
                    renewal_notification_days: null
                    cancellation_time: null
                    cancellation_source: null
                    ending_time: null
                    created_at: '2026-09-15T16:01:56.709393Z'
                    updated_at: '2026-09-15T16:01:58.115702Z'
                    pending_plan_change: null
                    current_period_start: '2026-09-15T16:01:56.709393Z'
                    current_period_end: '2026-10-15T16:01:56.709393Z'
              schema:
                type: object
                properties:
                  id:
                    type: string
                    example: 7304911d-5df9-429e-8488-ad41abea1a4c
                  name:
                    type: string
                    example: sub_001
                  description:
                    type: string
                    example: streaming service
                    nullable: true
                  account_id:
                    type: string
                    example: 2404911d-5df9-429e-8488-ad41abea1a4b
                  country:
                    type: string
                    description: 订阅所在国家/地区（ISO 3166-1 alpha-2）。
                    example: US
                  merchant_reference:
                    type: string
                    example: 001_marzo_23
                  soft_descriptor:
                    type: string
                    example: ACME SUBSCRIPTION
                    nullable: true
                  status:
                    type: string
                    example: ACTIVE
                  amount:
                    type: object
                    properties:
                      currency:
                        type: string
                        example: USD
                      value:
                        type: number
                        example: 12100
                        default: 0
                  frequency:
                    type: object
                    properties:
                      type:
                        type: string
                        example: MONTH
                      value:
                        type: integer
                        example: 1
                        default: 0
                      monthly_billing_day:
                        type: integer
                        nullable: true
                        description: >-
                          在 MONTH 频率的订阅上，计费所锚定的每月日期。由
                          RESTART（在更新、计划变更、恢复或重新激活时）设置，或通过发送更新订阅自己的
                          frequency.monthly_billing_day
                          设置。只有在写入之后才会出现；在此之前以及在所有其他频率类型上，该字段不存在（而不是 null）。
                        example: 15
                  billing_cycles:
                    type: object
                    properties:
                      total:
                        type: integer
                        example: 10
                        default: 0
                        nullable: true
                      current:
                        type: integer
                        example: 2
                        default: 0
                      next_at:
                        type: string
                        example: '2023-02-16T20:00:00.786342Z'
                      scheduling_date:
                        type: string
                        description: >-
                          扣款指令交给 Pix 通道的时间，即 `next_at` 减去四天。仅出现在由 Yuno 执行的
                          `PIX_AUTOMATIC` 订阅上，并且仅在该组织启用了四天预约提前期时出现；否则该字段不存在（而不是
                          `null`）。只读。请参阅 [Pix
                          Automático](/zh-hans/docs/payment-features/subscriptions/pix-automatico#the-scheduling-date)。
                        example: '2026-11-27T00:00:00Z'
                      paid:
                        type: integer
                        description: 到目前为止已支付的周期数。与 `current` 不同，`current` 是正在计费的周期。
                  current_period_start:
                    type: string
                    nullable: true
                    description: >-
                      订阅当前所处计费周期的开始时间，比 `current_period_end`
                      早一个计费间隔。在试用期或任何其他计划阶段内，它遵循该阶段的计费间隔。处于终态的订阅（`CANCELED` 或
                      `COMPLETED`）保留其最后的时间窗口，而不会变为 null。仅对没有周期性计费间隔的订阅为 Null。始终与
                      current_period_end 一起返回。
                    example: '2023-01-16T20:00:00.912480Z'
                  current_period_end:
                    type: string
                    nullable: true
                    description: >-
                      订阅当前所处计费周期的结束时间。等于 billing_cycles.next_at。始终与
                      current_period_start 一起返回。
                    example: '2023-02-16T20:00:00.786342Z'
                  billing_date:
                    type: object
                    nullable: true
                    description: 仅出现在按固定日期（而不是按频率）计费的订阅上；与 `frequency` 互斥。
                    properties:
                      type:
                        type: string
                        example: DAY
                      day:
                        type: integer
                        example: 2
                  customer_payer:
                    type: object
                    properties:
                      id:
                        type: string
                        example: 3t04911d-5df9-429e-8488-ad41abea1a2c
                  payment_method:
                    type: object
                    properties:
                      type:
                        type: string
                        example: CARD
                      vaulted_token:
                        type: string
                        example: 6104911d-5df9-429e-8488-ad41abea1a4b
                      card:
                        type: object
                        properties:
                          installments:
                            type: integer
                            nullable: true
                          network_transaction_id:
                            type: string
                            nullable: true
                          usage:
                            type: string
                            example: FIRST
                        nullable: true
                  availability:
                    type: object
                    properties:
                      start_at:
                        type: string
                        example: '2024-01-16T00:00:00.786342Z'
                      finish_at:
                        type: string
                        example: '2024-05-26T20:00:00.786342Z'
                        nullable: true
                  retries:
                    type: object
                    nullable: true
                    description: >-
                      定期扣款被拒绝时所采用的重试策略。请参阅[重试](/zh-hans/docs/payment-features/subscriptions/retries)。
                    properties:
                      retry_on_decline:
                        type: boolean
                        description: 被拒绝的扣款是否会重试。
                        example: true
                      amount:
                        type: integer
                        description: 一个计费周期可以重试的次数。上限为您所在环境的重试计划长度（生产环境为 6）。
                        example: 4
                      strategy:
                        type: string
                        description: >-
                          每次重试的时间如何确定：`DEFAULT`、`SMART` 或
                          `CUSTOM_SCHEDULE`。请将其视为开放式字段，并妥善处理无法识别的值。
                        example: DEFAULT
                      schedule:
                        type: array
                        nullable: true
                        description: >-
                          每次尝试的计划，仅当 `strategy` 为 `CUSTOM_SCHEDULE` 时设置；否则为
                          `null`。
                        items:
                          type: object
                      stop_on_hard_decline:
                        type: boolean
                        nullable: true
                        description: 为 true 时，硬拒绝会停止当前计费周期的重试。
                      cancel_on_exhausted_retries:
                        type: boolean
                        nullable: true
                        description: >-
                          为 true 时，一个周期的重试结束后仍没有支付成功，订阅就会被取消，同时
                          `cancellation_source` 设置为 `RETRIES_EXHAUSTED`。
                      profile:
                        type: string
                        description: >-
                          订阅遵循的固定重试阶梯，用来替代可配置的计划。始终为
                          `PIX_AUTOMATIC`。该字段和下面三个字段仅出现在由 Yuno 执行的
                          `PIX_AUTOMATIC` 订阅上；在所有其他支付方式上，它们不存在（而不是 `null`）。请参阅
                          [Pix
                          Automático](/zh-hans/docs/payment-features/subscriptions/pix-automatico#the-retry-ladder)。
                        example: PIX_AUTOMATIC
                      max_attempts:
                        type: integer
                        description: Pix 阶梯执行的重试次数。始终为 3，与这些订阅所报告的 `amount` 一致。
                        example: 3
                      min_gap_hours:
                        type: integer
                        description: >-
                          始终为
                          24，即阶梯各扣款日期（`D`、`D+1`、`D+2`、`D+3`）之间的间隔，而不是各发出尝试之间的间隔。
                        example: 24
                      until:
                        type: string
                        description: >-
                          阶梯停止的时间，即 `billing_cycles.next_at` 加 7 天。每次续订时随
                          `next_at` 一起变动。
                      stopped:
                        type: boolean
                        description: 仅当订阅处于 PAST_DUE 状态或有待处理的 cancel_scheduled 时出现。
                      attempts_made:
                        type: integer
                        description: 仅当订阅处于 PAST_DUE 状态或有待处理的 cancel_scheduled 时出现。
                      outcome:
                        type: string
                        description: >-
                          RECOVERED、EXHAUSTED 或 ABANDONED。仅当订阅处于 PAST_DUE
                          状态或有待处理的 cancel_scheduled 时出现。
                      next_retry_at:
                        type: string
                        description: 仅当订阅处于 PAST_DUE 状态或有待处理的 cancel_scheduled 时出现。
                  trial_period:
                    type: object
                    properties:
                      billing_cycles:
                        type: integer
                        example: 1
                        default: 0
                      amount:
                        type: object
                        properties:
                          value:
                            type: number
                            example: 0
                            default: 0
                          currency:
                            type: string
                            example: ''
                  metadata:
                    type: array
                    items:
                      type: object
                      properties:
                        key:
                          type: string
                          example: sub_ext_id
                        value:
                          type: string
                          example: AA001
                    nullable: true
                  additional_data:
                    type: object
                    nullable: true
                    description: >-
                      创建时发送的可选订单补充数据，原样回显。完整结构请参阅[订阅对象](/zh-hans/reference/subscriptions/the-subscription-object)。
                  initial_payment_validation:
                    type: boolean
                    description: 订阅是否等待首次支付成功后才激活。默认为 `false`。
                    example: false
                  reason:
                    type: string
                    nullable: true
                    description: 订阅当前状态的自由格式原因（如果有记录）；否则为 `null`。
                    example: merchant request
                  renewal_notification_days:
                    type: integer
                    nullable: true
                    description: >-
                      在下一个计费日期之前多少天发送 `subscription.close_to_renewal`
                      webhook。`null` 表示不发送续订通知。
                    example: 3
                  payments:
                    type: array
                    items:
                      type: string
                      example: 5104911d-5df9-229e-8468-bd41abea1a4s
                  subscription_agreement_id:
                    type: string
                    example: sa_6af2dfcd-44c0-4f16-a331-8bed3ed9c9fa
                    nullable: true
                  cancellation_time:
                    type: string
                    nullable: true
                    description: 订阅被取消的时间。仅在订阅达到 `CANCELED` 后设置；否则为 `null`。
                    example: '2023-12-16T20:46:54.786342Z'
                  cancellation_source:
                    type: string
                    nullable: true
                    description: >-
                      触发取消的原因：`MERCHANT`、`SYSTEM`、`PLAN_CHANGE` 或
                      `RETRIES_EXHAUSTED`。仅在订阅达到 `CANCELED` 后设置；否则为
                      `null`。请将其视为开放式字段，并妥善处理无法识别的值。
                    example: MERCHANT
                  ending_time:
                    type: string
                    nullable: true
                    description: 订阅完成或过期的时间。仅在订阅达到 `COMPLETED` 后设置；否则为 `null`。
                    example: '2024-12-16T20:46:54.786342Z'
                  plan_id:
                    type: string
                    description: 仅当订阅关联了计划时出现。
                    example: 00000000-0000-4000-8000-000000000001
                  plan_assigned_at:
                    type: string
                    description: 仅出现在关联了计划的订阅上。计划被附加的时间，即从计划创建订阅时、迁移到计划时或计划变更时。
                    example: '2023-12-16T20:46:54.786342Z'
                  previous_subscription_id:
                    type: string
                    description: 仅当该订阅由计划变更（将现有订阅切换到另一个计划）创建时出现。
                    nullable: true
                  phases:
                    type: array
                    description: >-
                      所关联计划的阶段定义，与计划声明的一致，包括终止的 `REGULAR`
                      阶段。仅出现在其计划包含阶段的、关联了计划的订阅上。这是计划自己的阶梯，而不是该订阅者的快照：要查看创建时为该订阅固定下来的内容，请使用
                      `billing_phases`。
                    items:
                      type: object
                      properties:
                        order:
                          type: integer
                        name:
                          type: string
                        type:
                          type: string
                          description: '`TRIAL` 或 `REGULAR`。'
                        duration:
                          type: object
                          nullable: true
                          description: 阶段持续多长时间。在终止的 `REGULAR` 阶段上为 `null`，该阶段一直持续到订阅结束。
                          properties:
                            type:
                              type: string
                            value:
                              type: integer
                        frequency:
                          type: object
                          nullable: true
                          description: 阶段的计费频率。在终止的 `REGULAR` 阶段上为 `null`，该阶段按计划自身的频率计费。
                          properties:
                            type:
                              type: string
                            value:
                              type: integer
                        amount:
                          type: object
                          nullable: true
                          description: 阶段价格。在终止的 `REGULAR` 阶段上为 `null`，其价格在每次计费时由计划确定。
                          properties:
                            currency:
                              type: string
                            value:
                              type: number
                        total_payments:
                          type: integer
                          nullable: true
                        country_prices:
                          type: array
                          description: 按国家/地区覆盖的阶段价格，阶段没有覆盖时为空。
                          items:
                            type: object
                            properties:
                              country:
                                type: string
                              amount:
                                type: object
                                properties:
                                  currency:
                                    type: string
                                  value:
                                    type: number
                  current_phase:
                    type: string
                    description: 仅出现在关联了计划的订阅上。
                    example: REGULAR
                  current_phase_end:
                    type: string
                    nullable: true
                    description: >-
                      由 `current_phase`
                      指定的阶段移交给下一个阶段的时间，对于处于试用期的订阅，即切换到常规价格的时间。它是该阶段所涵盖的最后一个计费周期的结束时间，因此在试用期的最后一个周期，它等于
                      `current_period_end`。对于没有计划的订阅以及已离开阶段阶梯的订阅，为 Null。
                    example: '2023-03-16T20:00:00.786342Z'
                  billing_phases:
                    type: array
                    description: >-
                      仅出现在其计划包含阶段的、关联了计划的订阅上。只包含前面的 TRIAL 阶段，在创建时生成快照；终止的
                      REGULAR 阶段从不包含在内，因为它的价格没有被固定，而是在每次计费时由计划确定。`current_phase:
                      "REGULAR"` 表示阶梯已经用完。
                    items:
                      type: object
                      properties:
                        order:
                          type: integer
                        type:
                          type: string
                          description: 始终为 TRIAL，终止的 REGULAR 阶段从不出现在该数组中。
                        name:
                          type: string
                        amount:
                          type: object
                          properties:
                            currency:
                              type: string
                            value:
                              type: number
                        frequency:
                          type: object
                          properties:
                            type:
                              type: string
                            value:
                              type: integer
                        start_cycle:
                          type: integer
                        end_cycle:
                          type: integer
                  pending_plan_change:
                    type: object
                    nullable: true
                    description: >-
                      计划在下一个计费周期生效的变更，没有待处理的变更时为 null。使用更新订阅上的 `plan_change`
                      块可以预定一个变更。
                    properties:
                      plan_id:
                        type: string
                        description: 目标计划的标识符。
                        example: 1904911d-5df9-429e-8488-ad41abea1a4d
                      plan_name:
                        type: string
                        description: 目标计划的名称。
                        example: Pro
                      direction:
                        type: string
                        enum:
                          - UPGRADE
                          - DOWNGRADE
                        description: 目标计划是升级还是降级。仅供参考。
                        example: UPGRADE
                      effective:
                        type: string
                        enum:
                          - NEXT_BILLING_CYCLE
                        description: 变更生效的时间。
                        example: NEXT_BILLING_CYCLE
                      phases_behavior:
                        type: string
                        enum:
                          - START_FROM_REGULAR
                          - HONOR_PHASES
                        description: 目标计划包含阶段时会发生什么。
                        example: START_FROM_REGULAR
                      applies_at:
                        type: string
                        description: 变更将在其上生效的计费事件，即订阅的下一个计费日期。
                        example: '2023-02-16T20:00:00.786342Z'
                      requested_at:
                        type: string
                        description: 变更被预定的时间。
                        example: '2023-01-20T10:12:31.786342Z'
                  created_at:
                    type: string
                    example: '2023-12-16T20:46:54.786342Z'
                  updated_at:
                    type: string
                    example: '2023-12-16T21:00:54.786342Z'
                  refund_rule:
                    type: object
                    description: >-
                      已存储的退款规则，当取消请求没有自带 refund_amount 时，用它来确定 CUSTOM
                      取消的退款。仅在配置了规则时出现；否则该字段被省略（而不是 null）。适用于已启用该功能的组织；请联系 Yuno。
                    properties:
                      type:
                        type: string
                        enum:
                          - PERCENT
                          - FIXED
                        description: PERCENT 将退款确定为已扣款金额的百分比；FIXED 将其确定为固定金额。
                        example: FIXED
                      percent:
                        type: number
                        description: 当 type 为 PERCENT 时必填，且仅在此时允许（0-100）。
                        example: 50
                      amount:
                        type: object
                        description: 当 type 为 FIXED 时必填，且仅在此时允许。
                        properties:
                          value:
                            type: number
                            example: 10000
                          currency:
                            type: string
                            description: 必须与订阅自身的币种一致。
                            example: COP
                  pause_until:
                    type: string
                    description: >-
                      订阅预定自动恢复的时间。仅出现在当前带有时长（暂停时发送了 pause_cycles 或
                      pause_until）而处于暂停状态的订阅上；在所有其他读取中，该字段不存在（而不是 null）。
                    example: '2026-10-15T15:54:22.780166Z'
                  cancel_scheduled:
                    type:
                      - object
                      - 'null'
                    description: 没有待处理的取消时为 null。
                    properties:
                      mode:
                        type: string
                        example: AFTER_CYCLES
                      after_cycles:
                        type: integer
                        example: 3
                      at:
                        type: string
                      requested_at:
                        type: string
                      past_due_behavior:
                        type: string
                        example: EXHAUST_RETRIES
                  refund:
                    type:
                      - object
                      - 'null'
                    description: 当 refund 为 NONE 或被省略时为 null。出现在取消响应中，计算完成后的每次后续读取中也会出现。
                    properties:
                      mode:
                        type: string
                        example: PRORATED
                      amount:
                        type: object
                        properties:
                          currency:
                            type: string
                            example: USD
                          value:
                            type: number
                            example: 20
                      unused_days:
                        type: integer
                        example: 20
                      period_days:
                        type: integer
                        example: 30
                      basis:
                        type: object
                        properties:
                          billing_cycle:
                            type: integer
                            example: 4
                          charged_amount:
                            type: object
                            properties:
                              currency:
                                type: string
                                example: USD
                              value:
                                type: number
                                example: 30
                          payment_id:
                            type: string
                            description: 对于没有已捕获支付的 $0 阶段报价，为 null。
                          charged_at:
                            type: string
                            description: 对于没有已捕获支付的 $0 阶段报价，为 null。
                      execution:
                        type: string
                        example: MERCHANT
                      quoted_at:
                        type: string
                  unpaid_cycle:
                    type: object
                    description: 仅当当前计费周期处于 PAST_DUE 状态且尚未结清时出现。
                    properties:
                      cycle_number:
                        type: integer
                      amount:
                        type: object
                        properties:
                          currency:
                            type: string
                          value:
                            type: number
                      attempts:
                        type: integer
                      last_failure_code:
                        type: string
        '400':
          description: '400'
          content:
            application/json:
              examples:
                INVALID_DATE:
                  value:
                    code: INVALID_DATE
                    messages:
                      - >-
                        The subscription can not be resume due to a conflict
                        with the availability dates. Please update availability
                        dates and try again if you want to keep using the
                        subscription
                  summary: >-
                    availability.finish_at is in the past. Sourced from
                    checks/YunoHttpErrorCode-v1.45.0.kt (the enum's default
                    text, which says "resume" verbatim) — not exercised by a
                    live capture.
                billing_cycles.total BELOW THE CURRENT TOTAL:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - >-
                        billing_cycles.total must be greater than the current
                        total (12).
                billing_cycles.total WITHOUT A CYCLE LIMIT:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - >-
                        billing_cycles.total cannot be set on a subscription
                        without a billing cycle limit.
                INVALID BILLING CYCLE BEHAVIOR:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - billing_cycle_behavior must be one of KEEP, RESTART.
                  summary: >-
                    Identical through the gateway — reactivate has no
                    gateway-side validation of its own.
                PAYMENT METHOD NO LONGER ENROLLED:
                  value:
                    code: PAYMENT_METHOD_STATUS_INVALID
                    messages:
                      - >-
                        The payment method is a state that does not allow
                        payments to be made.
                  summary: >-
                    Sourced from checks/YunoHttpErrorCode-v1.45.0.kt — not
                    exercised by a live capture.
                UNKNOWN TOP-LEVEL KEY:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - Bad request
                  summary: >-
                    An unrecognized top-level key is caught by the gateway's own
                    JSON binding (DisallowUnknownFields) before the call reaches
                    the engine. The engine's own guard says "Unknown field(s):
                    foo." instead — see UNKNOWN KEY INSIDE billing_cycles below.
                UNKNOWN KEY INSIDE billing_cycles:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - 'Unknown field(s): foo.'
                  summary: >-
                    billing_cycles is a field the gateway forwards raw, so a key
                    nested inside it reaches the engine unfiltered and is
                    refused by the engine's own unknown-key guard.
        '409':
          description: '409'
          content:
            application/json:
              examples:
                NOT ENABLED FOR THIS ORGANIZATION:
                  value:
                    code: INVALID_SUBSCRIPTION_STATUS
                    messages:
                      - >-
                        Subscription reactivation is not enabled for this
                        organization.
                  summary: >-
                    Sourced from
                    checks/SubscriptionService-v1.45.0-pause-resume-reactivate-cancel.kt
                    — the stg allow-list is `.*`, so this could not be captured
                    live.
                NOT TERMINAL:
                  value:
                    code: INVALID_SUBSCRIPTION_STATUS
                    messages:
                      - >-
                        Only a CANCELED or COMPLETED subscription can be
                        reactivated.
                    current_status: ACTIVE
                BILLING CYCLES EXHAUSTED:
                  value:
                    code: INVALID_SUBSCRIPTION_STATUS
                    messages:
                      - >-
                        The subscription exhausted its 1 billing cycles. Send
                        billing_cycles.total greater than 1 in the reactivate
                        body.
                    current_status: COMPLETED
                  summary: >-
                    Engine-only capture (row 756) — no merchant capture reaches
                    an exhausted subscription in this run; the body shape is
                    identical to the merchant NOT TERMINAL case.
      deprecated: false
components:
  securitySchemes:
    sec0:
      type: apiKey
      in: header
      name: public-api-key
      x-default: <Your public-api-key>
    sec1:
      type: apiKey
      in: header
      name: private-secret-key
      x-default: <Your private-secret-key>

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.