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

# 计划对象

> 介绍计划对象的属性，包括按国家/地区定价、阶段和元数据。

## 属性

计划是一个可重复使用的定价目录条目。将客户订阅到某个计划，而不是直接在订阅上设置 `amount`/`frequency`，所有定义“收费多少、多久收费一次”的字段都会从该计划中解析。

**id** `string`

计划的唯一标识符（MAX 64; MIN 36）。

示例：00000000-0000-4000-8000-000000000001

**account\_id** `string`

计划所属账户的唯一标识符（MAX 64; MIN 36）。

示例：00000000-0000-4000-8000-000000000002

**account\_ids** `Array of strings`

与该计划共享的其他账户，不包括 `account_id` 中的所有者账户。对于只属于单个账户的计划，此字段为空。此字段仅在响应中返回，创建计划时不接受该字段。

示例：\["00000000-0000-4000-8000-000000000003"]

**name** `string`

计划名称（MAX 255; MIN 3）。

示例：Streaming Pro

**description** `string`

计划描述。目前不强制执行长度限制。

示例：Access to Pro features, billed monthly

**merchant\_reference** `string`

您为该计划自定义的标识符。目前不强制执行长度限制。

示例：streaming-pro-monthly

**status** `enum`

计划的状态。

可能的值：

* `ACTIVE` = 可以订阅该计划。
* `CANCELED` = 该计划不再接受新的订阅。取消计划还会取消当前与其关联的所有订阅。

**base\_amount** `object`

在 `country_prices` 中没有明确条目的任何国家/地区收取的默认价格。

**属性**

**currency** `enum`

用于支付的币种（MAX 3; MIN 3; [ISO 4217](https://docs.y.uno/zh-hans/reference/country-reference.md)）。

**value** `number`

支付金额（0.0001 的倍数）。

示例：20.00

**frequency** `object`

计划的计费频率。从该计划创建的每个订阅都会继承此频率：使用 `plan_id` 订阅时，请勿发送 `frequency`。

**属性**

**type** `enum`

可能的枚举值：`DAY`、`WEEK`、`MONTH`、`QUARTER`、`HALF_YEAR` 或 `YEAR`。

**value** `int`

示例：1

**country\_prices** `array of objects`

明确的按国家/地区定价。未在此列出的国家/地区将回退为使用 `base_amount`。

**属性**

**country** `string`

MAX 2; MIN 2; [ISO 3166-1](https://docs.y.uno/zh-hans/reference/country-reference.md)。

**amount** `object`

**属性**

**currency** `enum`

**value** `number`

**allowed\_payment\_methods** `array of strings`

该计划的订阅可接受的支付方式类型。

示例：`["CARD", "PIX"]`

**metadata** `array of objects`

附加在计划本身上的键值对。它独立于直接在订阅上设置的任何 `metadata`，相关内容请参阅[订阅对象](https://docs.y.uno/zh-hans/reference/subscriptions/the-subscription-object.md)。

**属性**

**key** `string`

示例：campaign

**value** `string`

示例：app\_store

**phases** `array of objects`

在计划的常规价格生效之前，可选的一组前置阶段（例如试用期）。对于没有试用期的固定计划，请省略此字段。

**属性**

**order**\* `int`

在阶梯中的位置，从 1 开始计数。`order` 最大的阶段是终止阶段，即常规价格阶段，该阶段没有 `duration`。必填。

**name**\* `string`

必填，不可为空：每个阶段都必须有名称。

**type**\* `enum`

必填。可能的值：`TRIAL`（任意前置阶段，任意价格，包括 0）、`REGULAR`（终止阶段）。

**duration** `object`

每个非终止阶段必填；终止阶段省略。

**属性**

**type** `enum`

`DAY`、`WEEK`、`MONTH` 或 `YEAR`。

**value** `int`

**frequency** `object`

可选。如果省略，该阶段将以一次性收费的方式覆盖整个 `duration`。如果设置，该阶段将改为按每个 `frequency` 间隔计费。不适用于终止阶段。

**属性**

**type** `enum`

`DAY`、`WEEK`、`MONTH`、`QUARTER`、`HALF_YEAR` 或 `YEAR`。

**value** `int`

**amount** `object`

该阶段的固定价格。允许为 0（免费试用）。

> [!WARNING]
>
> 在**非终止**阶段，此字段或 `country_prices` 为必填，二者择一。在**终止**的 REGULAR 阶段，请完全省略此字段：在该阶段发送 `amount` 会被拒绝并返回 `400 BAD_REQUEST`（"The terminal phase price comes from the plan base\_amount/country\_prices - remove the phase amount"）。终止阶段的价格始终来自计划自身的 `base_amount`/`country_prices`，绝不会来自阶段层级的字段。

**country\_prices** `array of objects`

该阶段的按国家/地区定价，结构与计划层级的 `country_prices` 相同。在非终止阶段，此字段或 `amount` 为必填。不适用于终止阶段。

**total\_payments** `int`

由服务器计算。如果省略 `frequency`，则始终为 `1`（整个阶段一次性收费）。如果设置了 `frequency`，则为 `duration / frequency`（两者使用相同单位）：例如，为期 3 个月且按月计费（`frequency: {type: MONTH, value: 1}`）的阶段会得到 `3`。终止阶段为 `null`。

**subscribers\_count** `int`

当前在该计划上的有效订阅数量（处于任何非终止状态）。这就是取消操作会影响的订阅集合。

示例：12

> [!NOTE]
>
> 仅由[列出计划](https://docs.y.uno/zh-hans/reference/plans/list-plans.md)返回，[创建计划](https://docs.y.uno/zh-hans/reference/plans/create-plan.md)或[检索计划](https://docs.y.uno/zh-hans/reference/plans/retrieve-plan.md)的响应中不包含此字段。

**countries** `array of strings`

已排序的 ISO α2 代码：该计划在计划层级或任意阶段中明确定价的所有国家/地区的去重并集。空数组表示该计划通过 `base_amount` 在全球适用，而不是没有覆盖范围。

> [!NOTE]
>
> 仅由[列出计划](https://docs.y.uno/zh-hans/reference/plans/list-plans.md)返回，[创建计划](https://docs.y.uno/zh-hans/reference/plans/create-plan.md)或[检索计划](https://docs.y.uno/zh-hans/reference/plans/retrieve-plan.md)的响应中不包含此字段。

**created\_at** `Timestamp`

**updated\_at** `Timestamp`

## 相关内容

* [创建计划](https://docs.y.uno/zh-hans/reference/plans/create-plan.md)
* [检索计划](https://docs.y.uno/zh-hans/reference/plans/retrieve-plan.md)
* [列出计划](https://docs.y.uno/zh-hans/reference/plans/list-plans.md)
* [取消计划](https://docs.y.uno/zh-hans/reference/plans/cancel-plan.md)
* [订阅对象](https://docs.y.uno/zh-hans/reference/subscriptions/the-subscription-object.md)：请参阅 `plan_id`，了解订阅如何关联回其计划


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