## Afriex SDK

### TypeScript

```typescript
const response = await afriex.paymentMethods.listVirtualAccounts({
  customerId: "customer-id",
  currency: "USD",
});
```

```bash
curl --request GET \
  --url https://sandbox.api.afriex.com/api/v1/payment-method/virtual-account \
  --header 'x-api-key: <api-key>'
```

```python
import requests

url = "https://sandbox.api.afriex.com/api/v1/payment-method/virtual-account"

headers = {"x-api-key": "<api-key>"}

response = requests.get(url, headers=headers)

print(response.text)
```

```javascript
const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};

fetch('https://sandbox.api.afriex.com/api/v1/payment-method/virtual-account', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://sandbox.api.afriex.com/api/v1/payment-method/virtual-account",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "x-api-key: <api-key>"
  ],
]);

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

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
?>
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

url := "https://sandbox.api.afriex.com/api/v1/payment-method/virtual-account"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("x-api-key", "<api-key>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}
```

```java
HttpResponse<String> response = Unirest.get("https://sandbox.api.afriex.com/api/v1/payment-method/virtual-account")
  .header("x-api-key", "<api-key>")
  .asString();
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://sandbox.api.afriex.com/api/v1/payment-method/virtual-account")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'

response = http.request(request)
puts response.read_body
```

### Response Structure

200

twoNgnAccounts

```json
{
  "data": [
    {
      "paymentMethodId": "690cc5bbe2a1143ff6070119",
      "channel": "VIRTUAL_BANK_ACCOUNT",
      "customerId": "68e6717848e1f632e9686460",
      "institution": {
        "institutionName": "FIDELITY BANK"
      },
      "accountName": "Lily New",
      "accountNumber": "3820404958",
      "countryCode": "NG"
    },
    {
      "paymentMethodId": "690cc5bbe2a1143ff607011a",
      "channel": "VIRTUAL_BANK_ACCOUNT",
      "customerId": "68e6717848e1f632e9686460",
      "institution": {
        "institutionName": "FIDELITY BANK"
      },
      "accountName": "Lily New (Sales)",
      "accountNumber": "3820404971",
      "countryCode": "NG"
    }
  ],
  "total": 2,
  "page": 0
}
```

### Overview

Returns every active virtual account for the resolved customer or owner and currency. The endpoint is read-only: when no virtual account exists, you get a `200` response with `data: []` rather than `404`. Pass `customerId` to scope the list to a specific end-user. Omit it to list virtual accounts that belong to the business owner. **Important:** Virtual accounts are **only active in production** and do **not work on staging/dev**.

Want to see virtual accounts in action? Learn how to build payment links using them: [https://dev.to/afriex/send-a-link-get-paid-building-payment-links-with-afriex-13ak](https://dev.to/afriex/send-a-link-get-paid-building-payment-links-with-afriex-13ak)

---

## Breaking change from earlier versions

Previously this endpoint returned a single virtual account and would create one on the fly when none existed. It now returns a list and never creates. The behaviour has been split into three explicit endpoints:

| Endpoint                                   | What it does                                                                 |
|-------------------------------------------|------------------------------------------------------------------------------|
| `GET /api/v1/payment-method/virtual-account` | Lists existing virtual accounts (this page). Read-only.                     |
| `POST /api/v1/payment-method/virtual-account`| Creates a new virtual account. See [Create Virtual Account](https://docs.afriex.com/api-reference/endpoint/payment-methods/virtual-account-create). |
| `GET /api/v1/payment-method/pool-account`    | Returns the business pool account for a country. See [Get Pool Account](https://docs.afriex.com/api-reference/endpoint/payment-methods/pool-account). |

If you were relying on the get-or-create behaviour, call `GET` first; when `data` is empty, follow up with `POST` to create one.

---

## Virtual accounts are for end customers

Virtual accounts are designed for your **customers as end users**, meaning the people your business is acting on behalf of. Each virtual account is linked to a `customerId` (or to the business owner if no `customerId` is provided). Payments received into a virtual account are attributed to the associated customer in your Afriex system. Make sure you have created a Customer record before listing or creating virtual accounts for that person. See [Create Customer](https://docs.afriex.com/api-reference/endpoint/customers/create).

### Authorizations

#### x-api-key

A static business API key issued from the dashboard. A business can provision multiple API keys, each scoped to a configurable set of permissions (e.g. read transactions, create deposits, etc). Permissions are chosen per key at creation time in the dashboard and may be revoked by deleting the key. Requests made with a key that does not include the permission required by the target endpoint will be rejected with a `403 Forbidden` response; an unrecognised, malformed, or revoked key returns `401 Unauthorized`. Manage your keys and their permissions under Developer → API keys in the dashboard.

### Headers

#### x-api-version

API version in ISO 8601 format (e.g. 2025-12-28). Defaults to latest stable.

### Query Parameters

#### currency

The 3-letter ISO 4217 currency code for the virtual account

Available options:

`USD`, `NGN`, `GBP`, `EUR`

#### customerId

Optional customer ID. When supplied, the lookup is scoped to that customer. When omitted, it resolves to the business owner.

#### country

Optional ISO 3166-1 alpha-2 country code.

#### amount

Optional positive amount.

#### reference

Optional merchant-supplied reference.

### Response

200

application/json

Virtual accounts retrieved successfully (possibly empty list).
