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

# Validate an account

Before you send a payout, you can check that the destination exists and find out whose name is on it. `POST /payouts/validate_account` returns the account holder's name and whether the account is frozen or restricted.

This matters because a payout to a valid-looking but wrong number will often succeed. Validating first turns a silent misdirected payment into a question you can ask the user: *is this the right John Doe?*

> [!NOTE]
>
> Validation is a read-only lookup. It moves no money, creates no payout, and does not reserve anything.

## Request

```bash curl theme={"system"}
curl --request POST \
  --url https://api.sandbox.pesaswap.io/payouts/validate_account \
  --header "api-key: {{api_key}}" \
  --header "Content-Type: application/json" \
  --data '{
    "connector": "choicebank",
    "account_id": "254712345678",
    "account_type": "mobile_mpesa",
    "profile_id": "{{profile_id}}"
  }'
```

```javascript Node.js theme={"system"}
const response = await fetch(
  "https://api.sandbox.pesaswap.io/payouts/validate_account",
  {
    method: "POST",
    headers: {
      "api-key": "{{api_key}}",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      connector: "choicebank",
      account_id: "254712345678",
      account_type: "mobile_mpesa",
      profile_id: "{{profile_id}}",
    }),
  }
);

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

```python Python theme={"system"}
import requests

response = requests.post(
    "https://api.sandbox.pesaswap.io/payouts/validate_account",
    headers={
        "api-key": "{{api_key}}",
        "Content-Type": "application/json",
    },
    json={
        "connector": "choicebank",
        "account_id": "254712345678",
        "account_type": "mobile_mpesa",
        "profile_id": "{{profile_id}}",
    },
)

account = response.json()
print(account)
```

```php PHP theme={"system"}
<?php
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.sandbox.pesaswap.io/payouts/validate_account",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "api-key: {{api_key}}",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "connector" => "choicebank",
        "account_id" => "254712345678",
        "account_type" => "mobile_mpesa",
        "profile_id" => "{{profile_id}}",
    ]),
]);

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

