> ## Documentation Index
> Fetch the complete documentation index at: https://paystack-sdk.efobi.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Virtual Account

> Dedicated Virtual Account API methods for creating and managing virtual accounts

The VirtualAccount class provides methods for interacting with Paystack's Dedicated Virtual Account API. Virtual accounts allow you to receive payments via bank transfers with automatically generated account numbers.

## Overview

The VirtualAccount class allows you to:

* Create dedicated virtual accounts for customers
* Assign virtual accounts to existing customers
* List and fetch virtual account details
* Manage splits on virtual accounts
* Requery accounts for new transactions
* Deactivate virtual accounts
* Fetch available bank providers

## Methods

### create

Creates a dedicated virtual account.

```typescript theme={null}
async create(input: VirtualAccountCreateInput): Promise<VirtualAccountCreateResponse>
```

<ParamField body="customer" type="string" required>
  Customer ID or code
</ParamField>

<ParamField body="preferred_bank" type="string">
  The preferred bank slug for the virtual account
</ParamField>

<ParamField body="subaccount" type="string">
  Subaccount code to assign to the virtual account
</ParamField>

<ParamField body="split_code" type="string">
  Split code to assign to the virtual account
</ParamField>

<ParamField body="first_name" type="string">
  Customer's first name
</ParamField>

<ParamField body="last_name" type="string">
  Customer's last name
</ParamField>

<ParamField body="phone" type="string">
  Customer's phone number
</ParamField>

<ResponseField name="data" type="object">
  <ResponseField name="bank" type="object">
    <ResponseField name="name" type="string">
      The bank name
    </ResponseField>

    <ResponseField name="id" type="number">
      The bank ID
    </ResponseField>

    <ResponseField name="slug" type="string">
      The bank slug
    </ResponseField>
  </ResponseField>

  <ResponseField name="account_name" type="string">
    The account name
  </ResponseField>

  <ResponseField name="account_number" type="string">
    The generated virtual account number
  </ResponseField>

  <ResponseField name="assigned" type="boolean">
    Whether the account is assigned
  </ResponseField>

  <ResponseField name="currency" type="string">
    The account currency
  </ResponseField>

  <ResponseField name="active" type="boolean">
    Whether the account is active
  </ResponseField>

  <ResponseField name="customer" type="object">
    Customer details including id, email, and customer\_code
  </ResponseField>
</ResponseField>

**Example:**

```typescript theme={null}
const { data, error } = await paystack.virtualAccount.create({
  customer: "CUS_abc123",
  preferred_bank: "wema-bank"
});

if (data) {
  console.log(data.data.account_number);
}
```

***

### assign

Assigns a dedicated virtual account to a customer.

```typescript theme={null}
async assign(input: VirtualAccountAssignInput): Promise<GenericResponse>
```

<ParamField body="email" type="string" required>
  Customer's email address
</ParamField>

<ParamField body="first_name" type="string" required>
  Customer's first name
</ParamField>

<ParamField body="last_name" type="string" required>
  Customer's last name
</ParamField>

<ParamField body="phone" type="string" required>
  Customer's phone number
</ParamField>

<ParamField body="country" type="'NG' | 'GH'" required>
  Customer's country code
</ParamField>

<ParamField body="account_number" type="string">
  Customer's account number for validation (Nigeria only)
</ParamField>

<ParamField body="bvn" type="string">
  Customer's Bank Verification Number (Nigeria only)
</ParamField>

<ParamField body="bank_code" type="string">
  Customer's bank code
</ParamField>

<ParamField body="subaccount" type="string">
  Subaccount code to assign
</ParamField>

<ParamField body="split_code" type="string">
  Split code to assign
</ParamField>

**Example:**

```typescript theme={null}
const { data, error } = await paystack.virtualAccount.assign({
  email: "customer@example.com",
  first_name: "John",
  last_name: "Doe",
  phone: "+2348012345678",
  country: "NG",
  bvn: "12345678901"
});

if (data) {
  console.log(data.message);
}
```

***

### list

Lists dedicated virtual accounts.

```typescript theme={null}
async list(input: VirtualAccountListInput): Promise<VirtualAccountListResponse>
```

<ParamField body="active" type="boolean" required>
  Filter by active status
</ParamField>

<ParamField body="currency" type="'NGN' | 'USD' | 'GHS' | 'ZAR' | 'KES' | 'XOF'" required>
  Filter by currency (defaults to NGN)
</ParamField>

<ParamField body="provider_slug" type="string">
  Filter by provider slug
</ParamField>

<ParamField body="bank_id" type="string">
  Filter by bank ID
</ParamField>

<ParamField body="customer" type="string">
  Filter by customer ID or code
</ParamField>

<ResponseField name="data" type="array">
  Array of virtual account objects

  <ResponseField name="bank" type="object">
    Bank details (name, id, slug)
  </ResponseField>

  <ResponseField name="account_name" type="string">
    The account name
  </ResponseField>

  <ResponseField name="account_number" type="string">
    The account number
  </ResponseField>

  <ResponseField name="assigned" type="boolean">
    Whether the account is assigned
  </ResponseField>

  <ResponseField name="active" type="boolean">
    Whether the account is active
  </ResponseField>

  <ResponseField name="customer" type="object">
    Associated customer details
  </ResponseField>
</ResponseField>

<ResponseField name="meta" type="object">
  Pagination metadata including total, page, perPage, and pageCount
</ResponseField>

**Example:**

