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

> Creates a full or partial refund for an eligible paid order created through the native Kyren API.
Epay-source orders must be refunded through the Epay compatibility API.




## OpenAPI

````yaml /openapi.yaml post /v1/orders/{orderId}/refunds
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@kyrenpay.com
    url: https://kyrenpay.com
servers:
  - url: https://api.kyrenpay.com
    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: Refunds
    description: Create and retrieve refunds for eligible paid Kyren API orders.
  - 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/orders/{orderId}/refunds:
    post:
      tags:
        - Refunds
      summary: Create a refund
      description: >
        Creates a full or partial refund for an eligible paid order created
        through the native Kyren API.

        Epay-source orders must be refunded through the Epay compatibility API.
      operationId: createRefund
      parameters:
        - name: orderId
          in: path
          required: true
          schema:
            type: string
          description: The Kyren order ID to refund
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateRefundRequest'
            example:
              amount: '9.99'
              reason: Customer requested refund
              refundNo: refund_20260708001
      responses:
        '200':
          description: Refund request accepted or processed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RefundResponseWrapper'
              example:
                code: 0
                message: success
                data:
                  id: refund_abc123
                  merchantId: merch_001
                  orderId: order_def456
                  status: PROCESSING
                  amount: '9.99'
                  currency: USD
                  userRefundAmountUsd: '9.99'
                  merchantDebitUsd: '9.99'
                  reason: Customer requested refund
                  errorMessage: null
                  createdAt: 1783526400000
                  updatedAt: 1783526400000
                  succeededAt: null
                  failedAt: null
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    CreateRefundRequest:
      type: object
      required:
        - amount
      properties:
        amount:
          type: string
          description: >-
            Refund amount as a decimal string. Must be greater than 0 and not
            exceed the remaining refundable amount.
        reason:
          type: string
          nullable: true
          description: Optional refund reason.
        refundNo:
          type: string
          nullable: true
          description: Optional merchant refund number used for idempotency.
    RefundResponseWrapper:
      type: object
      properties:
        code:
          type: integer
          example: 0
        message:
          type: string
          example: success
        data:
          $ref: '#/components/schemas/Refund'
    Refund:
      type: object
      properties:
        id:
          type: string
        merchantId:
          type: string
        orderId:
          type: string
        status:
          $ref: '#/components/schemas/RefundStatus'
        amount:
          type: string
        currency:
          type: string
        userRefundAmountUsd:
          type: string
          nullable: true
        merchantDebitUsd:
          type: string
          nullable: true
        reason:
          type: string
        errorMessage:
          type: string
          nullable: true
        createdAt:
          type: integer
          format: int64
          description: Unix timestamp in milliseconds
        updatedAt:
          type: integer
          format: int64
          description: Unix timestamp in milliseconds
        succeededAt:
          type: integer
          format: int64
          nullable: true
          description: Unix timestamp in milliseconds
        failedAt:
          type: integer
          format: int64
          nullable: true
          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
    RefundStatus:
      type: string
      enum:
        - CREATED
        - SUBMITTING
        - PROCESSING
        - SUCCEEDED
        - FAILED
        - UNKNOWN
      description: |
        - `CREATED` — Refund record has been created
        - `SUBMITTING` — Refund is being submitted to the provider
        - `PROCESSING` — Provider is processing the refund
        - `SUCCEEDED` — Refund succeeded
        - `FAILED` — Refund failed
        - `UNKNOWN` — Final provider status is not confirmed yet
  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
    NotFound:
      description: Not found — the requested resource does not exist
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: 404
            message: Not Found
  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.

````