echo $response;
```

| Field | Required | What it does |
| - | - | - |
| `connector` | Yes | Which connector performs the lookup. |
| `account_id` | Yes | What to look up — a phone number, bank account number, paybill or till. |
| `account_type` | Yes | The kind of account. See the table below. |
| `profile_id` | Yes | Used to find the connector credentials to validate with. |
| `bank_code` | Sometimes | Required for `pesalink`, and for every AICAPAY lookup. |
| `currency` | Sometimes | Required for Airtel, which resolves a country-specific endpoint from it. |
| `merchant_connector_id` | No | Pin the lookup to one specific connector account. |

> [!WARNING]
>
> The request rejects unknown fields outright. A typo in a field name is a `400`, not a silently ignored key.

## Response

```json theme={"system"}
{
  "account_type": "mobile_mpesa",
  "account_id": "254712345678",
  "account_name": "JOHN DOE",
  "freeze_status": "normal",
  "restrict_status": "normal"
}
```

| Field | What it means |
| - | - |
| `account_name` | The name the provider holds for the account. This is the field you came for. |
| `freeze_status` | `normal` or `frozen`. |
| `restrict_status` | `normal` or `restricted`. |

> [!WARNING]
>
> A `200` does not mean "safe to pay". It means the account was found. Check `freeze_status` and `restrict_status` yourself — a frozen or restricted account returns a perfectly successful response, and a payout to it will fail at the connector.

## What each connector supports

Validation rules differ per connector, and a mismatch is rejected before any network call:

| `connector` | Supported `account_type` | Also required |
| - | - | - |
| `choicebank` | `choice_merchant`, `mpesa_paybill`, `mpesa_till`, `mobile_mpesa`, `pesalink`, `imt_validate`, `airtel_money` | `bank_code` for `pesalink`; `currency` for `airtel_money` |
| `daraja` | Same as Choice Bank, including `imt_validate` | As above |
| `airtel` | `airtel_money` | `currency`, always |
| `cooperativebank` | `pesalink` only | `bank_code`, always |
| `aicapay` | `bank_account` | `bank_code`, always |
| `momomtn` | `momo_mtn` only | — |

> [!NOTE]
>
> Co-op supports M-Pesa payouts but **not** M-Pesa validation — Co-op has not provided a validation endpoint for it. Sending any `account_type` other than `pesalink` to `cooperativebank` returns a "not supported" error rather than attempting it.

### Account types

> [accordion] mobile\_mpesa
>
> A customer's M-Pesa number. The most common lookup — use it to confirm a recipient's name before a wallet payout.

> [accordion] mpesa\_paybill and mpesa\_till
>
> A business paybill or till number, rather than a personal wallet. Validate these before a `pay_bill` or `pay_till` payout.

> [accordion] pesalink
>
> A bank account reachable over PesaLink. Needs `bank_code` as well as `account_id` — the account number alone is ambiguous across banks. See [PesaPay bank codes](https://docs.pesaswap.io/api-reference/payouts/pesapay--bank-codes.md).

> [accordion] bank\_account
>
> A local bank account checked by name enquiry through AICAPAY. `bank_code` is always required.

> [accordion] airtel\_money
>
> An Airtel Money wallet. `currency` is required, because Airtel runs a separate endpoint per country.

> [accordion] momo\_mtn
>
> An MTN MoMo account, checked through MTN's own subscriber lookup. Only the `momomtn` connector serves it.

> [accordion] imt\_validate
>
> An international money transfer recipient. Only `choicebank` and `daraja` can serve this — any other connector returns a "not supported" error.

## M-Pesa validation

Validating an M-Pesa account with `connector: "daraja"` works, but the lookup itself does not go to Safaricom. Daraja has no account-validation API, so Pesaswap routes M-Pesa name checks through Choice Bank's verification service using Pesaswap's own credentials.

Two consequences:

* **You do not need a Choice Bank account** to validate M-Pesa numbers. It works whether your payouts run through Choice Bank or Daraja.
* **M-Pesa validation depends on a third party.** If Choice Bank's verification service is down, M-Pesa name lookups fail even though M-Pesa payouts themselves are fine. Removing this dependency is [on our roadmap](https://docs.pesaswap.io/essentials/roadmap.md).

The same pattern applies to Airtel Money: validating an Airtel number through a non-Airtel connector such as Choice Bank uses Pesaswap's global Airtel credentials. But if you set `connector: "airtel"` directly, your own Airtel connector account is required.

## Common errors

> [accordion] Missing bank\_code
>
> `pesalink` lookups, every `cooperativebank` lookup and every `aicapay` lookup need `bank_code`. The request fails validation before any connector is contacted.

> [accordion] Missing currency on Airtel
>
> Airtel resolves which country's endpoint to call from `currency`. Omitting it fails immediately. `connector: "choicebank"` with `account_type: "airtel_money"` needs it too, since that lookup is handed to Airtel.

> [accordion] Account type not supported for connector
>
> Each row of the table above is enforced. `imt_validate` on anything but Choice Bank or Daraja, any non-`pesalink` type on Co-op, or any non-`momo_mtn` type on MTN all return this.

> [accordion] Treating a frozen account as payable
>
> `freeze_status: "frozen"` or `restrict_status: "restricted"` arrives inside a `200`. If your code only checks the HTTP status, it will send a payout that cannot land.

> [accordion] Showing the returned name without a confirmation step
>
> The value of validation is a human confirming the name. Fetching `account_name` and sending anyway gets you the same misdirected payout, one API call later.

## Next steps

> [card] [Payouts](https://docs.pesaswap.io/essentials/payments-guide/payouts.md)
>
> Send the payout once the account checks out.

> [card] [Wallet balance](https://docs.pesaswap.io/essentials/payments-guide/wallet-balance.md)
>
> Confirm you have the funds to send.

> [card] [Supported connectors](https://docs.pesaswap.io/essentials/explore-pesaswap/payment-orchestration/accept-payments/connectors/supported-connectors.md)
>
> Which connectors support which flows.

> [card] [Roadmap](https://docs.pesaswap.io/essentials/roadmap.md)
>
> What we are building next.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.