```typescript theme={null}
const { data, error } = await paystack.virtualAccount.list({
  active: true,
  currency: "NGN",
  customer: "CUS_abc123"
});

if (data) {
  console.log(`Found ${data.meta.total} virtual accounts`);
}
```

***

### fetch

Retrieves details of a dedicated virtual account.

```typescript theme={null}
async fetch(dedicated_account_id: string): Promise<VirtualAccountFetchResponse>
```

<ParamField path="dedicated_account_id" type="string" required>
  The ID of the dedicated virtual account
</ParamField>

<ResponseField name="data" type="object">
  <ResponseField name="bank" type="object">
    Bank details (name, id, slug)
  </ResponseField>

  <ResponseField name="account_name" type="string">
    The account name
  </ResponseField>

  <ResponseField name="account_number" type="string">
    The account number
  </ResponseField>

  <ResponseField name="assigned" type="boolean">
    Whether the account is assigned
  </ResponseField>

  <ResponseField name="currency" type="string">
    The currency
  </ResponseField>

  <ResponseField name="active" type="boolean">
    Whether the account is active
  </ResponseField>

  <ResponseField name="customer" type="object">
    Full customer details including metadata and phone
  </ResponseField>

  <ResponseField name="split_config" type="string">
    The split configuration if any
  </ResponseField>
</ResponseField>

**Example:**

```typescript theme={null}
const { data, error } = await paystack.virtualAccount.fetch("12345");

if (data) {
  console.log(data.data.account_number);
}
```

***

### requery

Requeries a dedicated virtual account for new transactions.

```typescript theme={null}
async requery(input: VirtualAccountRequeryInput): Promise<GenericResponse>
```

<ParamField body="account_number" type="string" required>
  The virtual account number
</ParamField>

<ParamField body="provider_slug" type="string" required>
  The provider slug
</ParamField>

<ParamField body="date" type="string">
  ISO date to check for transactions (optional)
</ParamField>

**Example:**

```typescript theme={null}
const { data, error } = await paystack.virtualAccount.requery({
  account_number: "0123456789",
  provider_slug: "wema-bank",
  date: "2024-01-15"
});

if (data) {
  console.log(data.message);
}
```

***

### deactivate

Deactivates a dedicated virtual account.

```typescript theme={null}
async deactivate(dedicated_account_id: string): Promise<VirtualAccountDeleteResponse>
```

<ParamField path="dedicated_account_id" type="string" required>
  The ID of the dedicated virtual account to deactivate
</ParamField>

<ResponseField name="data" type="object">
  The deactivated virtual account details with active status set to false
</ResponseField>

**Example:**

```typescript theme={null}
const { data, error } = await paystack.virtualAccount.deactivate("12345");

if (data) {
  console.log(`Account ${data.data.account_number} deactivated`);
}
```

***

### addSplit

Adds a split to a dedicated virtual account.

```typescript theme={null}
async addSplit(input: VirtualAccountAddSplitInput): Promise<VirtualAccountAddSplitResponse>
```

<ParamField body="customer" type="string" required>
  Customer ID or code
</ParamField>

<ParamField body="subaccount" type="string">
  Subaccount code
</ParamField>

<ParamField body="split_code" type="string">
  Split code
</ParamField>

<ParamField body="preferred_bank" type="string">
  Preferred bank slug
</ParamField>

<ResponseField name="data" type="object">
  Updated virtual account with split\_config containing the split\_code
</ResponseField>

**Example:**

```typescript theme={null}
const { data, error } = await paystack.virtualAccount.addSplit({
  customer: "CUS_abc123",
  split_code: "SPL_xyz789"
});

if (data) {
  console.log(data.data.split_config.split_code);
}
```

***

### removeSplit

Removes a split from a dedicated virtual account.

```typescript theme={null}
async removeSplit(input: VirtualAccountRemoveSplitInput): Promise<VirtualAccountRemoveSplitResponse>
```

<ParamField body="account_number" type="string" required>
  The virtual account number
</ParamField>

<ResponseField name="data" type="object">
  <ResponseField name="id" type="number">
    The account ID
  </ResponseField>

  <ResponseField name="split_config" type="object">
    Empty object indicating split has been removed
  </ResponseField>

  <ResponseField name="account_number" type="string">
    The account number
  </ResponseField>
</ResponseField>

**Example:**

```typescript theme={null}
const { data, error } = await paystack.virtualAccount.removeSplit({
  account_number: "0123456789"
});

if (data) {
  console.log("Split removed successfully");
}
```

***

### fetchBanks

Fetches available bank providers for dedicated virtual accounts.

```typescript theme={null}
async fetchBanks(): Promise<FetchBanksResponse>
```

<ResponseField name="data" type="array">
  Array of available bank providers

  <ResponseField name="provider_slug" type="string">
    The provider slug
  </ResponseField>

  <ResponseField name="bank_id" type="number">
    The bank ID
  </ResponseField>

  <ResponseField name="bank_name" type="string">
    The bank name
  </ResponseField>

  <ResponseField name="id" type="number">
    The provider ID
  </ResponseField>
</ResponseField>

**Example:**

```typescript theme={null}
const { data, error } = await paystack.virtualAccount.fetchBanks();

if (data) {
  data.data.forEach(bank => {
    console.log(`${bank.bank_name}: ${bank.provider_slug}`);
  });
}
```

## Related Resources

* [Dedicated Virtual Accounts Guide](/guides/virtual-accounts)
* [Split API Reference](/api-reference/split)
