## Overview

Reservepay allows you to send payouts from your merchant balance to your own bank account or directly to your contacts. This guide covers how to manage your balance, set up payout destinations, and initiate transfers.

## Managing your balance

Before you can send funds, you need to have an available balance in your merchant account. You can check your current balance using the `get-balance` endpoint.

### Payout methods

You can send funds in two main ways:

1. **To your primary bank account**: Typically used for settling your own merchant funds.
2. **To a contact**: Send funds directly to a customer or partner via bank account, mobile number (PromptPay), or National ID (PromptPay).

## Sending payouts to your primary bank account

To receive funds into your own bank account, you must have configured a primary bank account during the merchabt onboarding.

### Initiate a payout

Once your primary bank account is set, you can send funds using `send-payout`.

```bash
curl -X POST https://api.reservepay.com/merchants/send-payout \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "amount": "10000",
    "external_id": "payout_001"
  }'
```

## Sending payouts to contacts

You can send funds directly to your contacts using the `send-payout-to-contact` endpoint.

### Payout destinations for contacts

When sending to a contact, you can specify the destination in several ways:

- **Bank account**: Use the contact's primary bank account by providing only the `recipient_id`.
- **Specific bank account**: Provide both `recipient_id` and `bank_account_id`.
- **New bank account**: Provide bank details (`bank_account_number`, `bank_account_name`, `bank_code`, `country_code`) to create and use a new account for the contact.
- **Mobile number (PromptPay)**: Set `payout_method` to `mobile_number` and provide the `mobile_number`.
- **National ID (PromptPay)**: Set `payout_method` to `national_id` and provide the `national_id` (13 digits).

### Example: Sending to a contact's mobile number

```bash
curl -X POST https://api.reservepay.com/merchants/send-payout-to-contact \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "recipient_id": "ctc_12345",
    "payout_method": "mobile_number",
    "mobile_number": "0812223333",
    "amount": "50000"
  }'
```

## Error handling

When sending funds, you should be prepared to handle common errors:

- `INSUFFICIENT_BALANCE`: Your merchant account doesn't have enough funds for the requested payout.
- `INVALID_MOBILE_NUMBER` / `INVALID_NATIONAL_ID`: The PromptPay details provided are incorrect.
- `NOT_FOUND`: The specified contact or bank account could not be found.
