# Create a single-use virtual account

{% hint style="info" %} <mark style="color:blue;">The single-use account is only valid for one-time use only</mark>
{% endhint %}

Depending on the partner bank you choose, we may require more information. These *requirements are at the request of our partnering banks.*

### URI

&#x20;<mark style="color:blue;background-color:blue;">**POST**</mark>&#x20;

```
https://api.tryduplo.com/v1/virtual-accounts
```

### Parameters

#### Header

<table data-header-hidden><thead><tr><th width="171"></th><th></th></tr></thead><tbody><tr><td><strong>Authorization</strong><br><code>string</code> </td><td>set value to <code>Bearer SECRET_KEY</code></td></tr></tbody></table>

#### Body Param

<table data-header-hidden><thead><tr><th width="253"></th><th></th></tr></thead><tbody><tr><td><strong>business_id</strong>         <br><code>string</code>   <mark style="color:red;"><code>required</code></mark></td><td>Buisness ID</td></tr><tr><td><strong>first_name</strong>         <br><code>string</code>   <mark style="color:red;"><code>required</code></mark></td><td>Customer's first name</td></tr><tr><td><strong>last_name</strong>         <br><code>string</code>   <mark style="color:red;"><code>required</code></mark></td><td>Customer's last name</td></tr><tr><td><strong>phone_number</strong>         <br><code>string</code>   <mark style="color:red;"><code>required</code></mark></td><td>Customer's phone number</td></tr><tr><td><strong>email</strong>         <br><code>string</code>   <mark style="color:red;"><code>required</code></mark></td><td>Customer's email address</td></tr><tr><td><strong>bvn</strong>         <br><code>string</code>  </td><td>Customer's bank verification number</td></tr><tr><td><strong>metadata</strong>         <br><code>string</code> </td><td>Customer's specific data - Stringified JSON</td></tr><tr><td><strong>is_permanent</strong>         <br><code>boolean</code>   <mark style="color:red;"><code>required</code></mark></td><td>Flags a virtual account as temporary</td></tr><tr><td><strong>preferred_banks</strong>          <br><code>array</code></td><td>List of Customer's preferred banks</td></tr><tr><td><strong>purpose</strong>         <br><code>string</code>   <mark style="color:red;"><code>required</code></mark></td><td>Customer's purpose for creating a virtual account</td></tr><tr><td><strong>amount</strong>         <br><code>number</code></td><td>Specifies the exact amount a virtual account should receive</td></tr><tr><td>single_use<br>boolean <mark style="color:red;"><code>required</code></mark></td><td>Flag for a single use virtual account, should be set to <code>true</code></td></tr></tbody></table>

{% hint style="info" %} <mark style="color:blue;">If the amount is specified, the customer will only be allowed to pay the exact amount. Any other amount will be rejected</mark>
{% endhint %}

### Sample request

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```bash
curl --location --request POST 'https://api.tryduplo.com/v1/virtual-accounts' \
--header 'Authorization: Bearer SECRET_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
   "first_name": "Pat",
   "last_name": "Daniel",
   "phone_number": "08085279945",
   "email": "patwiksingle@yopmail.com",
   "bvn": "39372746283",
   "is_permanent": false,
   "purpose": "Testing purpose",
   "preferred_banks": [
       {
           "bank_code": "111",
           "bank_name": "Wema Bank",
           "id": "wema"
       }
   ],
   "single_use": true,
   "metadata": "{'invocie': '10093743'}"
}'
```

{% endcode %}

{% endtab %}

{% tab title="Node" %}
{% code overflow="wrap" lineNumbers="true" %}

```javascript
var axios = require('axios');
var data = JSON.stringify({
 "first_name": "Pat",
 "last_name": "Daniel",
 "phone_number": "08012345678",
 "email": "patwiksingle@yopmail.com",
 "bvn": "39372746283",
 "is_permanent": false,
 "purpose": "Testing purpose",
 "preferred_banks": [
   {
     "bank_code": "111",
     "bank_name": "Wema Bank",
     "id": "wema"
   }
 ],
 "single_use": true,
 "metadata": '{}'
});

var config = {
 method: 'post',
 url: 'https://api.tryduplo.com/v1/virtual-accounts',
 headers: {
   'Authorization': 'Bearer SECRET_KEY',
   'Content-Type': 'application/json'
 },
 data : data
};

axios(config)
.then(function (response) {
 console.log(JSON.stringify(response.data));
})
.catch(function (error) {
 console.log(error);
});
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code overflow="wrap" lineNumbers="true" %}

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, array(
 CURLOPT_URL => 'https://api.tryduplo.com/v1/virtual-accounts',
 CURLOPT_RETURNTRANSFER => true,
 CURLOPT_ENCODING => '',
 CURLOPT_MAXREDIRS => 10,
 CURLOPT_TIMEOUT => 0,
 CURLOPT_FOLLOWLOCATION => true,
 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
 CURLOPT_CUSTOMREQUEST => 'POST',
 CURLOPT_POSTFIELDS =>'{
   "business_id": BUSINESS_ID,
   "first_name": "Pat",
   "last_name": "Daniel",
   "phone_number": "08085279945",
   "email": "patwiksingle@yopmail.com",
   "bvn": "39372746283",
   "is_permanent": false,
   "purpose": "Testing purpose",
   "preferred_banks": [
       {
           "bank_code": "111",
           "bank_name": "Wema Bank",
           "id": "wema"
       }
   ],
   "fallback_bank": true,
   "single_use": true,
   "amount": 3000,
   "metadata": {}
}',
 CURLOPT_HTTPHEADER => array(
   'Authorization: Bearer SECRET_KEY',
   'Content-Type: application/json'
 ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Duplo Response

```json
{
    "data": {
        "account_ref": "act_jR8TvmZgiIHV",
        "account_number": "9190000023",
        "is_permanent": false,
        "email": "alindavdsin@gmail.com",
        "status": "active",
        "provider": {
            "bank_code": "111",
            "bank_name": "Wema Bank",
            "id": "wema",
            "credentials": {}
        },
        "created_at": "2022-02-01T18:20:19.000Z",
        "account_name": "David Daniel"
    },
    "errors": {},
    "message": "Account created successfully"
}
```
