> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yabetoopay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a Disbursement

> Create a disbursement to transfer funds from your account to a customer's account

## Prepare your request

The endpoint to use is `POST https://pay.sandbox.yabetoopay.com/v1/disbursements` for sandbox environment and `POST https://pay.api.yabetoopay.com/v1/disbursements` for production environment.

<Note>
  Secret key security: The secret key (secret\_key) must be kept confidential and
  must never be exposed in the frontend or client code. It must only be used on
  the server side.
</Note>

1. Use the secret key provided `secret_key` to authenticate yourself to the API. For security reasons, this key must only be used on the server side.
2. The request body should contain the following parameters:

```javascript theme={null}
{
    "amount": 10000,
    "currency": "XAF",
    "first_name": "Jean",
    "last_name": "Dupont",
    "payment_method_data": {
        "type": "momo",
        "momo": {
            "msisdn": "242066594471",
            "country": "CG",
            "operator_name": "mtn"
        }
    }
}
```

### Parameters

* `amount`: The amount to be paid
* `currency`: The currency of the payment
* `first_name`: The first name of the customer
* `last_name`: The last name of the customer
* `payment_method_data`: The payment method data
  * `type`: The type of payment method
  * `momo`: The momo payment method data
    * `msisdn`: The customer's phone number
    * `country`: The country code
    * `operator_name`: The operator name

## Create a Disbursement

```javascript theme={null}
{
  const response = await fetch(
    "https://pay.sandbox.yabetoopay.com/v1/disbursements",
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        Authorization: `Bearer ${secret_key}`,
      },
      body: JSON.stringify({
        amount: 10000,
        currency: "XAF",
        first_name: "Jean",
        last_name: "Dupont",
        payment_method_data: {
          type: "momo",
          momo: {
            msisdn: "242066594471",
            country: "CG",
            operator_name: "mtn",
          },
        },
      }),
    }
  );

  const data = await response.json();
  console.log(data);
}
```

## Response

### 200 OK

When the disbursement was successfully created, the API will return a 200 OK response with the following body:

The status of the disbursement is `processing` because the payment is still being processed and has not been executed yet.

```json theme={null}
{
  "amount": 1000,
  "currency": "xaf",
  "status": "processing",
  "firstName": "Jean",
  "lastName": "Dupont",
  "operatorName": "mtn",
  "country": "cg",
  "phone": "242066594470",
  "object": "disbursement",
  "type": 1,
  "shouldExecutedAt": "2025-03-18T09:24:57.555Z",
  "id": "wt_RMqehxy8NNi1ocJFG2SSAZMj81m6spo72vnZ",
  "createdAt": "2025-03-17T10:24:57.559+01:00",
  "updatedAt": "2025-03-17T10:24:57.559+01:00"
}
```

### 400 Bad Request

When the request is invalid, the API will return a 400 Bad Request response with the following body:

```json theme={null}
{
  "errors": [
    {
      "rule": "required",
      "field": "currency",
      "message": "required validation failed"
    }
  ]
}
```

### 401 Unauthorized

When the secret key is invalid, the API will return a 401 Unauthorized response with the following body:

```json theme={null}
{
  "message": "Unauthorized"
}
```
