Prerequisites
- An Afriex Business account (sign up here)
- A tool for making HTTP requests (cURL, Postman, or your preferred HTTP client)
https://sandbox.api.afriex.com. Replace YOUR_API_KEY with your sandbox key, and replace the IDs in capitals with the values your earlier calls returned.
1
Get a sandbox API key
- Log in to the Afriex Dashboard and switch the Test / Live toggle to Test.
- Go to Developer and open the API Keys tab.
- Generate a key. For this guide, give it Write on Customers, Payment methods, and Withdrawals, and Read on Rates and quotes and Transactions. See Permissions for what each level grants.
- Copy the key and store it securely.
2
Create a customer
A customer is the end user you are acting for. On a payout, the customer is the sender; you save the recipient’s bank account in the next step.The response returns the new customer. Keep its
customerId for the next steps.You send the customer’s name as
fullName, and responses return it as name.3
Save the recipient's bank account
A payout goes to a payment method, so save the recipient’s bank account first, linked to the customer. Look up the bank’s Then create the payment method with an Keep the
institutionCode with List Institutions rather than hardcoding it:institutionCode and institutionName from that list:paymentMethodId from the response.4
Fund your sandbox balance
A payout debits your Payout wallet, so give it some test USD with Top Up Sandbox Balance:This endpoint is sandbox only and returns
403 in production.5
Price the payout
Ask for a quote before you send. Choose the side you want to be exact. Here the recipient gets exactly 5,000 NGN, and the API works out how many USD that costs:The response holds the
rate, any fee, and both amounts. A quote creates nothing, and creating the transaction with the same inputs charges the quoted amounts.6
Send the payout
Create a
WITHDRAW with the same inputs as the quote. Send only the amount you fixed, here destinationAmount, and let the API derive the other side.meta.reference is your own order ID, and meta.idempotencyKey is a fresh UUID for this attempt. Both must be unique in your business. If the request times out, retry with the same idempotency key so it can never create a second payout. See Idempotency.7
Check the result
The transaction starts as In a real integration, don’t poll. Listen for the
PENDING. In the sandbox it settles about 5 minutes later. Add SIMULATE_INSTANT anywhere in meta.reference to settle it in about 30 seconds.Look it up by your reference:TRANSACTION.UPDATED webhook and act on its status.Next steps
Planning to use webhooks? Allowlist these Afriex IP addresses on your server so webhook deliveries are not blocked:
See Webhook setup for full details.
Connecting the pieces
How customers, payment methods, and transactions fit together, with payloads for every transaction type.
Testing in Sandbox
Drive failures, OTPs, pending payouts, and webhooks before you go live.
Webhooks
Receive real-time notifications and verify their signatures.
API Reference
Explore all available endpoints and their parameters.
Step-by-step tutorial
Prefer a tutorial? Follow the blog walkthrough from signup to your first request.
