# Mass Payout

## Batch disburse to multiple destinations

When you need to process multiple payouts based on a schedule, Moneywave provides a single API for submitting a payout schedule. You can send money to over five hundred beneficiaries in the same currency.  Payouts are queued, processed and send notifications when completed. Mass Payouts required an active balance as source of disbursements.

{% hint style="info" %}
Setup an **Active Balance** for your payouts [here](https://moneywave.gitbook.io/doc/funding-for-payout)
{% endhint %}

## Disburse - Batch

<mark style="color:green;">`POST`</mark> `https://staging.moneywaveapp.com/v1/disburse/queue`

Destinations and Amounts are passed as an Array.

#### Headers

| Name          | Type   | Description           |
| ------------- | ------ | --------------------- |
| Authorization | string | Authorization TokenAA |

#### Request Body

| Name         | Type    | Description                                         |
| ------------ | ------- | --------------------------------------------------- |
| instantQueue | boolean | Process schedule immediately or submit only         |
| name         | string  | Batch or Schedule name                              |
| ref          | string  | Unique Batch or Schedule reference                  |
| senderName   | string  | Sender / Business name to appear in bank statement  |
| lock         | string  | Password required to access active balance (wallet) |
| currency     | string  | Payout currency for all recipients                  |
| recipients   | array   | An array of payout details for each recipient       |

{% tabs %}
{% tab title="200 Batch ID is returned indicating payout submitted for processing." %}

```
{ "status": "success", "data": { "batchId": 256, "message": "Disbursement queued for processing." } }
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
A reference is required for the batch and a different reference is required for each payout. All references must be unique.
{% endhint %}

The recipients Array would include the transfer details for each payout, see sample values  in the code snippet below. Individual recipient format is described in single payout requirements.

{% tabs %}
{% tab title="Sample Code" %}

```
Select a Language above ...
```

{% endtab %}

{% tab title="Node.JS" %}

```javascript
var unirest = require("unirest");
var base_url = "https://staging.moneywaveapp.com";
var req = unirest("POST", `${base_url}/v1/disburse/queue`);

req.headers({
  "Authorization": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwibmFtZSI6IlRocml2ZSIsImFjY291bnROdW1iZXIiOiIwNjkwMDAwMDAiLCJiYW5rQ29kZSI6IjMwNyIsImlzQWN0aXZlIjp0cnVlLCJlbnZpcm9ubWVudCI6ImxpdmUiLCJjYW5fZ29saXZlIjp0cnVlLCJjb3VudGRvd24iOm51bGwsImNvbXBsaWFuY2UiOjAsImNvZGUiOiJNMSIsInBvc0lkIjoiUDEiLCJlYmlsbElkIjpudWxsLCJpcCI6bnVsbCwiY3JlYXRlZEF0IjoiMjAxNi0wOS0xNlQxMzo0OToyMy4wMDBaIiwidXBkYXRlZEF0IjoiMjAxOC0wMi0wOVQxNDozMDo0Ny4wMDBaIiwiZGVsZXRlZEF0IjpudWxsLCJpYXQiOjE1MzAwMzA2OTcsImV4cCI6MTUzMDAzNzg5N30.zsMrcFJPpg2-H_b3Hr3Rn7pqaQhdYSGTpxO8wPR6TUg",
  "Content-Type": "application/json"
});
req.type("json");
req.send({
  "instantQueue": true,
  "name": "Batch Schedule Oct 1",
  "ref": "BS101823",
  "senderName": "ABCompany",
  "lock": "walpassword",
  "currency": "NGN",
  "recipients": [
    {
      "accountNumber": "0600000004",
      "bankcode": "044",
      "amount": "5000",
      "ref": "TX32567MV",
      "narration": "Call airtime",
    },
    {
      "accountNumber": "0690000005",
      "bankcode": "044",
      "amount": "30500",
      "ref": "TX32568MV",
      "narration": "Building materials",
    }
  ]
});

req.end(function (res) {
  if (res.error) console.log(res.code, res.body);
  else console.log(res.body);
});
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();
$base_url = "https://staging.moneywaveapp.com";
$header = array(
  "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwibmFtZSI6IlRocml2ZSIsImFjY291bnROdW1iZXIiOiIwNjkwMDAwMDAiLCJiYW5rQ29kZSI6IjMwNyIsImlzQWN0aXZlIjp0cnVlLCJlbnZpcm9ubWVudCI6ImxpdmUiLCJjYW5fZ29saXZlIjp0cnVlLCJjb3VudGRvd24iOm51bGwsImNvbXBsaWFuY2UiOjgsImNvZGUiOiJNTDU4MCIsInBvc0lkIjoiMTE0NjMiLCJlYmlsbElkIjoiTVRGVyIsImlwIjpudWxsLCJjcmVhdGVkQXQiOiIyMDE2LTA5LTE2VDEzOjQ5OjIzLjAwMFoiLCJ1cGRhdGVkQXQiOiIyMDE3LTA3LTE5VDE0OjA2OjM2LjAwMFoiLCJkZWxldGVkQXQiOm51bGwsImlhdCI6MTUzMDIxMDY4MywiZXhwIjoxNTMwMjE3ODgzfQ.IO4iX_estdWbe2dHey27bj5xsZC0skXHGdFUMTQSJfI",
  "Content-Type: application/json",
);

$body = array(
  "instantQueue" => true,
  "name" => "Batch Schedule Oct 1",
  "ref" => "BS101823",
  "senderName" => "ABCompany",
  "lock" => "walpassword",
  "currency" => "NGN",
  "recipients" => array(
    array(
      "accountNumber" => "0600000004",
      "bankcode" => "044",
      "amount" => "5000",
      "ref" => "TX32567MV",
      "narration" => "Call airtime",
    ),
    array(
      "accountNumber" => "0690000005",
      "bankcode" => "044",
      "amount" => "30500",
      "ref" => "TX32568MV",
      "narration" => "Building materials",
    )
  )
);

curl_setopt_array($curl, array(
  CURLOPT_URL => $base_url . "/v1/disburse/queue",
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 180,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_POSTFIELDS => json_encode($body),
  CURLOPT_HTTPHEADER => $header,
));

$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);


if ($err) {
  echo "cURL Error #:" . $err;
} else {
  $decodedResponse = json_decode($response, true);

  echo "<pre>"; print_r($decodedResponse);
}
```

{% endtab %}
{% endtabs %}

## Confirming Success

When each payout in a batch is processed, a callback notification is sent to your endpoint. This url is setup on your moneywave profile. See Batch payout [notification](https://moneywave.gitbook.io/doc/notifications/mass-payouts) for additional details.&#x20;

A disbursement is successful only when the callback parameters has the value below

```
"responsecode" : "00"
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://moneywave.gitbook.io/doc/send-money-to-people/mass-payout.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
