- An API key with the
onrampscope. See getting access. - A Base address you control to receive the USDC.
1
Quote the collection
Specify either the KES amount to charge the customer, or the USDC amount you want to receive. This example charges the customer an exact KES figure.
amount_kes is the exact figure the customer’s phone will be prompted to pay. amount_usdc is what your address receives.2
Create the order
Pass an The payment prompt is sent to the customer’s phone the moment this call succeeds. There is no separate trigger step.
Idempotency-Key header so a network retry can never send a second payment prompt.3
Customer confirms
The customer enters their PIN on the prompt. Nothing further is required from your side.
Each order is one-shot. If the customer cancels or the prompt times out, the order moves to
failed and cannot be retried. Create a new order.4
Confirm completion
Poll the order, or listen for the webhook:When payment is collected,
status becomes completed and receipt_number holds the M-Pesa confirmation code. An onramp.completed webhook fires at that moment; onramp.released follows once the on-chain transfer is confirmed and carries release_tx_hash. See onramp webhooks.Quoting the other direction
If you’d rather guarantee a specific USDC amount and let the KES figure float, passamount_usdc instead of amount_kes:
amount_kes is then the figure the customer is charged, always your requested amount_usdc plus the 1% fee. Pass the same field to POST /api/onramp/orders in place of amount_kes.
