Skip to main content

Integration Guide

This guide covers best practices for integrating the Afriex Business API into your application.

Environments

The Afriex API provides two environments:
EnvironmentBase URLPurpose
Staginghttps://staging.afx-server.comTesting and development
Productionhttps://prod.afx-server.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://staging.afx-server.com/api/v1/customer

Idempotency

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

Error Handling

The API uses standard HTTP status codes:
StatusMeaning
200Success
201Created
400Bad Request - Check your request payload
401Unauthorized - Invalid API key
404Not Found - Resource doesn’t exist
500Server Error - Contact support

Pagination

List endpoints support pagination with page and limit parameters:
curl -H "x-api-key: YOUR_API_KEY" \
  "https://staging.afx-server.com/api/v1/customer?page=0&limit=10"

Webhook Integration

Set up webhooks to receive real-time event notifications:
  1. Configure your webhook URL in the Dashboard
  2. Verify webhook signatures using our public key
  3. Return a 2xx status code to acknowledge receipt

Webhook Documentation

Learn more about webhook events and security.

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.