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

# 重试订阅

> 针对当前计费周期，手动重试订阅最近一次已拒绝的支付。

使用此 endpoint 手动重试订阅最近一次失败的支付。当客户在计费周期中途更新了支付方式或解决了支付问题（例如余额不足、卡片过期）时，此功能非常有用，因为订阅更新仅从下一个计费周期开始生效。调用此 endpoint 会使用最新的订阅配置，强制为当前周期发起一次新的收费尝试。

* 只能重试订阅的 **最近一次支付**。
* **仅当** 上一次重试尝试的结果为 DECLINED 状态时，才能执行多次手动重试。
* 手动触发重试会 **停止** 相应支付的 [智能重试机制](https://docs.y.uno/zh-hans/docs/payment-features/subscriptions/retries.md)。如果创建订阅时启用了智能重试机制，该订阅后续的支付将继续遵循该机制。
* 重试成功后，系统将 **继续** 执行下一次计划的订阅收费。
* 如果上述条件均不满足，请求将返回 `400`，代码为 **INVALID\_STATE**，消息为 `The last payment intent of the subscription does not support the action requested.`。订阅已取消时也会返回相同的错误。
* 如果账户中没有与 `subscription_id` 匹配的订阅，请求将返回 `400`，代码为 **SUBSCRIPTION\_NOT\_FOUND**。


## OpenAPI

````yaml openapi/zh-hans/subscriptions/retry-subscription.json POST /subscriptions/{subscription_id}/retry
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}/retry:
    post:
      summary: 重试订阅
      operationId: retry-subscription
      parameters:
        - name: subscription_id
          in: path
          description: >-
            订阅的唯一标识符，请参阅[创建订阅](/zh-hans/reference/subscriptions/create-subscription)（UUID）。
          schema:
            type: string
          required: true
        - in: header
          name: X-Account-Code
          schema:
            type: string
          description: >-
            在 [Yuno Dashboard](https://dashboard.y.uno/developers) 中找到的
            `account_id`（UUID）。
      responses:
        '200':
          description: '200'
          content:
            application/json:
              examples:
                Result:
                  value:
                    id: 0054840f-bcd5-4d8e-b86c-c18ede81c556
                    name: Test Subscription
                    account_id: f7c5fe77-721b-49c2-84d3-957748df3c2c
                    country: CL
                    description: Subscription Test
                    merchant_reference: subscription-ref-merchant-AA01
                    status: ACTIVE
                    amount:
                      currency: CLP
                      value: 15000
                    frequency:
                      type: MONTH
                      value: 1
                    billing_cycles:
                      total: 12
                      current: 2
                      next_at: '2025-05-29T11:13:31.786421Z'
                    customer_payer:
                      id: 1c6d1a88-d8d5-4c09-b19c-852530d89f05
                    payment_method:
                      type: CARD
                      vaulted_token: 743880c1-1bdb-4572-99a8-c4e5ce184895
                    availability:
                      start_at: '2025-04-29T11:13:31.786421Z'
                      finish_at: null
                    retries:
                      retry_on_decline: false
                      amount: 6
                    metadata: null
                    additional_data: null
                    trial_period:
                      billing_cycles: 1
                      amount:
                        value: 0
                        currency: ''
                    initial_payment_validation: false
                    created_at: '2025-04-29T11:13:31.786421Z'
                    updated_at: '2025-04-29T11:13:31.942325Z'
              schema:
                type: object
                properties:
                  id:
                    type: string
                    example: 0054840f-bcd5-4d8e-b86c-c18ede81c556
                  name:
                    type: string
                    example: Test Subscription
                  account_id:
                    type: string
                    example: f7c5fe77-721b-49c2-84d3-957748df3c2c
                  country:
                    type: string
                    example: CL
                  description:
                    type: string
                    example: Subscription Test
                  merchant_reference:
                    type: string
                    example: subscription-ref-merchant-AA01
                  status:
                    type: string
                    example: ACTIVE
                  amount:
                    type: object
                    properties:
                      currency:
                        type: string
                        example: CLP
                      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
                      current:
                        type: integer
                        example: 2
                        default: 0
                      next_at:
                        type: string
                        example: '2025-05-29T11:13:31.786421Z'
                      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: 1c6d1a88-d8d5-4c09-b19c-852530d89f05
                  payment_method:
                    type: object
                    properties:
                      type:
                        type: string
                        example: CARD
                      vaulted_token:
                        type: string
                        example: 743880c1-1bdb-4572-99a8-c4e5ce184895
                      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: '2025-04-29T11:13:31.786421Z'
                      finish_at: {}
                  retries:
                    type: object
                    properties:
                      retry_on_decline:
                        type: boolean
                        example: false
                        default: true
                      amount:
                        type: integer
                        example: 6
                        default: 0
                      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 时出现。
                  metadata: {}
                  additional_data: {}
                  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: ''
                  initial_payment_validation:
                    type: boolean
                    example: false
                    default: true
                  created_at:
                    type: string
                    example: '2025-04-29T11:13:31.786421Z'
                  updated_at:
                    type: string
                    example: '2025-04-29T11:13:31.942325Z'
                  soft_descriptor:
                    type: string
                    example: ACME SUBSCRIPTION
                    nullable: true
                  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
                  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'
                  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:
                Result:
                  value:
                    code: INVALID_STATE
                    messages:
                      - >-
                        The last payment intent of the subscription does not
                        support the action requested.
                SUBSCRIPTION NOT FOUND:
                  value:
                    code: SUBSCRIPTION_NOT_FOUND
                    messages:
                      - Subscription not found.
                  summary: >-
                    No subscription resolves for the subscription_id on this
                    account. Returned as 400, not 404.
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: INVALID_STATE
                  messages:
                    type: array
                    items:
                      type: string
                      example: >-
                        The last payment intent of the subscription does not
                        support the action requested.
      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.