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

# Create a checkout session

> Creates a new checkout session for a product. Returns a URL where you can redirect
your customer to complete the payment. Checkout sessions expire after 24 hours.




## OpenAPI

````yaml /openapi.yaml post /v1/checkouts
openapi: 3.1.0
info:
  title: Kyren Pay API
  description: >
    The Kyren Pay API enables merchants to accept payments from customers
    worldwide.

    Integrate checkout sessions, manage products, track orders, and handle
    webhooks.


    **Data types**: The API uses the following types for request/response data:

    - **string**: For text, identifiers, and **all amount/price fields** (e.g.
    `price`, `amount`, `platformFee`, `available`)
      to avoid floating-point precision issues. Use decimal format like `"9.99"`.
    - **integer**: For counts, pagination, and timestamps

    - **timestamp**: Unix timestamp in milliseconds (integer) for all time
    fields (e.g. `createdAt`, `paidAt`, `expiresAt`).
      Time parameters (e.g. `startDate`, `endDate`) also use Unix milliseconds.
  version: 1.0.0
  contact:
    name: Kyren Pay Support
    email: support@kyren.top
    url: https://kyren.top
servers:
  - url: https://api.kyren.top
    description: Production
  - url: https://staging-api.kyren.top
    description: Staging, available only with credentials issued by Kyren
security:
  - ApiKeyAuth: []
tags:
  - name: Config
    description: Retrieve platform configuration such as supported currencies.
  - name: Products
    description: Create and manage products that represent the goods or services you sell.
  - name: Checkouts
    description: Create checkout sessions to collect payments from your customers.
  - name: Orders
    description: View and manage orders created from completed checkout sessions.
  - name: Balance
    description: View your account balance and transaction history.
  - name: Epay Compatibility
    description: >
      Compatibility endpoints for existing integrations built on 易支付 API
      conventions.

      These endpoints use form/query parameters with `pid + sign` verification
      (MD5), not `x-api-key` header auth.
paths:
  /v1/checkouts:
    post:
      tags:
        - Checkouts
      summary: Create a checkout session
      description: >
        Creates a new checkout session for a product. Returns a URL where you
        can redirect

        your customer to complete the payment. Checkout sessions expire after 24
        hours.
      operationId: createCheckout
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCheckoutRequest'
            example:
              productId: prod_abc123
              successUrl: https://example.com/success
              cancelUrl: https://example.com/cancel
              customerEmail: customer@example.com
              displayMerchantName: Campaign Store
              metadata:
                userId: user_456
      responses:
        '200':
          description: Checkout session created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutResponseWrapper'
              example:
                code: 0
                message: success
                data:
                  id: cs_xyz789
                  productId: prod_abc123
                  amount: '9.99'
                  currency: USD
                  status: OPEN
                  url: https://payment.kyren.io/checkout/cs_xyz789
                  expiresAt: 1736934000000
                  createdAt: 1736932200000
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    CreateCheckoutRequest:
      type: object
      required:
        - productId
        - successUrl
      properties:
        productId:
          type: string
          description: The ID of the product to create a checkout for
        successUrl:
          type: string
          format: uri
          description: URL to redirect the customer to after successful payment
        cancelUrl:
          type: string
          format: uri
          description: URL to redirect the customer to if they cancel the payment
        customerEmail:
          type: string
          format: email
          description: Pre-fill the customer's email on the checkout page
        customerName:
          type: string
          description: Pre-fill the customer's name on the checkout page
        displayMerchantName:
          type: string
          maxLength: 80
          description: >-
            Optional per-checkout merchant display name shown on the hosted
            checkout page. Also accepted as `display_merchant_name`.
        metadata:
          type: object
          additionalProperties:
            type: string
          description: >-
            Arbitrary key-value pairs attached to the checkout and resulting
            order
    CheckoutResponseWrapper:
      type: object
      properties:
        code:
          type: integer
          example: 0
        message:
          type: string
          example: success
        data:
          $ref: '#/components/schemas/Checkout'
    Checkout:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier
        productId:
          type: string
        amount:
          type: string
          description: Order amount (e.g. "9.99")
        currency:
          type: string
        status:
          $ref: '#/components/schemas/CheckoutStatus'
        url:
          type: string
          format: uri
          description: The URL to redirect the customer to for payment
        expiresAt:
          type: integer
          format: int64
          description: Unix timestamp in milliseconds
        createdAt:
          type: integer
          format: int64
          description: Unix timestamp in milliseconds
    ErrorResponse:
      type: object
      properties:
        code:
          type: integer
        message:
          type: string
        error:
          type: object
          properties:
            field:
              type: string
            reason:
              type: string
    CheckoutStatus:
      type: string
      enum:
        - OPEN
        - COMPLETE
        - EXPIRED
      description: |
        - `OPEN` — Checkout session is awaiting payment
        - `COMPLETE` — Payment has been completed
        - `EXPIRED` — Checkout session has expired (24 hours)
  responses:
    BadRequest:
      description: Bad request — invalid parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: 400
            message: Bad Request
            error:
              field: productId
              reason: Product ID is required
    Unauthorized:
      description: Unauthorized — missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: 401
            message: Unauthorized
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >
        Your API key. Public production API-key endpoints accept `kyren_live_*`
        keys. Staging credentials are environment-specific and must be used only
        with the staging environment for which Kyren issued them.

````