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

# 取消计划

> 取消计划，并级联取消当前与其关联的所有订阅。

> [!CAUTION]
>
> **级联取消是同步且立即生效的**
>
> 取消计划会立即取消该计划上的所有订阅：无法在不取消其订阅者的情况下单独取消计划。请检查响应中的 `affected_subscriptions`，了解受影响的订阅数量。
>
> 对已处于 `CANCELED` 状态的计划再次取消是安全的，并会重新执行级联：它会再次返回 `200`，而不是错误。这是有意设计的：如果之前的级联未能取消部分订阅，这就是恢复途径，因此如果您不确定取消调用是否已完全完成，请重试。`INVALID_STATE`（`400`）保留给 `ACTIVE`/`CANCELED` 之外的计划状态，而由于这是仅有的两种计划状态，目前不会出现这种情况。


## OpenAPI

````yaml openapi/zh-hans/plans/cancel-plan.json POST /subscriptions/plans/{plan_id}/status
openapi: 3.1.0
info:
  title: plans
  version: 1.0.0
servers:
  - url: https://api-sandbox.y.uno/v1
    description: Sandbox
  - url: https://api.y.uno/v1
    description: Production (US)
security:
  - sec0: []
    sec1: []
paths:
  /subscriptions/plans/{plan_id}/status:
    post:
      summary: 取消计划
      description: 唯一支持的状态转换。取消计划会阻止新订阅，并同步级联取消当前关联到该计划的所有订阅。
      operationId: cancel-plan
      parameters:
        - in: header
          name: X-Account-Code
          required: true
          schema:
            type: string
          description: >-
            您的 [Yuno Dashboard](https://dashboard.y.uno/developers) 中的
            `account_id`（UUID）。必填：缺少该参数时返回 `400 BAD_REQUEST`（"Invalid
            x-account-code header."）。
        - name: plan_id
          in: path
          description: 计划的唯一标识符。
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - status
              properties:
                status:
                  type: string
                  enum:
                    - CANCELED
            examples:
              Result:
                value:
                  status: CANCELED
      responses:
        '200':
          description: '200'
          content:
            application/json:
              examples:
                Result:
                  value:
                    id: 00000000-0000-4000-8000-000000000001
                    status: CANCELED
                    affected_subscriptions: 3
              schema:
                type: object
                properties:
                  id:
                    type: string
                  status:
                    type: string
                  affected_subscriptions:
                    type: integer
                    description: 随计划一并级联取消的订阅数量。
        '400':
          description: >-
            400。保留给 ACTIVE/CANCELED 以外的计划状态，目前无法触发，因为这两个是计划当前仅有的状态。重复取消已处于
            CANCELED 的计划不会触发此错误：它会重新执行级联取消并返回 200。
          content:
            application/json:
              examples:
                Result:
                  value:
                    code: INVALID_STATE
                    messages:
                      - The plan state does not support the action requested.
                  summary: Result
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: INVALID_STATE
                  messages:
                    type: array
                    items:
                      type: string
      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.