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

# 更新订阅

> 更新订阅的字段，包括追溯添加存储凭证的使用数据。

> [!WARNING]
>
> **订阅状态转换**
>
> `billing_cycles` 和 `availability.finish_at` 字段会相互影响。如果在创建订阅时同时填写了这两个字段，订阅将在到达这两个字段所定义的最近事件时转换为 `COMPLETED` 状态，无论该事件是计费周期还是相应的 `finish_at`。它们是相互独立的结束条件：先达到哪一个，订阅就在哪一个时完成。
>
> 包含 `availability` 对象时，`finish_at` 会按发送的值应用：省略它或将其作为 `null` 发送，之前设置的结束日期都会被移除，因此订阅将变为没有结束时间，并持续续订直到被取消。这意味着当您更新 `availability.start_at` 时，如果想保留结束日期，必须在同一请求中包含 `finish_at`。`start_at` 的行为不同：省略它会保持当前的开始日期不变。省略整个 `availability` 对象则会保持这两个日期都不变。
>
> 请注意，更新时 `availability.start_at` 只能提前。发送更晚的日期会返回 400 错误：`The availability start date cannot be greater than the current availability start date`。

> [!NOTE]
>
> **追溯更新凭证**
>
> 如果您已有的订阅因缺少凭证使用信息（例如来自初始 CIT 支付）而导致重复扣款失败，您可以使用此 `PATCH` endpoint 追溯设置 `payment_method.card.usage` 来解决该问题。

> [!NOTE]
>
> **预定的计划变更**
>
> 使用 `plan_change` 块将订阅转移到另一个计划，并在其下一个计费周期生效：不按比例计费，也不在周期中途收费。订阅必须处于 `ACTIVE` 或 `TRIALING` 状态，并且已关联某个计划；目标计划必须处于有效状态，并且同一时间只能有一个待处理的变更。发送 `"plan_change": null` 可撤销待处理的变更；省略该字段则不会对其产生任何影响。待处理的变更会以 `pending_plan_change` 的形式在此 endpoint 和订阅对象中返回，`subscription.plan_change_scheduled`、`subscription.plan_change_canceled` 和 `subscription.plan_changed` webhooks 会跟踪其生命周期。
>
> `amount`、`frequency`、`billing_date` 和 `country` 由计划管理，对于关联计划的订阅不能发送这些字段：将其中任何一个与 `plan_change` 一起发送都会返回 `400`。

