Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.afriex.com/llms.txt

Use this file to discover all available pages before exploring further.

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.

Environments

The Afriex API provides two environments:
EnvironmentBase URLPurpose
Staginghttps://sandbox.api.afriex.comTesting and development
Productionhttps://api.afriex.comLive transactions
Never use production API keys in your testing environment.

Authentication

All API requests require authentication using your API key in the x-api-key header:
curl -H "x-api-key: YOUR_API_KEY" \
  https://sandbox.api.afriex.com/api/v1/customer

Idempotency

For critical operations like creating transactions, use idempotency keys to prevent duplicate processing:
{
  "customerId": "CUSTOMER_ID",
  "type": "WITHDRAW",
  "sourceAmount": "10",
  "destinationAmount": 5000,
  "sourceCurrency": "USD",
  "destinationCurrency": "NGN",
  "destinationId": "PAYMENT_METHOD_ID",
  "meta": {
    "idempotencyKey": "unique-key-123",
    "reference": "YOUR_REFERENCE"
  }
}

Error Handling

The API uses standard HTTP status codes:
StatusMeaning
200Success
201Created
204No Content - Successful deletion, no body returned
400Bad Request - Check your request payload
401Unauthorized - Invalid or missing API key
404Not Found - Resource doesn’t exist
429Too Many Requests - Rate limit exceeded
500Server Error - Contact support

Error response format

All error responses follow a consistent structure:
{
  "code": "INVALID_BUSINESS_CUSTOMER_REQUEST",
  "error": "Bad Request",
  "details": {
    "errorMessage": "PHONE_COUNTRY_MISMATCH",
    "friendlyMessage": "The phone number does not match the customer's country."
  }
}
FieldDescription
codeMachine-readable error code for programmatic handling
errorShort human-readable error category
details.errorMessageSpecific reason for the error
details.friendlyMessageUser-friendly message suitable for displaying to end users
Use the details.friendlyMessage field to surface errors directly to your users, and use code for programmatic error handling in your application logic.

Pagination

List endpoints support pagination with page and limit parameters:
curl -H "x-api-key: YOUR_API_KEY" \
  "https://sandbox.api.afriex.com/api/v1/customer?page=0&limit=10"
ParameterTypeDefaultDescription
pageinteger0Page number, zero-indexed (first page = 0)
limitinteger10Number of results per page (max 100)
All list endpoints return results in this shape:
{
  "page": 0,
  "total": 20,
  "data": []
}
Use the total field to calculate the number of pages: Math.ceil(total / limit).

Webhook Integration

Set up webhooks to receive real-time event notifications:
  1. Configure your webhook URL in the Dashboard
  2. Verify the x-webhook-signature header (RSA-SHA256, base64) using the raw request body
  3. Use the webhook public key from Dashboard -> Developers -> Webhooks (staging and production keys are different)
  4. Return 200 quickly after successful verification and processing
If signature verification fails, return 400 or 401. Afriex retries failed deliveries up to 12 times 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:
  • Implement exponential backoff for retries
  • Cache exchange rates and other static data
  • Use webhooks instead of polling for status updates

Testing Your Integration

1

Test in Staging

Use the staging environment to test all API calls without affecting live data.
2

Verify Webhooks

Test webhook handling with the staging environment events.
3

Go Live

Switch to production base URL and API keys when ready.

Support

Need help with your integration? Contact us at support@afriex.com.