Skip to main content
This guide takes you from a new API key to a settled payout in the sandbox. You create a customer, save the bank account you are paying, fund your sandbox balance, price the payout, and send it. No real money moves.
Want to see what the hosted checkout looks like before writing any code? Try the sandbox demo. No API key required.

Prerequisites

  • An Afriex Business account (sign up here)
  • A tool for making HTTP requests (cURL, Postman, or your preferred HTTP client)
Every request below goes to the sandbox at 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

  1. Log in to the Afriex Dashboard and switch the Test / Live toggle to Test.
  2. Go to Developer and open the API Keys tab.
  3. 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.
  4. Copy the key and store it securely.
Keep your API key on your server. Never put it in client-side code or a public repository. Test mode keys only work against the sandbox, and live mode keys only work against production.
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 institutionCode with List Institutions rather than hardcoding it:
Then create the payment method with an institutionCode and institutionName from that list:
Keep the paymentMethodId from the response.
In the sandbox, the last four digits of the account number choose what happens to payouts to it. 6789 succeeds. 0001 fails, and 0003 stays pending until you call /simulate. See Testing in Sandbox for every test value.
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 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:
In a real integration, don’t poll. Listen for the 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.

Support

Need help? Contact us at support@afriex.com.