Create a checkout session
Send aPOST request to /api/v1/payment/collection/checkout/ with your public key and the payment details. The response includes a url (the hosted checkout page) and a signature you use to authorise subsequent payment calls from that session.
Request fields
| Field | Type | Required | Description |
|---|---|---|---|
public_key | string | Yes | Your publishable API key from the dashboard. You can also pass this in the X-KULMI-PUBLIC-API-KEY header instead. |
amount | number | Yes | Amount to collect, in the specified currency. |
currency | string | Yes | Currency code: KES, USD, EUR, or GBP. |
email | string | No | Pre-fill the customer’s email on the checkout page. |
api_ref | string | No | Your internal reference for this transaction. |
card_tarrif | string | No | Who pays card transaction fees. BUSINESS-PAYS (default) or CUSTOMER-PAYS. |
mobile_tarrif | string | No | Who pays mobile money fees. BUSINESS-PAYS (default) or CUSTOMER-PAYS. |
unique_api_ref | boolean | No | When true, if a checkout already exists for this api_ref, Kulmi Pay returns the existing session instead of creating a new one. Use this for idempotency. |
Success response
Embed checkout in JavaScript or React
You can redirect the customer to theurl from the response, or embed the checkout inside your app using an iframe or Kulmi Pay’s JavaScript widget.
Idempotency with unique_api_ref
If your user navigates away and returns, or your server retries a failed request, you may not want to create a duplicate checkout session. Setunique_api_ref: true and include a consistent api_ref value (such as your order ID). Kulmi Pay returns the existing checkout session if one already exists for that reference, rather than creating a new one.
The checkout session URL is tied to your business account. Always use your publishable (public) key in client-side code, never your secret key. Your secret key should only be used in server-side requests.