> [!NOTE]
>
> **立即生效的计划变更**
>
> 在 `plan_change` 中发送 `"effective": "IMMEDIATE"`，即可在本次调用中直接应用变更，而不是安排在之后生效：订阅保留其 `id`，新计划的价格从下一次收费开始计费，并且与预定的变更不同，即使在最后一个计费周期中也可以使用。如果在另一个变更待处理时进行立即变更，将返回 `409 PLAN_CHANGE_ALREADY_SCHEDULED`；请先使用 `"plan_change": null` 撤销待处理的变更。
>
> `billing_cycle_behavior` 决定计划原地变更时计费锚点如何处理：
>
> * `KEEP`（默认值，省略该字段的效果相同）：下一次收费日期保持不变；只有价格会变化。
> * `RESTART`：下一次收费重新锚定到变更时刻加上新计划的频率。**只有锚点会重置**：计费周期计数器、重试配置和订阅的状态都会保留。`RESTART` 要求 `effective: IMMEDIATE`，与预定的变更一起使用时会返回 `400`；`KEEP` 与预定的变更一起使用时会被接受，并像往常一样安排变更，因为预定的变更本来就不会移动锚点。
>
> 立即变更会在调用时发出 `subscription.plan_changed` webhook；`subscription.plan_change_scheduled` 不会因此触发，并且 `pending_plan_change` 始终保持为 `null`。
>
> `billing_cycle_behavior` 为 **只写** 字段：它在请求中被接受，但从不会在任何响应中返回。
>
> 对于创建时未显式设置 `frequency.monthly_billing_day` 的月度订阅，`RESTART` 会将该字段设为重新开始当天的日期，之后的每次续订都会读取该值：在 15 日重新开始，则此后每月都在 15 日计费，而不仅仅是下一个周期。已声明计费日的订阅会保留该值：日期不会移动到重新开始的那一天，只会重新锚定一天中的时间。该值会在订阅对象中返回，因此可以在变更后读取。同样的规则也适用于 [恢复订阅](https://docs.y.uno/zh-hans/reference/subscriptions/resume-subscription.md#keep-and-restart-compared) 中的 `RESTART`：两个 endpoint 遵循同一条规则。

> [!NOTE]
>
> **在没有计划的情况下重新开始计费周期**
>
> 对于 *未* 关联计划的订阅，`billing_cycle_behavior` 可作为此 endpoint 的顶层字段使用，通常与同一调用中的 `frequency` 变更结合使用，例如将订阅者从按月计费改为按年计费，并从今天起重新开始周期。`KEEP`/`RESTART` 的语义相同；对于尚未开始的订阅，重新锚定的日期会被限制为不早于其 `availability.start_at`。
>
> 放置规则：对于关联计划的订阅，顶层字段会返回 `400`（锚点通过 `plan_change` 管理）；将顶层字段与 `plan_change` 块一起发送也会返回 `400`，请改用 `plan_change.billing_cycle_behavior`。`PAUSED` 状态的订阅会返回 `409 INVALID_SUBSCRIPTION_STATUS`：订阅处于 `ACTIVE`、`TRIALING` 或 `PAST_DUE` 状态时，或仍处于 `CREATED` 状态时，可以接受重新开始；在该状态下（与 `plan_change` 不同）该请求是允许的，重新锚定的日期会被限制为不早于 `availability.start_at`。顶层的重新开始不会发出任何 webhook：请从订阅对象中读取新的锚点。

> [!NOTE]
>
> **订阅促销**
>
> 发送带有 `id` 或 `code` 的 `promotion`，即可应用附加到该订阅计划的促销。订阅必须处于 `ACTIVE` 或 `TRIALING` 状态。折扣从下一次收费开始生效。响应中包含 `promotion` 对象。在另一个促销有效时应用新促销会替换原促销：当前促销结束，`end_reason` 为 `REPLACED`，新促销从已使用 0 个周期开始。
>
> ```json theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> { "promotion": { "code": "WELCOME50" } }
> ```
>
> 如需移除当前有效的促销，请使用 [从订阅中移除促销](https://docs.y.uno/zh-hans/reference/subscriptions/remove-subscription-promotion.md)。
>
> 发送 `promotion` 的请求不能再发送任何其他内容。如果与 `plan_change` 一起发送，将返回 `400 INVALID_PARAMETERS`，消息为 `A promotion and a plan change cannot be sent in the same update, so send them in two requests.`。如果与任何其他字段（例如 `name` 或 `metadata`）一起发送，将返回 `400 BAD_REQUEST`，消息为 `a promotion must be sent alone; send the other changes in a separate request`。在这两种情况下都不会做任何更改。请在不同的请求中分别发送这些字段。

> [!NOTE]
>
> **计划变更时的促销**
>
> `plan_change` 中有两个可选字段，用于决定当前有效的促销如何处理：
>
> * `promotion_behavior`：`KEEP`（默认值）在新计划中保留该促销及其剩余周期。`END` 结束该促销，`end_reason` 为 `PLAN_CHANGE`。如果没有有效的促销，则忽略该字段。
> * `apply_new_plan_promotion`：`true`（默认值）应用新计划的 `AUTOMATIC` 促销（如果有），并以 `PLAN_CHANGE` 结束当前促销。`false` 不应用新计划的促销，当前促销如何处理由 `promotion_behavior` 决定。
>
> 请参阅 [计划变更](https://docs.y.uno/zh-hans/docs/payment-features/subscriptions/promotions.md#plan-changes)，了解每种生效时机下的结果。

### 计划变更错误

下面每个 `409` 和 `422` 错误除 `code` 和 `messages` 外，还会携带一个 `current_status` 字段，表示请求被驳回时订阅所处的状态。被驳回的请求不会做任何更改。

```json 409 Conflict theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "code": "PLAN_CHANGE_ALREADY_SCHEDULED",
  "messages": [
    "A plan change is already scheduled for this subscription. Undo it first with plan_change: null."
  ],
  "current_status": "ACTIVE"
}
```

| HTTP | `code` | 触发条件 |
| - | - | - |
| `404` | `PLAN_NOT_FOUND` | 目标计划不存在，或未关联到此账户。 |
| `409` | `PLAN_CHANGE_ALREADY_SCHEDULED` | 已有一个待处理的变更。请先使用 `plan_change: null` 撤销该变更。 |
| `409` | `PLAN_CHANGE_ALREADY_APPLIED` | `plan_change: null` 撤销请求到达时，待处理的变更已在续订时生效。 |
| `409` | `TARGET_PLAN_NOT_ACTIVE` | 目标计划未处于有效状态。 |
| `409` | `SUBSCRIPTION_NOT_ON_A_PLAN` | 该订阅未关联任何计划。 |
| `409` | `PLAN_CHANGE_NOT_AVAILABLE` | 订阅处于最后一个计费周期，或其可用时间窗口在下一次续订之前结束。 |
| `409` | `INVALID_SUBSCRIPTION_STATUS` | 订阅处于 `PAUSED`、`CREATED` 或 `ERROR` 状态。 |
| `422` | `SAME_PLAN` | 订阅已在此计划上。 |

`CANCELED` 或 `COMPLETED` 状态的订阅会更早被驳回，返回 `400 INVALID_STATE`，且不携带 `current_status`。

块本身的校验问题（缺少 `plan_id`、不支持的 `effective`、目标计划使用其他币种，或 `HONOR_PHASES` 阶梯长于剩余的计费周期）会返回 `400 BAD_REQUEST`，且不携带 `current_status`。`billing_cycle_behavior` 的放置错误同样如此：没有 `effective: IMMEDIATE` 的 `RESTART`、与 `plan_change` 一起发送的顶层字段，或关联计划的订阅上的顶层字段，都会返回 `400 BAD_REQUEST`，并附带说明修正方法的消息。无效的 `billing_cycle_behavior` **值** 在何处被拦截取决于其位置：顶层字段在 API 边缘被驳回，返回 `400 INVALID_PARAMETERS`（`"The field 'billing_cycle_behavior' has an invalid value."`），而嵌套在 `plan_change` 中的错误值会到达引擎，并返回 `400 BAD_REQUEST`（例如 `"RESET is invalid for plan_change.billing_cycle_behavior field"`）；请将这两种代码都视为校验失败。

上述计划变更错误表有一个例外：`PLAN_CHANGE_NOT_AVAILABLE` 仅适用于 *预定的* 变更。`IMMEDIATE` 变更不需要即将到来的周期，因此在最后一个计费周期中也会被接受。

## 设置退款规则

`refund_rule` 用于配置当之后的取消请求未携带自己的 `refund_amount` 时，如何确定 `CUSTOM` 退款的金额。它可以在此处或创建时设置，发送 `"refund_rule": null` 可将其清除。

```json A share of the charged amount theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{ "refund_rule": { "type": "PERCENT", "percent": 50 } }
```

```json A flat amount theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{ "refund_rule": { "type": "FIXED", "amount": { "value": 10000, "currency": "COP" } } }
```

```json Clear the rule theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{ "refund_rule": null }
```

`PERCENT` 和 `FIXED` 互斥：同时携带 `percent` 和 `amount` 的规则会被驳回，未携带其自身 `type` 所需字段的规则也会被驳回。`FIXED` 规则的 `amount.currency` 必须与订阅自身的币种相同；发送不匹配的币种会返回 `400` `REFUND_RULE_CURRENCY_MISMATCH`：`"refund_rule.amount.currency USD must match the subscription currency COP."`（币种随请求而变化）。

当更新更改了订阅自身的 `amount.currency`，而仍存储着旧币种的 `FIXED` 规则，且同一请求中未涉及 `refund_rule` 时，同样会进行此检查，返回 `400` `REFUND_RULE_CURRENCY_MISMATCH`：`"stored refund rule is FIXED in COP; send refund_rule in USD or refund_rule: null in the same request."`（消息中会列出所涉及的币种）。请在更改 `amount.currency` 的同一请求中，以新币种重新发送该规则，或将其清除。

清除之后，响应中的订阅对象会省略 `refund_rule`，而不会将其作为 `null` 返回。

请参阅 [取消订阅](https://docs.y.uno/zh-hans/reference/subscriptions/cancel-subscription.md#custom) 了解该规则的使用方式，并参阅 [订阅对象](https://docs.y.uno/zh-hans/reference/subscriptions/the-subscription-object.md) 了解字段参考。仅适用于已启用该功能的组织；请联系 Yuno。对于未启用的组织，发送 `refund_rule`（包括 `null`）会被静默忽略，不会做任何更改。


## OpenAPI

````yaml openapi/zh-hans/subscriptions/update-subscription.json PATCH /subscriptions/{subscription_id}
openapi: 3.1.0
info:
  title: subscription
  version: 1.0.2
servers:
  - url: https://api-sandbox.y.uno/v1
    description: Sandbox
  - url: https://api.y.uno/v1
    description: Production (US)
security:
  - sec0: []
    sec1: []
paths:
  /subscriptions/{subscription_id}:
    patch:
      summary: 更新订阅
      operationId: update-subscription
      parameters:
        - name: subscription_id
          in: path
          description: 订阅的唯一标识符。
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: 订阅计划名称（MAX 255；MIN 3）。
                description:
                  type: string
                  description: 订阅计划描述（MAX 255；MIN 3）。
                account_id:
                  type: string
                  description: 可以使用该订阅计划的账户的唯一标识符（MAX 64 ; MIN 36）。
                merchant_reference:
                  type: string
                  description: 订阅计划的标识（MAX 255；MIN 3）。
                soft_descriptor:
                  type: string
                  maxLength: 255
                  description: >-
                    显示在持卡人银行对账单上的账单描述符。更新它会改变订阅引擎之后生成的续订支付所应用的描述符。长度和格式限制因服务提供商而异（例如，Unlimit
                    截断为 22 个字符，Airwallex 截断为 30 个字符）。Worldpay 不读取该字段，而是根据
                    `payment_description` 生成账单说明。
                country:
                  type: string
                  description: 订阅所在国家/地区。
                amount:
                  type: object
                  description: 指定 `amount` 对象，包含每次订阅支付的金额和所使用的币种。
                  required:
                    - currency
                    - value
                  properties:
                    currency:
                      type: string
                      description: >-
                        支付所使用的币种（MAX 3；MIN 3；[ISO
                        4217](/zh-hans/reference/country-reference)）。
                    value:
                      type: number
                      description: 订阅每次支付的金额（0.0001 的倍数）。
                      format: float
                frequency:
                  type: object
                  description: 指定 `frequency` 对象。定义订阅的计费频率，包括类型和值。
                  required:
                    - type
                  properties:
                    type:
                      type: string
                      description: 订阅在时间上的间隔类型（DAY、WEEK、MONTH）。如果未设置，默认始终为 MONTH。
                      enum:
                        - DAY
                        - WEEK
                        - MONTH
                    value:
                      type: integer
                      description: 订阅每个间隔之间的值。如果未设置，系统将使用默认值 1。
                      format: int32
                    monthly_billing_day:
                      type: integer
                      description: >-
                        处理计费的每月日期。（MAX 31；MIN 1）。仅适用于 MONTH
                        频率。如果订阅尚未开始（availability.start_at 在未来），首次计费仍发生在
                        availability.start_at，计费日从第二个周期起生效；由此产生的第一个计费周期可能短于完整周期，并且按全额扣款。
                billing_cycles:
                  type: object
                  description: 指定 `billing_cycles` 对象。定义与订阅关联的扣款次数。
                  properties:
                    total:
                      type: integer
                      description: >-
                        订阅的计费周期总数（MIN 1）。更新时，它还必须大于或等于当前的
                        `billing_cycles.current`。低于任一限制的值会以 `400` 错误被驳回。发送
                        `null` 或省略此字段，会保持当前值不变；不支持清除之前设置的周期上限。
                      format: int32
                      minimum: 1
                customer_payer:
                  type: object
                  description: 指定用于识别客户的 `customer_payer` 对象。
                  properties:
                    id:
                      type: string
                      description: 客户的唯一标识符（MAX 255；MIN 3）。仅在需要更改订阅的客户时发送。
                    ip_address:
                      type: string
                      maxLength: 45
                      example: 203.0.113.7
                      description: >-
                        付款人在首次客户发起的支付时的 IP 地址（IPv4 或 IPv6，最多 45
                        个字符）。发送它会替换已存储的值，该值会在每次续订时发送；省略它（或发送空值）会保持已存储的值不变，并且无法清除。不是有效
                        IPv4 或 IPv6 地址的值会返回 `400 BAD_REQUEST`（"The
                        customer_payer.ip_address must be a valid IPv4 or IPv6
                        address."）。仅对已启用该功能的组织保存和返回。
                payment_method:
                  type: object
                  description: >-
                    指定 `payment_method` 对象。支持的类型为 `CARD` 和
                    `PAYPAL_ENROLLMENT`。发送 `payment_method` 时，`type` 和
                    `vaulted_token` 为必填，即使您只更改 `card.usage` 也是如此。
                  properties:
                    type:
                      type: string
                      description: 支付方式类型。
                      enum:
                        - CARD
                    vaulted_token:
                      type: string
                      description: 存储令牌（UUID，MAX：64；MIN：36）。只要发送了 `payment_method`，就必填。
                    card:
                      type: object
                      description: 指定卡对象。
                      properties:
                        usage:
                          type: string
                          description: >-
                            表示此已存储凭证是首次使用（FIRST）还是之前已使用过（USED）。如果在订阅之前创建了 CIT
                            支付，则为必填：没有它，续订扣款会被视为 CIT，并可能被拒绝。
                          enum:
                            - FIRST
                            - USED
                  required:
                    - type
                    - vaulted_token
                availability:
                  type: object
                  description: >-
                    指定 `availability`
                    对象。根据开始日期和结束日期定义订阅可以使用的日期区间。如果请求中省略该对象，可用日期保持不变。包含该对象时，省略
                    `finish_at`（或将其设为 `null`）会移除之前设置的结束日期；省略 `start_at`
                    会保持当前的开始日期不变。
                  properties:
                    start_at:
                      type: string
                      description: >-
                        订阅计划可以开始使用的开始日期。如果未设置，订阅从创建的那一刻起即可使用。更新时，省略此字段会保持当前开始日期不变，并且开始日期只能提前：发送更晚的日期会返回
                        400 错误。
                      format: date-time
                    finish_at:
                      type:
                        - string
                        - 'null'
                      description: >-
                        订阅可以使用的截止日期。当请求中包含 `availability` 对象时，省略此字段或发送 `null`
                        可以清除之前设置的结束日期：订阅变为没有结束时间，并持续续订，直到被取消。发送日期时间可以设置或更新结束日期。请注意，`availability.finish_at`
                        和 `billing_cycles.total` 是相互独立的结束条件：先到达的那个会使订阅完成。
                      format: date-time
                retries:
                  type: object
                  description: >-
                    今后要应用的重试配置。接受与创建订阅相同的对象，包括 strategy 和 schedule，但
                    cancel_on_exhausted_retries
                    除外，它仅限创建时设置。变更在下一次安排重试时生效：已经在执行重试的计费周期会按它开始时的配置完成，更新从下一个周期起生效。
                  properties:
                    retry_on_decline:
                      type: boolean
                      description: 首次被拒绝之后是否重试支付。默认为 False。
                    amount:
                      type: integer
                      description: >-
                        对于 DEFAULT 和 SMART
                        策略，订阅将尝试的重试次数。最大值等于您所在环境配置的重试计划长度，生产环境为 6；更高的值会以 400
                        被驳回（Max retries attempts exceeded）。对于
                        CUSTOM_SCHEDULE，次数改为由 schedule 数组的长度得出。
                      format: int32
                    strategy:
                      type: string
                      description: >-
                        重试策略。允许的值：DEFAULT（固定重试计划）、SMART（基于机器学习的重试时机，从第二次重试开始应用）或
                        CUSTOM_SCHEDULE（使用您提供的每次尝试计划数组）。发送 schedule 而不带
                        strategy，则默认为 CUSTOM_SCHEDULE。
                      enum:
                        - DEFAULT
                        - SMART
                        - CUSTOM_SCHEDULE
                    schedule:
                      type: array
                      description: >-
                        每次尝试的重试计划；整体替换已存储的计划。最多 7 次尝试，尝试编号必须从 1 开始依次递增，每个
                        delay_seconds 必须在 1 到 604800（7 天）之间。发送它即表示 strategy 为
                        CUSTOM_SCHEDULE，并将重试次数设置为 schedule 的长度。
                      items:
                        properties:
                          attempt:
                            type: number
                            description: 重试尝试的编号
                          delay_seconds:
                            type: number
                            description: 指定每次重试之间的秒数。
                        type: object
                    stop_on_hard_decline:
                      type: boolean
                      description: >-
                        为 true 时，在硬拒绝之后，当前计费周期的重试计划会停止。仅此一项时，订阅保持
                        ACTIVE，计费推进到下一个周期；不会取消或暂停任何订阅，也不会发出订阅 webhook。如果
                        cancel_on_exhausted_retries 也为 true，则订阅会被取消。
                    cancel_on_exhausted_retries:
                      type: boolean
                      description: >-
                        仅限创建时设置：订阅创建后无法更改此标志，发送与订阅上已存储的值不同的值会返回 400（The field
                        'retries.cancel_on_exhausted_retries' can only be set
                        when the subscription is created）；回显当前值会被接受。为 true
                        时，一个计费周期的重试结束后仍没有支付成功，订阅就会被取消，而不是保持 ACTIVE
                        并推进到下一个周期。cancellation_source 设置为
                        RETRIES_EXHAUSTED，并发出一条 SUBSCRIPTION.CANCEL webhook。默认为
                        false。取消本身是最终的，因此之后重试订阅会被驳回。
                plan_change:
                  type: object
                  nullable: true
                  description: >-
                    将订阅转移到另一个计划。`effective:
                    NEXT_BILLING_CYCLE`（默认）将变更安排在下一次续订时：不按比例计费，周期中途不扣款。`effective:
                    IMMEDIATE` 在本次调用中就地应用变更：订阅保留其
                    `id`，新计划的价格从下一次扣款起计费，`billing_cycle_behavior`
                    决定计费锚点如何处理。订阅必须处于 ACTIVE 或 TRIALING 状态，并且已在某个计划上；目标计划必须处于
                    ACTIVE 状态。对于预定的变更，同一时间只能有一个待处理：在它生效之前，发送 `"plan_change":
                    null` 可以撤销它（在另一个变更待处理时再发送 IMMEDIATE 变更会返回
                    409）。`amount`、`frequency`、`billing_date` 和 `country`
                    由计划管理，不能为关联了计划的订阅发送，将其中任何一个与 `plan_change` 组合都会返回 400。
                  required:
                    - plan_id
                  properties:
                    plan_id:
                      type: string
                      description: 目标计划的标识符。必填。目标计划必须处于 ACTIVE 状态，并且以订阅的币种定价。
                    effective:
                      type: string
                      enum:
                        - NEXT_BILLING_CYCLE
                        - IMMEDIATE
                      description: >-
                        变更生效的时间。NEXT_BILLING_CYCLE（默认）：当前周期按当前计划的价格计费，下一个周期按新计划的价格计费。IMMEDIATE：订阅在本次调用中转移到目标计划，与预定的变更不同，这在最后一个计费周期中也可以使用。
                    phases_behavior:
                      type: string
                      enum:
                        - START_FROM_REGULAR
                        - HONOR_PHASES
                      description: >-
                        目标计划包含阶段时会发生什么。START_FROM_REGULAR（默认）直接进入常规阶段，不会重新经历试用。HONOR_PHASES
                        按目标计划的阶段安排进入。
                    billing_cycle_behavior:
                      type: string
                      enum:
                        - KEEP
                        - RESTART
                      description: >-
                        在使用 `effective: IMMEDIATE`
                        就地更改计划时，计费锚点会如何处理。KEEP（默认，省略该字段的行为与之相同）：下一次扣款日期保持不变。RESTART：下一次扣款重新锚定到变更时刻加上新计划的频率，只重置锚点；计费周期计数器、重试配置和订阅状态都会保留。RESTART
                        需要 `effective: IMMEDIATE`，与预定的变更一起使用会返回 400；KEEP
                        与预定的变更一起使用会被接受，并照常安排该变更。只写：任何响应中都不会回显此字段。
                    promotion_behavior:
                      type: string
                      enum:
                        - KEEP
                        - END
                      description: >-
                        计划变更时，生效的促销会如何处理。`KEEP`（默认）会将其连同剩余周期一起保留在新计划上。`END` 会以
                        `end_reason` 为 `PLAN_CHANGE` 结束它。没有生效的促销时会被忽略。
                    apply_new_plan_promotion:
                      type: boolean
                      description: >-
                        计划变更时，是否应用新计划的 `AUTOMATIC` 促销。`true`（默认）会应用它，并以
                        `PLAN_CHANGE` 结束当前促销。`false` 则不应用，由 `promotion_behavior`
                        决定当前促销如何处理。
                billing_cycle_behavior:
                  type: string
                  enum:
                    - KEEP
                    - RESTART
                  description: >-
                    对于没有关联计划的订阅：以与 `plan_change.billing_cycle_behavior`
                    相同的方式重新锚定计费，通常与同一次调用中的 `frequency`
                    变更组合使用（例如从按月改为按年，从今天起重新开始周期）。KEEP（默认）：下一次扣款日期保持不变。RESTART：将下一次扣款重新锚定到现在加上（可能已更新的）频率；只重置锚点，周期计数器、重试配置和订阅状态都会保留。对于尚未开始的订阅（CREATED，此处接受，与
                    `plan_change` 不同），锚点会限制在其开始日期。规则：不能与 `plan_change`
                    同时使用（400，请使用嵌套字段）；在关联了计划的订阅上使用此字段会返回 400（通过 `plan_change`
                    管理）；处于 PAUSED 状态的订阅会返回 409
                    INVALID_SUBSCRIPTION_STATUS。只写：任何响应中都不会回显。
                metadata:
                  type: object
                  description: >-
                    可以附加到对象上的一组键值对。这有助于以结构化的格式存储对象的附加信息。向单个键发送空值可以取消设置该键。向
                    metadata 发送空值可以取消设置所有键。
                  properties:
                    key:
                      type: string
                      description: 表示 metadata 中键值对的键的对象标题（MAX 48 ; MIN 1）。
                    value:
                      type: string
                      description: 所定义的键对应的对象值（MAX 512 ; MIN 1）。
                refund_rule:
                  type: object
                  description: >-
                    配置退款规则，当之后的 CUSTOM 取消请求没有自带 refund_amount
                    时，用它来确定该取消的退款。适用于已启用该功能的组织；请联系 Yuno。发送 null 可以清除之前配置的规则。
                  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
                  nullable: true
                promotion:
                  type: object
                  description: >-
                    应用附加到订阅计划上的促销。`id` 和 `code` 只能发送其中一个。订阅必须处于 `ACTIVE` 或
                    `TRIALING` 状态，折扣从下一次扣款起生效。在另一个促销生效时应用促销会替换它：当前促销以
                    `end_reason` 为 `REPLACED` 结束，新促销从已使用 0
                    个周期开始。请参阅[订阅计划上的促销](/zh-hans/docs/payment-features/subscriptions/promotions)。
                  properties:
                    id:
                      type: string
                      description: 促销的 ID（UUID）。使用 `id` 或 `code`，不能同时使用。
                    code:
                      type: string
                      description: 带有代码的促销的代码。使用 `id` 或 `code`，不能同时使用。
            examples:
              Update card usage:
                summary: >-
                  Mark the card as already used, so rebills are sent as
                  subsequent payments
                value:
                  payment_method:
                    type: CARD
                    vaulted_token: <current vaulted_token of the subscription>
                    card:
                      usage: USED
      responses:
        '200':
          description: '200'
          content:
            application/json:
              examples:
                UPDATE SUBSCRIPTION:
                  value:
                    id: 0c7fed3e-ee0d-4d34-9547-778be4ec0798
                    name: Test Subscription
                    account_id: 493e9374-510a-4201-9e09-de669d75f256
                    country: US
                    description: Subscription Test
                    merchant_reference: subscription-ref-merchant-AA01
                    soft_descriptor: ACME SUBSCRIPTION
                    status: ACTIVE
                    amount:
                      currency: USD
                      value: 15000
                    frequency:
                      type: MONTH
                      value: 1
                    billing_cycles:
                      total: 12
                      current: 1
                      next_at: '2024-09-30T12:04:23.265393Z'
                    customer_payer:
                      id: a1d3b664-e32a-4508-9da1-9ede3e62a60c
                    payment_method:
                      type: CARD
                      vaulted_token: d4aa3586-def2-4705-b7cd-fe064bb764e6
                    availability:
                      start_at: '2024-09-30T12:04:23.265393Z'
                      finish_at: null
                    metadata: null
                    pending_plan_change:
                      plan_id: 1904911d-5df9-429e-8488-ad41abea1a4d
                      plan_name: Pro
                      direction: UPGRADE
                      effective: NEXT_BILLING_CYCLE
                      phases_behavior: START_FROM_REGULAR
                      applies_at: '2024-10-30T12:04:23.265372Z'
                      requested_at: '2024-09-30T12:04:23.265372Z'
                    created_at: '2024-09-30T12:04:23.265372Z'
                    updated_at: '2024-09-30T12:04:23.265372Z'
                    retries:
                      retry_on_decline: false
                      amount: 6
                      strategy: DEFAULT
                      schedule: null
                      stop_on_hard_decline: null
                      cancel_on_exhausted_retries: null
                    additional_data: null
                    trial_period:
                      billing_cycles: 1
                      amount:
                        value: 0
                        currency: USD
                    initial_payment_validation: false
                    reason: null
                    subscription_agreement_id: null
                    renewal_notification_days: null
                    cancellation_time: null
                    cancellation_source: null
                    ending_time: null
                    current_period_start: '2026-10-23T00:00:00Z'
                    current_period_end: '2026-11-23T00:00:00Z'
              schema:
                type: object
                properties:
                  id:
                    type: string
                    example: 0c7fed3e-ee0d-4d34-9547-778be4ec0798
                  name:
                    type: string
                    example: Test Subscription
                  account_id:
                    type: string
                    example: 493e9374-510a-4201-9e09-de669d75f256
                  country:
                    type: string
                    example: US
                  description:
                    type: string
                    example: Subscription Test
                    nullable: true
                  merchant_reference:
                    type: string
                    example: subscription-ref-merchant-AA01
                  soft_descriptor:
                    type: string
                    description: 账单描述符。
                    example: ACME SUBSCRIPTION
                    nullable: true
                  status:
                    type: string
                    example: ACTIVE
                  amount:
                    type: object
                    properties:
                      currency:
                        type: string
                        example: USD
                      value:
                        type: number
                        example: 15000
                        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: 12
                        default: 0
                        nullable: true
                      current:
                        type: integer
                        example: 1
                        default: 0
                      next_at:
                        type: string
                        example: '2024-09-30T12:04:23.265393Z'
                      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` 是正在计费的周期。
                  customer_payer:
                    type: object
                    properties:
                      id:
                        type: string
                        example: a1d3b664-e32a-4508-9da1-9ede3e62a60c
                      ip_address:
                        type: string
                        maxLength: 45
                        example: 203.0.113.7
                        description: >-
                          为续订保存的付款人 IP
                          地址。仅在单个订阅的响应（创建、检索、更新、暂停、恢复、重新激活和取消）中返回，并且仅在提供了该地址时返回；列表项和
                          webhook 中从不返回。
                  payment_method:
                    type: object
                    properties:
                      type:
                        type: string
                        example: CARD
                      vaulted_token:
                        type: string
                        example: d4aa3586-def2-4705-b7cd-fe064bb764e6
                      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-09-30T12:04:23.265393Z'
                      finish_at: {}
                  metadata: {}
                  pending_plan_change:
                    type: object
                    nullable: true
                    description: 预定在下一个计费周期生效的计划变更，没有待处理的变更时为 null。
                    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: '2024-10-30T12:04:23.265372Z'
                      requested_at:
                        type: string
                        description: 变更被预定的时间。
                        example: '2024-09-30T12:04:23.265372Z'
                  created_at:
                    type: string
                    example: '2024-09-30T12:04:23.265372Z'
                  updated_at:
                    type: string
                    example: '2024-09-30T12:04:23.265372Z'
                  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
                  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
                    description: 试用期。
                    properties:
                      billing_cycles:
                        type: integer
                        example: 1
                        default: 0
                      amount:
                        type: object
                        properties:
                          value:
                            type: number
                            example: 0
                            default: 0
                          currency:
                            type: string
                            example: USD
                  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
                    description: 订阅协议 ID。
                    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
                  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
                  promotion:
                    type: object
                    description: >-
                      订阅上存储的促销副本。请参阅[订阅促销对象](/zh-hans/reference/subscriptions/the-subscription-promotion-object)。
                    properties:
                      id:
                        type: string
                        description: 促销的 ID（UUID）。
                      name:
                        type: string
                      discount:
                        type: object
                        description: >-
                          带 `value` 的 `PERCENTAGE`，或带 `amount` 和 `currency` 的
                          `FIXED`。
                        properties:
                          type:
                            type: string
                            enum:
                              - PERCENTAGE
                              - FIXED
                          value:
                            type: number
                            description: 仅限 `PERCENTAGE`。范围为 0 到 100，最多 2 位小数。
                          amount:
                            type: number
                            description: 仅限 `FIXED`。按币种的小数位数表示。
                          currency:
                            type: string
                            description: 仅限 `FIXED`。ISO 4217 代码。
                      cycles:
                        type: object
                        properties:
                          total:
                            type: integer
                          used:
                            type: integer
                            description: 自应用以来已计入的周期：已批准的扣款、试用周期和 100% 折扣的周期。
                          remaining:
                            type: integer
                      on_pause:
                        type: string
                        enum:
                          - KEEP
                          - END
                      status:
                        type: string
                        enum:
                          - ACTIVE
                          - COMPLETED
                          - ENDED
                      applied_at:
                        type: string
                        format: date-time
                      ended_at:
                        type: string
                        format: date-time
                        nullable: true
                      end_reason:
                        type: string
                        nullable: true
                        enum:
                          - REPLACED
                          - REMOVED
                          - PLAN_CHANGE
                          - PAUSE
                          - CANCELED
        '400':
          description: '400'
          content:
            application/json:
              examples:
                Result:
                  value:
                    code: INVALID_REQUEST
                    messages:
                      - Invalid request.
                PIX AUTOMATICO CADENCE NOT SUPPORTED:
                  value:
                    code: INVALID_PARAMETERS
                    messages:
                      - >-
                        Pix Automático only supports weekly, monthly, quarterly,
                        half-yearly or yearly frequencies with value 1.
                PLAN CHANGE BEHAVIOR INVALID VALUE:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - >-
                        RESET is invalid for plan_change.billing_cycle_behavior
                        field
                  summary: >-
                    plan_change.billing_cycle_behavior accepts only KEEP or
                    RESTART.
                BEHAVIOR COMBINED WITH PLAN CHANGE:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - >-
                        The billing_cycle_behavior field cannot be combined with
                        plan_change; use plan_change.billing_cycle_behavior.
                  summary: >-
                    When you send plan_change, put the behaviour inside it
                    rather than at the top level.
                RESTART REQUIRES IMMEDIATE:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - >-
                        The plan_change.billing_cycle_behavior value RESTART
                        requires effective IMMEDIATE.
                  summary: >-
                    RESTART re-anchors the billing date, so it is only valid on
                    an immediate plan change.
                PLAN CHANGE ALREADY SCHEDULED:
                  value:
                    code: PLAN_CHANGE_ALREADY_SCHEDULED
                    messages:
                      - >-
                        A plan change is already scheduled for this
                        subscription. Undo it first with plan_change: null.
                  summary: Only one plan change may be pending at a time.
                REFUND RULE CURRENCY MISMATCH:
                  value:
                    code: REFUND_RULE_CURRENCY_MISMATCH
                    messages:
                      - >-
                        refund_rule.amount.currency USD must match the
                        subscription currency COP.
                  summary: >-
                    A FIXED refund_rule must be denominated in the
                    subscription's own currency.
                REFUND RULE PERCENT OUT OF RANGE:
                  value:
                    code: BAD_REQUEST
                    messages:
                      - refund_rule.percent must be between 0 and 100.
      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.