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

# Create Offramp Request

> This endpoint will create a offramp request for a customer. If the fiat transfer fails after successful crypto receipt, an automatic refund will be initiated after 5 minutes. Use the refund-status endpoint to check refund status.

This endpoint will create an offramp request for a customer to convert crypto to fiat.


## OpenAPI

````yaml POST /api/v3/offramp
openapi: 3.0.0
info:
  title: KOTANI PAY API PLATFORM
  description: ''
  version: '3.0'
  contact: {}
servers:
  - url: https://sandbox-api.kotanipay.io
    description: Sandbox
security: []
tags: []
paths:
  /api/v3/offramp:
    post:
      tags:
        - OFFRAMP
      summary: Offramp Request
      description: >-
        This endpoint will create a offramp request for a customer. If the fiat
        transfer fails after successful crypto receipt, an automatic refund will
        be initiated after 5 minutes. Use the refund-status endpoint to check
        refund status.
      operationId: OffRampController_createOfframp_api/v3
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OfframpDto'
      responses:
        '200':
          description: Offramp Response
          content:
            application/json:
              schema:
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: Offramp has been successfully created
                  data:
                    $ref: '#/components/schemas/OfframpResponseDto'
                    type: object
        '400':
          description: ''
          content:
            application/json:
              schema:
                properties:
                  success:
                    type: boolean
                    example: false
                  message:
                    type: string
                    example: Bad Request
                  data:
                    type: object
                    example: {}
        '401':
          description: ''
          content:
            application/json:
              schema:
                properties:
                  success:
                    type: boolean
                    example: false
                  message:
                    type: string
                    example: Unauthorized
                  data:
                    type: object
                    example: {}
      security:
        - JWT: []
components:
  schemas:
    OfframpDto:
      type: object
      properties:
        referenceId:
          type: string
          description: Onramp reference ID
        depositStatus:
          description: Deposit status
          allOf:
            - 7bd08c10-49e7-436f-a689-4b2225d294eb
        lipaNaMpesaReceiver:
          description: Lipa na M-Pesa (Till/Buy Goods) receiver — Kenya only
          allOf:
            - $ref: '#/components/schemas/LipaNaMpesaReceiverDto'
        paybillReceiver:
          description: Paybill receiver — Kenya only
          allOf:
            - $ref: '#/components/schemas/PaybillReceiverDto'
        cryptoAmount:
          type: number
          description: The crypto amount
        currency:
          description: Fiat currency
          allOf:
            - b8fd9289-e02d-4dce-a99e-b8621cbe9438
        transactionHash:
          type: string
          description: Transaction hash
        refund_config:
          description: >-
            Optional refund destination for this transaction. For Lightning:
            provide a bolt11 invoice so Kotani can refund immediately if fiat
            disbursement fails, without waiting for you to submit one manually.
            Include generate_invoice_url so Kotani can refresh the invoice if it
            expires. For on-chain chains: provide address as the fallback refund
            destination. If omitted, Kotani notifies you via webhook and email
            when a refund is needed and you submit via POST
            /offramp/submit-refund-invoice/:referenceId.
          allOf:
            - $ref: '#/components/schemas/OfframpRefundConfigDto'
      required:
        - cryptoAmount
        - currency
        - chain
        - token
        - referenceId
    OfframpResponseDto:
      type: object
      properties:
        referenceId:
          type: string
          description: The reference ID of the onramp crypto transaction
        status:
          type: string
          description: The status of the onramp crypto transaction
        cryptoAmount:
          type: number
          description: The amount of crypto sent
        cryptoAmountReceived:
          type: number
          description: The amount of crypto received
        feeInCrypto:
          type: number
          description: The fee in crypto
        feeType:
          type: string
          description: The type of fee
        cryptoWallet:
          type: string
          description: The ID of the crypto wallet
        chain:
          type: object
          description: The chain of the onramp crypto transaction
        token:
          type: object
          description: The token of the onramp crypto transaction
        transactionHash:
          type: string
          description: Creation timestamp
        updated_at:
          format: date-time
          type: string
          description: Last update timestamp
        onchainError:
          type: object
          description: Onchain error details if the transaction failed
        transactionError:
          type: object
          description: Transaction error details if the transaction failed
      required:
        - referenceId
        - status
        - cryptoAmount
        - cryptoAmountReceived
        - feeInCrypto
        - feeType
        - cryptoWallet
        - chain
        - token
        - transactionHash
    LipaNaMpesaReceiverDto:
      type: object
      properties:
        businessShortcode:
          type: string
          description: Till number (Business shortcode) to pay to
          example: '174379'
        accountReference:
          type: string
          description: Account reference (optional)
        transactionDesc:
          type: string
          description: Transaction description (optional)
      required:
        - businessShortcode
    PaybillReceiverDto:
      type: object
      properties:
        paybillNumber:
          type: string
          description: Paybill number to send payment to
          example: '400200'
        accountNumber:
          type: string
          description: Account number / reference the Paybill uses to identify the sender
          example: ACC123456
        remarks:
          type: string
          description: Transaction remarks (optional)
      required:
        - paybillNumber
        - accountNumber
    OfframpRefundConfigDto:
      type: object
      properties:
        bolt11:
          type: string
          description: >-
            Pre-generated Lightning bolt11 refund invoice. If provided and valid
            when a refund is triggered, Kotani pays this invoice directly
            without waiting for you to submit one manually. Lightning invoices
            expire — provide generate_invoice_url so Kotani can fetch a fresh
            one if this expires.
          example: lnbc1500n1p0xyz...
        payment_hash:
          type: string
          description: >-
            Payment hash of the bolt11 invoice — used to detect if the invoice
            was already paid.
          example: a1b2c3d4e5f6...
        amount_msat:
          type: number
          description: >-
            Amount of the bolt11 invoice in millisatoshis. Must exactly match
            the crypto amount to be refunded. Kotani validates this before
            paying.
          example: 150000000
        expires_at:
          type: string
          description: >-
            ISO 8601 expiry timestamp of the bolt11 invoice. If expires_at is in
            the past when a refund is triggered, Kotani calls
            generate_invoice_url for a fresh invoice. Lightning invoices
            typically expire in 1–24 hours depending on your node settings.
          example: '2024-11-22T13:00:00Z'
        generate_invoice_url:
          type: string
          description: >-
            URL Kotani calls (POST) to request a fresh bolt11 invoice when the
            stored one has expired. Kotani sends { amount_msat, reference_id }
            in the request body and expects { bolt11, payment_hash, amount_msat,
            expires_at } in the response. If not provided and the invoice
            expires, Kotani falls back to webhook notification asking you to
            submit via POST /offramp/submit-refund-invoice/:referenceId.
          example: https://api.yourapp.com/lightning/generate-refund-invoice
        address:
          type: string
          description: >-
            Fallback on-chain address for non-Lightning chains (EVM, Solana,
            Stellar, Cardano etc.). Kotani sends refunded crypto here if the
            fiat disbursement fails. Must be a valid address for the same chain
            as the offramp transaction.
          example: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'
  securitySchemes:
    JWT:
      scheme: bearer
      bearerFormat: JWT
      type: http

````