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

# 创建结账会话

> 创建与客户关联的结账会话，用于通过 SDK 初始化支付

此请求使用创建 `customer` 资源时生成的唯一标识符来创建结账会话。

> [!NOTE]
>
> 如果您的工作流需要发送 `additional_data` 对象，可以将其作为结账会话的一部分发送。


## OpenAPI

````yaml openapi/checkout-sessions/create-checkout-session.json POST /checkout/sessions
openapi: 3.1.0
info:
  title: checkout-api
  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:
  /checkout/sessions:
    post:
      summary: Create Checkout Session
      operationId: create-checkout-session
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - merchant_order_id
                - payment_description
                - country
                - account_id
              properties:
                customer_id:
                  type: string
                  description: >-
                    The unique identifier of the customer, created using the
                    [Create
                    Customer](https://docs.y.uno/reference/create-customer)
                    endpoint (UUID, 36 chars).
                merchant_order_id:
                  type: string
                  description: >-
                    The unique identifier of the customer's order (MAX 255; MIN
                    3).
                payment_description:
                  type: string
                  description: The description of the payment (MAX 255; MIN 3).
                callback_url:
                  type: string
                  description: >-
                    The URL where we will redirect your customer after making
                    the purchase. Required for alternative payment methods with
                    redirection. (MAX 526; MIN 3)
                country:
                  type: string
                  description: >-
                    Country where the transaction must be processed (MAX 2; MIN
                    2; [ISO 3166-1](/reference/country-reference)).
                account_id:
                  type: string
                  description: >-
                    The unique identifier of the account. You find this
                    information on [the Yuno
                    dashboard](https://dashboard.y.uno/) (UUID, 36 chars).
                amount:
                  type: object
                  description: >-
                    Specifies the payment amount object, with the value and
                    currency.
                  required:
                    - currency
                    - value
                  properties:
                    currency:
                      type: string
                      description: >-
                        The currency used to make the payment. For a full list
                        of currency codes, see [Country
                        reference](/reference/country-reference) (MAX 3; MIN 3;
                        ISO 4217).
                    value:
                      type: number
                      description: >-
                        The payment amount (multiple of 0.0001). For a
                        zero-decimal currency (for example KRW, JPY, or CLP) the
                        value must be a whole number: see [Amounts and
                        currencies](/docs/basic-concepts/amounts-and-currencies).
                      format: float
                alternative_amount:
                  type: object
                  description: >-
                    Alternative currency representation of the transaction
                    amount.
                  required:
                    - currency
                    - value
                  properties:
                    currency:
                      type: string
                      description: >-
                        The alternative currency code. For a full list of
                        currency codes, see [Country
                        reference](/reference/country-reference) (MAX 3; MIN 3;
                        ISO 4217).
                      nullable: true
                    value:
                      type: number
                      description: >-
                        The alternative amount value (multiple of 0.0001). For a
                        zero-decimal currency (for example KRW, JPY, or CLP) the
                        value must be a whole number: see [Amounts and
                        currencies](/docs/basic-concepts/amounts-and-currencies).
                      format: float
                shipping_methods:
                  type: array
                  description: >-
                    Delivery options the customer can pick from inside a wallet
                    widget (Fast Checkout). The first method is preselected. The
                    currency of every amount must match the session currency.
                  items:
                    required:
                      - id
                      - label
                      - amount
                      - summary_items
                    properties:
                      id:
                        type: string
                        description: >-
                          Merchant-defined identifier of the delivery method
                          (MAX 255). Echoed back as shipping.method.id on the
                          payment.
                      label:
                        type: string
                        description: Name the wallet displays for the method (MAX 255).
                      detail:
                        type: string
                        description: >-
                          Optional secondary text, such as the delivery promise
                          (MAX 255).
                      amount:
                        type: object
                        description: Cost of the delivery method.
                        required:
                          - currency
                          - value
                        properties:
                          currency:
                            type: string
                            description: >-
                              ISO 4217 currency code. Must match the session
                              currency.
                          value:
                            type: number
                            description: Cost value (multiple of 0.0001).
                            format: float
                      delivery_estimate:
                        type: object
                        description: >-
                          Optional delivery window (date-only, format
                          YYYY-MM-DD).
                        properties:
                          from:
                            type: string
                            description: Earliest delivery date.
                          to:
                            type: string
                            description: Latest delivery date.
                      summary_items:
                        type: array
                        description: >-
                          Order breakdown the wallet sheet displays when this
                          method is selected (at least one item; the last entry
                          is the grand total).
                        items:
                          required:
                            - id
                            - label
                            - amount
                          properties:
                            id:
                              type: string
                              description: Identifier of the line item (MAX 255).
                            label:
                              type: string
                              description: >-
                                Name the wallet displays for the line item (MAX
                                255).
                            amount:
                              type: object
                              description: >-
                                Amount of the line item. Currency must match the
                                session currency.
                              required:
                                - currency
                                - value
                              properties:
                                currency:
                                  type: string
                                  description: ISO 4217 currency code.
                                value:
                                  type: number
                                  description: Amount value (multiple of 0.0001).
                                  format: float
                metadata:
                  type: array
                  description: >-
                    Specifies a list of metadata objects. You can add up to 120
                    metadata objects.
                  items:
                    properties:
                      key:
                        type: string
                        description: The metadata key (MAX 48)
                      value:
                        type: string
                        description: The metadata key value (MAX 512)
                    required:
                      - key
                      - value
                    type: object
                workflow:
                  type: string
                  description: Checkout workflow type.
                  enum:
                    - SDK_CHECKOUT
                    - CHECKOUT
                    - SDK_SEAMLESS
                installments:
                  type: object
                  description: >-
                    The object to send the installment plan created in Yuno to
                    show your customers and let them choose from. This optional
                    field is used in case a particular installments plan needs
                    to be used in the session. if not sent, we will display the
                    installment plan created for the account for each scenario,
                    if any.
                  properties:
                    plan_id:
                      type: string
                      description: Plan Id of the installment plan created in Yuno
                    plan:
                      type: array
                      description: >-
                        Installments to show the customer in with the
                        checkout_session. This optional struct is used in case a
                        particular installments plan needs to be used in the
                        session and does not have an installments plan created
                        for it. if not sent, we will display the installment
                        plan created for the account for each scenario, if any.
                      items:
                        properties:
                          installment:
                            type: integer
                            description: >-
                              The number of monthly installments shoppers can
                              choose
                            format: int32
                          rate:
                            type: number
                            description: >-
                              The rate applied to the final amount of the
                              transaction by the payment provider after using
                              installments. The value should be entered as a
                              multiplier, not a percentage. For example, to
                              apply a 20% rate, enter `1.20` instead of `20`.
                            format: float
                        required:
                          - installment
                          - rate
                        type: object
                recurring_payment:
                  type: object
                  description: >-
                    Optional object to enable and configure recurring payments
                    (subscriptions).
                  properties:
                    description:
                      type: string
                      description: Description of the subscription plan.
                    management_url:
                      type: string
                      description: URL where the user can manage their subscription.
                    billing_agreement:
                      type: string
                      description: Billing agreement identifier.
                    regular_billing:
                      type: object
                      description: Configuration for the recurring billing cycle.
                      required:
                        - label
                        - amount
                        - interval_unit
                        - interval_count
                      properties:
                        label:
                          type: string
                          description: >-
                            Descriptive label for the billing cycle (e.g.
                            "Monthly").
                        amount:
                          type: string
                          description: Billing amount (e.g. "9.99").
                        interval_unit:
                          type: string
                          description: Unit of the billing interval.
                          enum:
                            - year
                            - month
                            - day
                            - hour
                            - minute
                        interval_count:
                          type: integer
                          description: Number of units between each billing cycle.
                    trial_billing:
                      type: object
                      description: (Optional) Trial period configuration.
                      required:
                        - label
                        - amount
                        - interval_unit
                        - interval_count
                      properties:
                        label:
                          type: string
                          description: >-
                            Descriptive label for the trial billing cycle (e.g.
                            "Free trial").
                        amount:
                          type: string
                          description: Billing amount for trial (e.g. "0.00").
                        interval_unit:
                          type: string
                          description: Unit of the trial billing interval.
                          enum:
                            - year
                            - month
                            - day
                            - hour
                            - minute
                        interval_count:
                          type: integer
                          description: Number of units for the trial period.
                checkout_id:
                  type: string
                  description: >-
                    The unique identifier (UUID) of the Custom Checkout to use
                    for this session. Optional. When omitted, the session uses
                    the account's default checkout. The checkout must be a
                    checkout configuration published on the same account as the
                    session, otherwise the API rejects the request with `400
                    INVALID_CHECKOUT_CODE`.
                wallet_card_acceptance:
                  type: object
                  description: >-
                    Optional. Limits which cards the customer can select in the
                    Apple Pay payment sheet. Cards that do not match are shown
                    greyed out. Every field is optional; a field that is not
                    sent keeps the default behaviour. Values must be uppercase,
                    and an empty list is rejected with 400 INVALID_PARAMETERS.
                    It can only be set when the session is created.
                  properties:
                    supported_countries:
                      type: array
                      description: >-
                        Countries that issued the card, as ISO 3166-1 alpha-2
                        codes. This is the card's issuing country, not the
                        customer's location.
                      items:
                        type: string
                      example:
                        - BR
                    supported_networks:
                      type: array
                      description: >-
                        Card networks the customer can select. Replaces the
                        default list (AMEX, DISCOVER, ELECTRON, ELO, MASTERCARD,
                        VISA, MAESTRO).
                      items:
                        type: string
                      example:
                        - VISA
                        - MASTERCARD
                    supported_funding_types:
                      type: array
                      description: >-
                        Funding types the customer can select: CREDIT, DEBIT, or
                        both.
                      items:
                        type: string
                        enum:
                          - CREDIT
                          - DEBIT
                      example:
                        - CREDIT
                summary_items:
                  type: array
                  description: >-
                    Order breakdown the wallet sheet displays (at least one
                    item; the last entry is the grand total). The currency of
                    every amount must match the session currency. When
                    `shipping_methods` is also sent, Apple Pay uses the first
                    method's `summary_items` instead; Google Pay does the same
                    only when the shipping address handler is registered.
                  items:
                    required:
                      - id
                      - label
                      - amount
                    properties:
                      id:
                        type: string
                        description: Identifier of the line item (MAX 255).
                      label:
                        type: string
                        description: Name the wallet displays for the line item (MAX 255).
                      amount:
                        type: object
                        description: >-
                          Amount of the line item. Currency must match the
                          session currency.
                        required:
                          - currency
                          - value
                        properties:
                          currency:
                            type: string
                            description: ISO 4217 currency code.
                          value:
                            type: number
                            description: Amount value (multiple of 0.0001).
                            format: float
                tax_collection:
                  type: boolean
                  description: >-
                    Set to `true` to quote and charge the tax of the customer's
                    address before the payment. Needs `external_subscription`
                    with `customer_id` and `items`, and your organization must
                    have tax collection enabled (`403 PRODUCT_NOT_ENABLED`
                    otherwise). With the SDK, pass `onBillingAddressChanged` to
                    `startCheckout`. Default `false`.
                  example: true
                external_subscription:
                  type: object
                  description: >-
                    The Stripe Billing subscription that Yuno creates after the
                    payment is approved, for the price and tax flow described in
                    [Local price and
                    taxes](/docs/payment-features/subscriptions/local-price-and-taxes).
                    Send `customer_id` and `items`. `id` (an existing
                    subscription) cannot be sent with `items` or with
                    `tax_collection`. `trial_period_days` and `metadata` are not
                    supported yet and are rejected with `400`.
                  properties:
                    provider:
                      type: string
                      enum:
                        - STRIPE_BILLING
                      description: >-
                        The billing platform. Only `STRIPE_BILLING`, the
                        default.
                    customer_id:
                      type: string
                      description: >-
                        The customer's identifier in Stripe (`cus_...`). 3 to
                        255 characters.
                      example: cus_RplXYZ
                    currency:
                      type: string
                      description: The currency of the subscription prices.
                      example: USD
                    items:
                      type: array
                      description: The prices of the subscription to create.
                      items:
                        type: object
                        properties:
                          price:
                            type: string
                            description: The price identifier in Stripe (`price_...`).
                            example: price_1QwAbc
                          quantity:
                            type: integer
                            description: Quantity of the price. Default `1`.
                            example: 1
                        required:
                          - price
                    id:
                      type: string
                      description: >-
                        An existing subscription (`sub_...`), instead of
                        `items`. Not allowed with `tax_collection`.
            examples:
              Checkout Session (full data):
                value:
                  account_id: '{{account_id}}'
                  merchant_order_id: '1717681150'
                  payment_description: Test Cards
                  country: CO
                  customer_id: '{{customer_id}}'
                  callback_url: https://www.example.com
                  amount:
                    currency: COP
                    value: 8000
                  alternative_amount:
                    currency: USD
                    value: 2
                  metadata:
                    - key: ID
                      value: '123456'
                  recurring_payment:
                    description: Monthly subscription
                    management_url: https://example.com/manage
                    billing_agreement: BA-123
                    regular_billing:
                      label: Monthly
                      amount: '9.99'
                      interval_unit: month
                      interval_count: 1
                    trial_billing:
                      label: Free trial
                      amount: '0.00'
                      interval_unit: month
                      interval_count: 1
                  checkout_id: 6822f80c-684e-41a3-8628-78963d3d60f7
              Checkout Session (min data):
                value:
                  country: US
                  amount:
                    currency: USD
                    value: 100
                  alternative_amount:
                    currency: ARS
                    value: '140000'
                  account_id: '{{account_id}}'
                  merchant_order_id: '1717681150'
                  payment_description: Test Cards
                  customer_id: '{{customer_id}}'
              Checkout Session (alternative currency omitted):
                value:
                  account_id: '{{account_id}}'
                  merchant_order_id: '1717681150'
                  payment_description: Test Cards
                  country: CO
                  customer_id: '{{customer_id}}'
                  amount:
                    currency: COP
                    value: 8000
                summary: Checkout Session (alternative currency omitted)
      responses:
        '200':
          description: '200'
          content:
            application/json:
              examples:
                Checkout Session (min. data):
                  value:
                    merchant_order_id: '1717681150'
                    checkout_session: d313047b-4f96-44ef-bbad-caf1d7ba4c2b
                    country: US
                    payment_description: Test Cards
                    customer_id: a577ad8f-08f1-4590-9cf1-e7679b15ee84
                    callback_url: https://www.example.com/callback
                    amount:
                      currency: USD
                      value: 520
                    created_at: '2024-06-06T13:39:10.932297Z'
                    metadata: null
                    workflow: SDK_CHECKOUT
                    installments:
                      plan_id: null
                      plan: null
                    checkout_id: 6822f80c-684e-41a3-8628-78963d3d60f7
                    used: false
                Checkout Session (full data):
                  value:
                    merchant_order_id: '1717681150'
                    checkout_session: c437f4cc-7d66-40e6-a8df-7c3cde1ddca7
                    country: US
                    payment_description: Test Cards
                    customer_id: 55006822-7c79-490b-bea1-81798b9afc74
                    callback_url: >-
                      https://www.example.com/?checkoutSession=c437f4cc-7d66-40e6-a8df-7c3cde1ddca7
                    amount:
                      currency: USD
                      value: 520
                    created_at: '2023-07-20T17:06:17.232130Z'
                    metadata:
                      - key: ID
                        value: '123456'
                    workflow: SDK_CHECKOUT
                    installments:
                      plan_id: null
                      plan: null
                    checkout_id: 6822f80c-684e-41a3-8628-78963d3d60f7
                    used: false
              schema:
                title: Checkout Session
                type: object
                properties:
                  merchant_order_id:
                    type: string
                    example: '1717681150'
                  checkout_session:
                    type: string
                    example: c437f4cc-7d66-40e6-a8df-7c3cde1ddca7
                  country:
                    type: string
                    example: US
                  payment_description:
                    type: string
                    example: Test Cards
                  customer_id:
                    type: string
                    example: 55006822-7c79-490b-bea1-81798b9afc74
                  callback_url:
                    type:
                      - string
                      - 'null'
                    example: >-
                      https://www.example.com/?checkoutSession=c437f4cc-7d66-40e6-a8df-7c3cde1ddca7
                  amount:
                    type: object
                    properties:
                      currency:
                        type: string
                        example: USD
                      value:
                        type: integer
                        example: 520
                        default: 0
                  created_at:
                    type: string
                    example: '2023-07-20T17:06:17.232130Z'
                  metadata:
                    type:
                      - array
                      - 'null'
                    items:
                      type: object
                      properties:
                        key:
                          type: string
                          example: ID
                        value:
                          type: string
                          example: '123456'
                  workflow:
                    type: string
                    example: SDK_CHECKOUT
                  installments:
                    type: object
                    properties:
                      plan_id: {}
                      plan: {}
                  checkout_id:
                    type: string
                    example: 6822f80c-684e-41a3-8628-78963d3d60f7
                  used:
                    type: boolean
                    example: false
                    description: Used.
                  tax_collection:
                    type: boolean
                    description: >-
                      `true` when the checkout session quotes and charges taxes
                      before the payment.
                  external_subscription:
                    type: object
                    description: >-
                      The Stripe Billing subscription that Yuno creates after
                      the payment is approved, for the price and tax flow
                      described in [Local price and
                      taxes](/docs/payment-features/subscriptions/local-price-and-taxes).
                      Send `customer_id` and `items`. `id` (an existing
                      subscription) cannot be sent with `items` or with
                      `tax_collection`. `trial_period_days` and `metadata` are
                      not supported yet and are rejected with `400`.
                    properties:
                      provider:
                        type: string
                        enum:
                          - STRIPE_BILLING
                        description: >-
                          The billing platform. Only `STRIPE_BILLING`, the
                          default.
                      customer_id:
                        type: string
                        description: >-
                          The customer's identifier in Stripe (`cus_...`). 3 to
                          255 characters.
                        example: cus_RplXYZ
                      currency:
                        type: string
                        description: The currency of the subscription prices.
                        example: USD
                      items:
                        type: array
                        description: The prices of the subscription to create.
                        items:
                          type: object
                          properties:
                            price:
                              type: string
                              description: The price identifier in Stripe (`price_...`).
                              example: price_1QwAbc
                            quantity:
                              type: integer
                              description: Quantity of the price. Default `1`.
                              example: 1
                          required:
                            - price
                      id:
                        type: string
                        description: >-
                          An existing subscription (`sub_...`), instead of
                          `items`. Not allowed with `tax_collection`.
        '400':
          description: '400'
          content:
            application/json:
              examples:
                Bad Request:
                  value:
                    code: INVALID_REQUEST
                    messages:
                      - Invalid request
                Invalid checkout_id:
                  value:
                    code: INVALID_CHECKOUT_CODE
                    messages:
                      - >-
                        The checkout_code is invalid for this account or is not
                        published: 6822f80c-684e-41a3-8628-78963d3d60f7
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: INVALID_REQUEST
                  messages:
                    type: array
                    items:
                      type: string
                      example: Invalid request
        '401':
          description: '401'
          content:
            application/json:
              examples:
                Unauthorized:
                  value:
                    code: INVALID_CREDENTIALS
                    messages:
                      - Invalid credentials
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: INVALID_CREDENTIALS
                  messages:
                    type: array
                    items:
                      type: string
                      example: Invalid credentials
        '403':
          description: '403'
          content:
            application/json:
              examples:
                Forbidden:
                  value:
                    code: AUTHORIZATION_REQUIRED
                    messages:
                      - The merchant has no authorization to use this API.
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: AUTHORIZATION_REQUIRED
                  messages:
                    type: array
                    items:
                      type: string
                      example: The merchant has no authorization to use this API.
      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.