# Create a virtual bank account

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Idempotency Supported](/docs/api/idempotency)

Creates a virtual bank account for a customer. Email address is mandatory for virtual bank account creation. All notifications related to this virtual bank account will be sent to the email address you specify.

Customer's email and virtual bank accounts will always be in sync.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/virtual_bank_accounts \
     -u {site_api_key}:\
     -d customer_id="__test__KyVnHhSBWSvsr5M" \
     -d email="Duncan@ac.com"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = VirtualBankAccount.Create()
		.CustomerId("__test__KyVnHhSBWSvsr5M")
		.Email("Duncan@ac.com")
		.Request();

VirtualBankAccount virtualBankAccount = result.VirtualBankAccount;
Customer customer = result.Customer;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    virtualbankaccountAction "github.com/chargebee/chargebee-go/v3/actions/virtualbankaccount"
    "github.com/chargebee/chargebee-go/v3/models/virtualbankaccount"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := virtualbankaccountAction.Create(&virtualbankaccount.CreateRequestParams{
        CustomerId : "__test__KyVnHhSBWSvsr5M",
        Email : "Duncan@ac.com",
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        VirtualBankAccount := res.VirtualBankAccount
        Customer := res.Customer
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.VirtualBankAccountCreateRequest{
    CustomerId : "__test__KyVnHhSBWSvsr5M",
    Email : "Duncan@ac.com",
}
  res, err := client.VirtualBankAccount.Create(req)
      if err != nil {
        fmt.Println(err)
    } else {
        VirtualBankAccount := res.VirtualBankAccount
        Customer := res.Customer
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = VirtualBankAccount.create()
            .customerId("__test__KyVnHhSBWSvsr5M")
            .email("Duncan@ac.com")
            .request();

        VirtualBankAccount virtualBankAccount = result.virtualBankAccount();
        Customer customer = result.customer();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.customer.Customer;
import com.chargebee.v4.models.virtualBankAccount.VirtualBankAccount;
import com.chargebee.v4.models.virtualBankAccount.params.VirtualBankAccountCreateParams;
import com.chargebee.v4.models.virtualBankAccount.responses.VirtualBankAccountCreateResponse;

public class VirtualBankAccountCreate {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        VirtualBankAccountCreateParams params = VirtualBankAccountCreateParams.builder()
            .customerId("__test__KyVnHhSBWSvsr5M")
            .email("Duncan@ac.com")
            .build();

        VirtualBankAccountCreateResponse response = client.virtualBankAccounts().create(params);

        VirtualBankAccount virtualBankAccount = response.getVirtualBankAccount();
        Customer customer = response.getCustomer();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.virtualBankAccount.create({
        customer_id: "__test__KyVnHhSBWSvsr5M",
        email: "Duncan@ac.com"
    });

    console.log(result);
    const virtualBankAccount = result.virtual_bank_account;
    const customer = result.customer;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->virtualBankAccount()->create([
    "customer_id" => "__test__KyVnHhSBWSvsr5M",
    "email" => "Duncan@ac.com"
]);
$virtualBankAccount = $result->virtual_bank_account;
$customer = $result->customer;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.VirtualBankAccount.create(
    cb_client.VirtualBankAccount.CreateParams(
        customer_id="__test__KyVnHhSBWSvsr5M",
        email="Duncan@ac.com"
    )
)
virtual_bank_account = response.virtual_bank_account
customer = response.customer
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::VirtualBankAccount.create({
  :customer_id => "__test__KyVnHhSBWSvsr5M",
  :email => "Duncan@ac.com"
})

virtual_bank_account = result.virtual_bank_account
customer = result.customer
```

## Sample Response

```json
{
  "customer": {
    "allow_direct_debit": false,
    "auto_collection": "on",
    "billing_address": {
      "city": "Walnut",
      "country": "US",
      "first_name": "Duncan",
      "last_name": "Walpole",
      "line1": "PO Box 9999",
      "object": "billing_address",
      "state": "California",
      "state_code": "CA",
      "validation_status": "not_validated",
      "zip": "91789"
    },
    "card_status": "no_card",
    "created_at": 1517501395,
    "deleted": false,
    "email": "Duncan@ac.com",
    "excess_payments": 0,
    "first_name": "Duncan",
    "id": "__test__KyVnHhSBWSvsr5M",
    "last_name": "walpole",
    "net_term_days": 0,
    "object": "customer",
    "pii_cleared": "active",
    "preferred_currency_code": "USD",
    "promotional_credits": 0,
    "refundable_credits": 0,
    "resource_version": 1517501395000,
    "taxability": "taxable",
    "unbilled_charges": 0,
    "updated_at": 1517501395
  },
  "virtual_bank_account": {
    "account_number": "test_5a576cb69dc2",
    "bank_name": "TEST BANK",
    "created_at": 1517501396,
    "customer_id": "__test__KyVnHhSBWSvsr5M",
    "deleted": false,
    "email": "Duncan@ac.com",
    "gateway": "stripe",
    "gateway_account_id": "gw___test__KyVnGlSBWSv3GHt",
    "id": "vba___test__KyVnHhSBWSw7J5O",
    "object": "virtual_bank_account",
    "reference_id": "cus_I57FLcFhampr4H/src_1HUx16Jv9j0DyntJh6X59egJ",
    "resource_version": 1517501396000,
    "routing_number": "110000000",
    "scheme": "ach_credit",
    "swift_code": "TSTEZ122",
    "updated_at": 1517501396
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/virtual_bank_accounts

## Input Parameters

- `customer_id` (required, string, max chars=50)
  Identifier of the customer.

- `email` (optional, string, max chars=70)
  Email address associated with the virtual bank account.

- `gateway_account_id` (optional, string, max chars=50)
  Identifier of the gateway account to use when creating the virtual bank account.
  
  **Default behavior** When not provided, Chargebee selects an applicable gateway account for the chosen `scheme`. Selection follows your site's [Smart Routing](https://www.chargebee.com/docs/payments/1.0/payment-gateways-and-configuration/gateway_settings#smart-routing) rules.

- `scheme` (optional, enumerated string, default=ach_credit)
  Type of the credit transfer.
  Possible enum values:
    - `ach_credit`
      ACH Credit Transfer
      
      This scheme is deprecated. Instead of `ach_credit` use `us_automated_bank_transfer` .
    - `sepa_credit`
      SEPA Credit Transfer
      
      This scheme is deprecated. Instead of `sepa_credit` use `eu_automated_bank_transfer` .
    - `us_automated_bank_transfer`
      US Automated Bank Transfer
    - `gb_automated_bank_transfer`
      UK Automated Bank Transfer
    - `eu_automated_bank_transfer`
      EU Automated Bank Transfer
    - `jp_automated_bank_transfer`
      JP Automated Bank Transfer
    - `mx_automated_bank_transfer`
      MX Automated Bank Transfer

## Returns

- `virtual_bank_account` (Virtual bank account object)
  Resource object representing virtual\_bank\_account

- `customer` (Customer object)
  Resource object representing customer
