Integration Guide
This guide covers best practices for integrating the Afriex Business API into your application.OpenAPI spec
Get the full OpenAPI spec at this endpoint for code generation, SDKs, and API tooling.
MCP server
Add the Afriex Business API to your MCP client and search the docs from Cursor, Claude Code, and other MCP-enabled tools.
Postman collection
Import every endpoint into Postman, with sandbox example requests and API key auth already set up.
Environments
The Afriex API provides two environments:Authentication
All API requests require authentication using your API key in thex-api-key header:
Using Postman
The Postman collection is generated from the same OpenAPI spec as this API reference, so it always lists the current endpoints, parameters, and example requests.apiKey, and send any request. Every request sends the key in the x-api-key header, and requests go to the sandbox by default. To keep your key in an environment instead, or to switch to production, fork the Afriex Sandbox and Afriex Production environments from the Afriex Postman workspace.
Each request comes with an example body. Optional query parameters are included but switched off, so tick the ones you want to use.
Using the Postman desktop app? Your fork appears there automatically once you’re signed in with the same account. Or skip the browser: click Import in the app and paste the link below.
Importing by link
To import the collection instead of forking it, click Import in Postman and paste this link:apiKey to your sandbox API key in a Postman environment. Requests go to the sandbox by default; for production, also set baseUrl to https://api.afriex.com in that environment.
Amounts
Transaction amounts are decimal values in the currency’s main unit. AsourceAmount of "10" in USD is ten US dollars, not ten cents.
- Send amounts as numeric strings, such as
"10"or"100.50". The API also accepts numbers, but strings keep floating-point rounding out of your code. - Responses and webhooks return amounts as strings. Parse them with a decimal type, not a float.
- Checkout sessions are the exception. Their
amountis in minor units, such as kobo or cents. See Create checkout session.
Idempotency
Creating a transaction takes ameta.idempotencyKey and a meta.reference. Both must be unique in your business, so a retry can never create a second transaction:
409 DUPLICATE_REQUEST and creates nothing. See Idempotency for what a duplicate returns, how to recover after a timeout, and why a failed swap needs a new key.
Error Handling
Every error has the same shape: a machine-readablecode to branch on, and details.friendlyMessage, which says what was wrong with this request.
429, 500, 503, and requests that time out, with backoff. Don’t retry the other 4xx errors until you change the request. See Errors for every status and what to do about it.
Pagination
List endpoints take a zero-basedpage and a limit of up to 100, and return {data, total, page}:
Webhook Integration
Set up webhooks to receive real-time event notifications:- Configure your webhook URL in the Dashboard
- Verify the
x-webhook-signatureheader (ECDSA P-384 with SHA-256, DER signature, base64) using the raw request body. The key is not RSA. See Security and signature validation - Use the webhook public key from Developer → Webhook in the Dashboard (sandbox and production keys are different)
- Return
200quickly after successful verification and processing
400 or 401. Afriex makes up to 12 delivery attempts, the first one and then up to 11 retries, with exponential backoff starting at 30 seconds.
Webhook Documentation
Learn more about webhook setup, security, and event types.
Rate Limiting
Be mindful of rate limits when making API calls:- Wait for
Retry-Afterbefore you retry a429, and back off on500and503 - Cache exchange rates and other static data
- Use webhooks to learn about status changes
429.
Testing Your Integration
1
Test in sandbox
Use the sandbox environment to test all API calls without affecting live data.
2
Verify Webhooks
Test webhook handling with the sandbox environment events.
3
Go Live
Work through the go-live checklist. Besides the base URL and API key, the webhook public key and the webhook IP address change in production.
