Skip to content

Automated Bulk Disbursements

Efficiently process salaries, rewards, and vendor payments to thousands of recipients securely.

Sending money to one person is easy. Sending money to 1,000 employees or contest winners requires robustness, validation, and error handling. This guide uses the Transfer API, Validate Name API, and Account Status API to build a secure disbursement engine.

Prefer one request? Use the Bulk payouts API

You can send up to 500 payouts in a single request. Moolre validates every row, sends the items in the background, reports each result and posts bulk_payout.completed when the batch is final. The loop below is still the right tool when you need per-recipient name checks or custom retry rules.

Read the Bulk payouts guide

Overview

A robust payout system shouldn't just "fire and forget". It needs to verify the recipient identity before sending funds to prevent irreversible errors.

Check Balance
Validate Name
Transfer Funds

Step 1: Validation

Before initiating any transfer, use the Validate Name endpoint. This returns the registered name on the mobile money or bank account. Comparing this against your internal records (e.g., HR database) helps prevent costly, irreversible payouts caused by typos in phone numbers.

Step 2: Execution

Iterate through your list of recipients. It's recommended to process these serially or in small batches to avoid hitting rate limits and to make error tracking easier.

const axios = require('axios');​// Mock Data: List of recipients (e.g., from a CSV)const recipients = [    { name: 'John Doe', number: '233244000001', amount: 100, network: '1' }, // 1 = MTN    { name: 'Jane Smith', number: '233200000002', amount: 150, network: '6' } // 6 = Telecel];​async function processPayroll() {    const headers = {         'X-API-KEY': process.env.API_KEY,         'X-API-USER': process.env.API_USER     };​    // 1. Check Balance First    const balanceRes = await axios.post('https://api.moolre.com/open/account/status',         { type: 1, accountnumber: process.env.ACCOUNT_NUM }, { headers });        const balance = balanceRes.data.data.balance;    const totalNeeded = recipients.reduce((sum, r) => sum + r.amount, 0);​    if (balance < totalNeeded) {        console.error("Insufficient Balance!");        return;    }​    // 2. Process Each Recipient    for (const person of recipients) {        try {            // A. Validate Name (Security Check)            const validateRes = await axios.post('https://api.moolre.com/open/transact/validate', {                type: 1,                receiver: person.number,                channel: person.network,                currency: 'GHS',                accountnumber: process.env.ACCOUNT_NUM            }, { headers });​            const registeredName = validateRes.data.data; // e.g., "JOHN KWAME DOE"                        // Simple fuzzy match check (optional but recommended)            if (!registeredName.includes(person.name.toUpperCase().split(' ')[0])) {                console.warn(`Name Mismatch for ${person.number}. Skipped.`);                continue;            }​            // B. Initiate Transfer            const transferRes = await axios.post('https://api.moolre.com/open/transact/transfer', {                type: 1,                channel: person.network,                currency: 'GHS',                amount: person.amount,                receiver: person.number,                externalref: `SALARY_${Date.now()}_${person.number}`,                accountnumber: process.env.ACCOUNT_NUM            }, { headers });​            console.log(`Paid ${person.name}: ${transferRes.data.message}`);​        } catch (error) {            console.error(`Failed to pay ${person.name}`, error.response?.data || error.message);            // Add to retry queue...        }    }}​processPayroll();

Error handling

  • Insufficient Balance: Always check your wallet balance via Account Status API before starting the batch.
  • Network Failures: If a transfer request times out, do not immediately retry. Check the Transfer Status using your externalref to see if it actually went through.
  • Idempotency: Ensure your externalref is unique for every transaction. If you retry a transaction with the same externalref, Moolre will prevent duplicate deductions.