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

# 创建定价方案

> 创建定价方案



## OpenAPI

````yaml openapi/v1-zh.yaml POST /api/v1/prices
openapi: 3.0.3
info:
  title: Subotiz API
  description: Subotiz OpenAPI
  version: 1.0.0
servers:
  - url: https://{api}.subotiz.com
    variables:
      api:
        default: api
security:
  - sec0: []
tags:
  - name: 折扣
    description: 折扣
  - name: 发票
    description: 发票
  - name: 退款
    description: 退款
  - name: 商品管理
    description: 商品管理
  - name: 订阅
    description: 订阅
  - name: 商品定价
    description: 商品定价方案
  - name: 交易单
    description: 交易单
  - name: 支付流水
    description: 支付流水
  - name: 结账会话
    description: 结账会话
  - name: 顾客
    description: 顾客
  - name: 顾客门户
    description: 顾客门户
  - name: Webhook
    description: Webhook
  - name: 争议
    description: 争议订单
paths:
  /api/v1/prices:
    post:
      tags:
        - 商品定价
      summary: 创建定价方案
      description: 创建定价方案
      operationId: v1-price-create-price
      parameters:
        - $ref: '#/components/parameters/HeaderRequestID'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePriceRequest'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatePriceResponse'
components:
  parameters:
    HeaderRequestID:
      name: Request-Id
      in: header
      description: 请求的唯一标识符
      required: true
      schema:
        type: string
        default: 008e3967-a1b5-48bb-be14-d5bff5092e61
  schemas:
    CreatePriceRequest:
      required:
        - name
        - product_id
        - product_version_id
        - billing_type
        - description
        - price_type
      type: object
      properties:
        name:
          type: string
          description: 定价方案名称
        product_id:
          type: string
          description: 关联商品 ID
        product_version_id:
          type: string
          description: 商品版本 ID
        billing_type:
          type: string
          description: 计费类型：one_time-一次性 / recurring-周期性
        price_val:
          type: string
          description: 一次性支付价格，当 billing_type 为 one_time 时必填
        description:
          type: string
          description: 定价描述
        has_trial:
          type: boolean
          description: 是否启用试用期
        trial_period:
          allOf:
            - $ref: '#/components/schemas/TrialPeriod'
          description: 试用期配置
        price_plan:
          allOf:
            - $ref: '#/components/schemas/CreatePricePlan'
          description: 定价计划，当 billing_type 为 recurring 时必填
        price_type:
          type: string
          description: 定价类型，取值之一：flat_price | package_price | based_on_usage
        usage_amount:
          type: string
          description: 用量，当 price_type 为 based_on_usage 或 package_price 时必填
        usage_unit:
          type: string
          description: 用量单位，当 price_type 为 based_on_usage 或 package_price 时必填
        features:
          type: array
          items:
            $ref: '#/components/schemas/CreatePriceFeature'
          description: 定价权益列表
        model_type:
          type: string
          description: 定价模型类型，取值之一：per_unit | tiers_price，当 price_type 为 based_on_usage 时必填
        billing_threshold:
          type: string
          description: 扣费阈值，当 model_type 为 per_unit 时必填
        trial_type:
          type: integer
          description: 试用类型：0-免费试用 | 1-付费试用
          format: int32
        trial_amount:
          type: string
          description: 试用价格，当 trial_type 为 1（付费试用）时必填
        status:
          type: string
          description: |-
            状态：
             - draft：草稿
             - active：已激活
             - frozen：已冻结
      description: 创建定价方案请求
    CreatePriceResponse:
      type: object
      properties:
        code:
          type: string
          description: error code
        message:
          type: string
          description: error message
        data:
          $ref: '#/components/schemas/CreatePriceResponse_Data'
      description: 创建定价方案响应
    TrialPeriod:
      type: object
      properties:
        trial_period_unit:
          type: string
          description: 试用期单位，必填，如：day、week、month等
        trial_period_count:
          type: integer
          description: 试用期数量，必填，如：7天、1个月等
          format: int32
      description: TrialPeriod - 试用期配置
    CreatePricePlan:
      type: object
      properties:
        base_price_val:
          type: string
          description: 基础价格，计划的基础定价
        billing_cycle_unit:
          type: string
          description: >-
            计费周期单位，取值之一：week、month、quarter、year、customer-initiated、over_threshold
        price_tiers:
          type: array
          items:
            $ref: '#/components/schemas/CreatePriceTier'
          description: 阶梯定价明细，不同周期的具体价格
        price_usage_tiers:
          type: array
          items:
            $ref: '#/components/schemas/PriceUsageTier'
          description: 阶梯定价明细，不同用量区间的具体价格
        price_tier_type:
          type: string
          description: >-
            价格阶梯类型，取值之一：common | volume | grading；common 用于一口价与资源包，volume 与
            grading 用于按量计费
        usage_unit_price:
          type: string
          description: 用量单价
      description: 创建定价时的定价计划
    CreatePriceFeature:
      type: object
      properties:
        product_feature_id:
          type: string
          description: 商品权益 ID
        value:
          type: string
          description: 权益数值，默认为 0
      description: 创建定价权益
    CreatePriceResponse_Data:
      type: object
      properties:
        price_id:
          type: string
          description: 定价方案 ID
        price_version_id:
          type: string
          description: 定价方案版本 ID
      description: 创建定价方案响应
    CreatePriceTier:
      type: object
      properties:
        billing_cycle_index:
          type: integer
          description: 计费周期索引，表示第几个周期
          format: int32
        price_val:
          type: string
          description: 价格值，该周期的具体价格
      description: 创建定价阶梯
    PriceUsageTier:
      type: object
      properties:
        usage_min:
          type: string
          description: 用量下限
        usage_max:
          type: string
          description: 用量上限
        current_tier_amount:
          type: string
          description: 当前阶梯金额
      description: 按用量阶梯定价明细
  securitySchemes:
    sec0:
      type: http
      description: 'Bearer API Key 鉴权。格式：Authorization: Bearer {your_api_key}'
      scheme: bearer

````