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

# 创建客户会话

> 创建客户会话，用于注册和管理已保存的支付方式，以便今后使用

创建客户会话，用于注册和管理支付方式。使用它来保存卡片、钱包和其他支付方式，以便今后使用。需要来自 [创建客户](https://docs.y.uno/zh-hans/reference/customers/create-customer.md) 的 `customer_id`。


## OpenAPI

````yaml openapi/zh-hans/customer-sessions-enrollment/create-customer-session.json POST /customers/sessions
openapi: 3.1.0
info:
  title: customer-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:
  /customers/sessions:
    post:
      summary: 创建客户会话
      operationId: create-customer-session
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - account_id
                - country
                - customer_id
              properties:
                account_id:
                  type: string
                  description: >-
                    账户的唯一标识符。您可以在 [Yuno Dashboard](https://dashboard.y.uno/)
                    上找到此信息（UUID，36 个字符）。
                country:
                  type: string
                  description: >-
                    客户所在国家/地区（最大 2；最小 2；[ISO
                    3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)）。
                  enum:
                    - AR
                    - BO
                    - BR
                    - CL
                    - CO
                    - CR
                    - EC
                    - SV
                    - GT
                    - HN
                    - MX
                    - NI
                    - PA
                    - PY
                    - PE
                    - US
                    - UY
                customer_id:
                  type: string
                  description: >-
                    客户的唯一标识符，通过 [Create
                    Customer](https://docs.y.uno/zh-hans/reference/customers/create-customer)
                    endpoint 创建（UUID，36 个字符）。
                callback_url:
                  type: string
                  description: 在服务提供商环境中完成注册后，将客户重定向到的 URL（最大 526；最小 3）。
                checkout_id:
                  type: string
                  description: 用于此注册会话的自定义 Checkout 的唯一标识符（UUID）。可选。省略时，会话使用账户的默认 checkout。
                metadata:
                  type: array
                  description: >-
                    可选的自定义键值标签，用于通过此会话注册的支付方式。它们的行为与直接注册的 `metadata`
                    相同：随已注册的支付方式一起存储，在您检索该支付方式时以及 `enrollment.enroll` webhook
                    中返回，并随注册一同发送到服务提供商集成，但保留的 `gateway_options`
                    条目除外，该条目会被存储和返回，但不会被转发。最多 120 项，所有键和值合计最多 75000 个字符。
                  items:
                    properties:
                      key:
                        type: string
                        description: >-
                          元数据键（MAX 48. Value: MIN:1, MAX:48）。**[Case
                          Sensitive]**
                      value:
                        type: string
                        description: >-
                          元数据键值（MAX 512. Value: MIN:1, MAX:512）。**[Case
                          Sensitive]**
                    required:
                      - key
                      - value
                    type: object
            examples:
              Customer session:
                value:
                  account_id: 8beac4de-5f6f-11ed-9b6a-0242ac120002
                  customer_id: ae106483-65ee-463b-8782-9794022b3112
                  country: US
                  callback_url: >-
                    https://www.google.com/?customerSession=7dd71f21-9e4c-439a-9c6d-58f240bd28df
                  created_at: '2025-05-07T20:00:18.721786Z'
                  checkout_id: 6822f80c-684e-41a3-8628-78963d3d60f7
                  metadata:
                    - key: on_behalf_of
                      value: acct_1A2b3C4d5E6f7G8h
                    - key: order_ref
                      value: ABC-123
      responses:
        '201':
          description: '201'
          content:
            application/json:
              examples:
                Customer session:
                  value:
                    customer_session: 7dd71f21-9e4c-439a-9c6d-58f240bd28df
                    customer_id: ae106483-65ee-463b-8782-9794022b3112
                    country: US
                    callback_url: >-
                      https://www.google.com/?customerSession=7dd71f21-9e4c-439a-9c6d-58f240bd28df
                    created_at: '2025-05-07T20:00:18.721786Z'
                    checkout_id: 6822f80c-684e-41a3-8628-78963d3d60f7
              schema:
                type: object
                properties:
                  customer_session:
                    type: string
                    example: 7dd71f21-9e4c-439a-9c6d-58f240bd28df
                  customer_id:
                    type: string
                    example: ae106483-65ee-463b-8782-9794022b3112
                  country:
                    type: string
                    example: US
                  callback_url:
                    type: string
                    example: >-
                      https://www.google.com/?customerSession=7dd71f21-9e4c-439a-9c6d-58f240bd28df
                  created_at:
                    type: string
                    example: '2025-05-07T20:00:18.721786Z'
                  checkout_id:
                    type: string
                    example: 6822f80c-684e-41a3-8628-78963d3d60f7
                  metadata:
                    type: array
        '400':
          description: '400'
          content:
            application/json:
              examples:
                Bad Request:
                  value:
                    code: INVALID_REQUEST
                    messages:
                      - Invalid request
                Customer Not Found:
                  value:
                    code: CUSTOMER_NOT_FOUND
                    messages:
                      - Customer not found
                  summary: Customer Not Found
              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.