What this guide covers
If you’ve read the quickstart but aren’t sure exactly which ID goes where, or why you need to create three different things before money can move, this guide is for you. The Afriex Business API has three core building blocks. They must be created in order, and each one produces an ID that the next step needs. This guide explains what each building block is, what ID it gives you, and exactly where that ID is used.The big picture
Think of it like this: a Customer is the person your business is acting on behalf of (the sender or originator). A Payment Method holds the account details of the person being paid (the recipient). A Transaction is the instruction to move money, and it needs to know on whose behalf you are acting and which recipient account to use. Here is how the IDs connect:ID quick-reference
| ID field | Belongs to | Used in |
|---|---|---|
customerId | Customer | Payment Method creation, Transaction creation |
paymentMethodId | Payment Method | Transaction as destinationId or sourceId |
destinationId | Transaction field | Equals a paymentMethodId (used in WITHDRAW) |
sourceId | Transaction field | Equals a paymentMethodId (used in DEPOSIT) |
transactionId | Transaction | Status lookups, webhook events |
Each building block explained
Customer
What it is: A Customer is the person or business your business is acting on behalf of. They are the originator or sender of the transaction, not the recipient. For example, if your platform processes payroll for a company, each employee whose salary you send out is a Customer. The Customer record stores their identity information (name, email, phone, country) and is used to attribute transactions to the right person in your system. What ID it gives you:customerId
When you use that ID:
- Pass it as
customerIdwhen creating a Payment Method (to link the account to this person) - Pass it as
customerIdwhen creating a Transaction (to identify whose account is involved)
| Field | Required | Example |
|---|---|---|
fullName | Yes | "Amara Osei" |
email | Yes | "amara@example.com" |
phone | Yes | "+233201234567" (E.164 format) |
countryCode | Yes | "GH" (ISO 3166-1 alpha-2) |
Payment Method
What it is: A Payment Method holds the account details of the person being paid or collected from: their bank account, mobile money wallet, or other financial account. It is linked to a Customer (the originator on whose behalf you are acting), but the account details it contains belong to the end recipient. You need a Payment Method before you can send or receive money, because the Transaction needs to know exactly which account to credit or debit. What ID it gives you:paymentMethodId
When you use that ID:
- As
destinationIdin a WITHDRAW transaction (the account the money is sent to) - As
sourceIdin a DEPOSIT transaction (the account the money is pulled from)
A Payment Method has a
type field, either WITHDRAW (can receive funds) or DEPOSIT (can send funds). Make sure you create the right type for the transaction you plan to run.| Channel | Description | Common use case |
|---|---|---|
BANK_ACCOUNT | Local bank transfer | Payout to Nigerian GTBank, Kenyan KCB |
MOBILE_MONEY | Mobile wallet | Payout to MTN MoMo, M-Pesa, Airtel Money |
SWIFT | International wire transfer | Cross-border payouts to Europe, US |
UPI | Unified Payments Interface | Payouts to India |
INTERAC | Interac e-Transfer | Payouts to Canada |
WE_CHAT | WeChat Pay | Payouts to China |
VIRTUAL_BANK_ACCOUNT | Afriex-issued virtual account | Receive deposits (production only) |
CRYPTO_WALLET | Crypto wallet | Crypto payouts (production only) |
Transaction
What it is: A Transaction is the actual instruction to move money. It references a Customer and (depending on the type) one of their Payment Methods. What ID it gives you:transactionId
When you use that ID:
- To check the status:
GET /api/v1/transaction/{transactionId} - It appears in webhook events so you can match notifications to records in your system
| Type | What it does | Payment method needed |
|---|---|---|
WITHDRAW | Send money from your Afriex wallet to a customer’s account | destinationId (= paymentMethodId) |
DEPOSIT | Pull money from a customer’s account into your Afriex wallet | sourceId (= paymentMethodId) |
SWAP | Convert currency within your Afriex wallet | None |
WITHDRAW: Your business wallet is the implicit source. Afriex debits your wallet automatically. You do not specify a source payment method.DEPOSIT: Your business wallet is the implicit destination. Afriex credits your wallet automatically. You do not specify a destination payment method.SWAP: Both source and destination are your business wallet. No customer or payment method IDs are needed at all.
The 3-step integration sequence
Here is the exact order of operations, with the IDs flowing from one step to the next.Create the Customer
Register the person on whose behalf the transaction is being made (the originator or sender).Save the
customerId from the response. You need it in the next step.Create the Payment Method
Register the recipient’s bank account or mobile wallet (the account the money will be sent to or collected from). Link it to the Customer from Step 1 by passing their Then create the payment method using the Save the
customerId.First, look up the correct institution code for the customer’s bank or mobile provider:institutionCode and institutionName from that response:paymentMethodId from the response. This is what goes into destinationId (or sourceId) in your transaction.Transaction type payloads side by side
What changes between each type
| Field | WITHDRAW | DEPOSIT | SWAP |
|---|---|---|---|
customerId | Required | Required | Not required |
destinationId | Required (= paymentMethodId) | Not used | Not used |
sourceId | Not used | Required (= paymentMethodId) | Not used |
destinationAmount | Required | Required | Optional (API calculates it at live rate) |
meta.idempotencyKey | Required | Required | Required |
meta.reference | Required | Required | Required |
Payment method fields by channel
Different payment channels require different fields. Use the sections below to find the exact payload shape for your channel.BANK_ACCOUNT: Local bank transfer
BANK_ACCOUNT: Local bank transfer
Required fields:
customerId, channel, accountName, accountNumber, countryCode, institution.institutionCode, institution.institutionNameLook up valid institution codes first: List InstitutionsYou can also verify the account holder name before creating: Resolve Payment MethodMOBILE_MONEY: M-Pesa, MTN MoMo, Airtel, etc.
MOBILE_MONEY: M-Pesa, MTN MoMo, Airtel, etc.
Required fields:
customerId, channel, accountName, accountNumber (the mobile number), countryCode, institution.institutionCode, institution.institutionNameLook up valid institution codes for the country: List InstitutionsSWIFT: International wire transfer
SWIFT: International wire transfer
Required fields:
customerId, channel, accountName, accountNumber (IBAN or account number), countryCode, institution.institutionCode (SWIFT/BIC), institution.institutionName, institution.institutionAddress, recipient.recipientAddressUse Institution Codes to resolve a SWIFT code to a bank name.UPI: India
UPI: India
Required fields:
customerId, channel, accountName, accountNumber (UPI ID / VPA), countryCode, institution.institutionCode ("UPI"), institution.institutionName ("UPI"), recipient.recipientPhoneINTERAC: Canada
INTERAC: Canada
Required fields:
customerId, channel, accountName, accountNumber (the email address registered for Interac), countryCode, institution.institutionCode ("INTERAC"), institution.institutionName ("INTERAC"), recipient.recipientEmailWE_CHAT: China
WE_CHAT: China
Required fields:
customerId, channel, accountName, accountNumber (phone number), countryCode, institution.institutionCode ("WECHAT"), institution.institutionName ("WECHAT"), recipient.recipientPhoneInstitution fields: which one to use and when
Theinstitution object has several fields that look similar. Here is exactly what each one is and when you need it.
| Field | What it is | When you need it |
|---|---|---|
institutionCode | Short identifier for the bank or provider (e.g. "058" for GTBank Nigeria, "MTN" for MTN Ghana) | Always required when creating a Payment Method |
institutionName | Human-readable display name (e.g. "GTBank", "MTN") | Always required when creating a Payment Method |
institutionId | Afriex’s internal database ID for the institution | Output only. Never pass this as input. It appears in responses but is not needed for creation. |
institutionAddress | Physical address of the institution | Only for SWIFT transfers. Skip it for all other channels. |
How to find the right institutionCode
- Call
GET /api/v1/payment-method/institution?channel=BANK_ACCOUNT&countryCode=NG - The response returns a list of institutions, each with
institutionCodeandinstitutionName - Copy those values directly into your Payment Method creation request
GET /api/v1/payment-method/institution/codes to resolve a known SWIFT/BIC code to a bank name.
The meta object
Every transaction must include ameta object with two required fields. Without them, the API returns a 400 error.
| Field | Required | What it does |
|---|---|---|
idempotencyKey | Yes | A unique string you generate per transaction attempt. If you retry a failed request with the same key, Afriex returns the original transaction instead of creating a duplicate. Use a UUID v4. |
reference | Yes | Your own internal ID for this transaction (e.g. order number, payment ID, or invoice reference). Used for reconciliation. |
narration | No | A human-readable description (e.g. "Salary payment for March 2025"). |
merchantId | No | Your internal merchant or business unit identifier. |
invoice | No | A base64-encoded invoice document to attach to the transaction. |
Common mistakes
1. Using a customerId as destinationId or sourceId
destinationId and sourceId must be a paymentMethodId, not a customerId. Both look like hex strings, which makes it easy to mix them up.
2. Skipping the 3-step sequence
You cannot create a Transaction without first creating a Customer and a Payment Method. The API returns a404 or 400 if either does not exist. Always follow: Customer → Payment Method → Transaction.
3. Mixing up DEPOSIT and WITHDRAW fields
- WITHDRAW uses
destinationId(where the money goes) - DEPOSIT uses
sourceId(where the money comes from)
destinationId on a DEPOSIT (or sourceId on a WITHDRAW) will cause the API to reject the request.
4. Assuming SWAP needs a payment method
SWAP does not touch any external account. It converts currency inside your Afriex business wallet. NocustomerId, destinationId, or sourceId is needed. Only the currency pair and the meta object are required.
5. Omitting meta.idempotencyKey or meta.reference
Both are required on every transaction. The API returns a400 if either is missing. Always generate a fresh UUID for idempotencyKey and use your own internal order or payment ID as reference.
6. Hardcoding institution codes without looking them up
Do not guess institution codes. UseGET /api/v1/payment-method/institution?channel=BANK_ACCOUNT&countryCode=NG to get the correct code for each country and channel. The same bank can have a different code in different countries.
7. Passing institutionId as input
institutionId is an output field. It appears in API responses but you never need to supply it when creating a Payment Method. The fields you pass are institutionCode and institutionName.
Tracking what happens after you create a transaction
Transactions do not complete instantly. After creation the status will bePENDING or PROCESSING. Here is how to know when it finishes.
Option A (recommended): Webhooks
Subscribe to TRANSACTION.UPDATED events. When the transaction reaches a terminal status, Afriex sends an HTTP POST to your webhook URL with the full transaction payload.
See Webhook setup for configuration steps and payload examples.
Option B: Poll the status endpoint
Terminal statuses
| Status | Meaning |
|---|---|
COMPLETED / SUCCESS | Transaction finished successfully |
FAILED | Transaction could not be processed |
CANCELLED | Cancelled before processing started |
REFUNDED | Funds returned to the sender |
REJECTED | Rejected after manual review |
Next steps
Quickstart
Make your first API call in under 5 minutes.
Create a Customer
Full parameter reference for customer creation.
Create a Payment Method
All channels and required fields in the API reference.
Create a Transaction
Full transaction creation reference with all fields.
Data Model Reference
Complete field-by-field documentation for all models.
Webhooks
Receive real-time transaction status updates.
