# Subaccounts

Notbank's subaccount service redefines financial management by allowing total segmentation of resources within the same platform. This tool facilitates precise balance control, enabling purchases, sales and conversions to be operated in independent and secure environments. By isolating each capital flow, users can optimize their trading strategies and maintain impeccable accounting organization. It is the ideal solution for those seeking operational agility without compromising clarity or structure of their financial movements.

### 1.1 Create a subaccount

{% tabs %}
{% tab title="Node" %}

```javascript
// ...
await restClient.getSubAccountService().createSubAccount({
    alias: "subaccount1"
});
```

{% endtab %}
{% endtabs %}

### 1.2 Get subaccounts

{% tabs %}
{% tab title="Node" %}

<pre class="language-javascript"><code class="lang-javascript">const subAccounts = await restClient.getSubAccountService().getSubAccounts({
    page: 1,
    page_size: 10
});

console.log(subAccounts);
// [
<strong>//    {
</strong>//        "id": 1556,
//        "alias": "subaccount1",
//        "created_at": "2026-02-17T13:27:28"
//    }
// ]
</code></pre>

{% endtab %}
{% endtabs %}

### 1.3 Get list of supported banks

{% tabs %}
{% tab title="Node" %}

```js
const banks = await restClient.getWalletService().getBanks({
  country: "PE"
});

console.log(banks);
// [
//    {
//        "id": "6e83d105-83ff-4a1e-ba62-cd23b21e9d37",
//        "name": "BANK OF CHINA",
//        "country": "PE"
//    },
//    {
//        "id": "925099d0-4b2c-403e-9b8b-f64e18ce5f47",
//        "name": "BANCO AZTECA",
//        "country": "PE"
//    }, ...
// ]
```

{% endtab %}
{% endtabs %}

### 1.4 Get provinces

{% tabs %}
{% tab title="Node" %}

```javascript
const provinces = await restClient.getWalletService().getProvinces({
  "country": "PE"
});

console.log(provinces);
// {
//   "status": "success",
//   "data": [
//     [
//       "101",
//       "Chachapoyas"
//     ],
//     [
//       "102",
//       "Bagua"
//     ],
//     [
//       "103",
//       "Bongara"
//     ], ...
//   ]
// }
```

{% endtab %}
{% endtabs %}

### 1.5 Add bank account

{% tabs %}
{% tab title="Node" %}

```js
// ...
const userBankAccount =  restClient.getWalletService().AddClientBankAccount({
  country: "PEN",
  bank: "6e83d105-83ff-4a1e-ba62-cd23b21e9d37",
  number: "111111111111111111111", // CCI number
  kind: "ahorro",
  province: "212", // Huaylas
  document_number: "111111111",
  document_type: "DNI",
  name_1: "Juan",
  name_2: "Perez"
});

console.log(userBankAccount.id);
// 29cd83cf-3678-4207-80c7-7caaa1d24c27
```

{% endtab %}
{% endtabs %}

### 1.6 Get available networks

Given the large number of coins and networks that Notbank supports, it is first necessary to obtain the available networks for a cryptocurrency.

{% tabs %}
{% tab title="Node" %}

```js
// ...
const networks = await restClient.getWalletService().getNetworksTemplates({
  currency: "USDT"
});

console.log(networks);
// [
//   {
//     "currency": "USDT",
//     "network": "USDT_ERC20",
//     "network_name": "Ethereum",
//     "network_protocol": "ERC-20",
//     template: [
//       [Object],
//       [Object]
//     ]
//   }
// ]
```

{% endtab %}
{% endtabs %}

### 1.7 Get a USDT ERC20 wallet

Using the network code ( `network` ) obtained in the previous step plus the currency code (`currency`) you can request your wallet address.&#x20;

{% tabs %}
{% tab title="Node" %}

```js
// ...
const addresses = await restClient.getWalletService().getDepositAddresses({
  account_id: clientAccountId,
  currency: "USDT",
  network: "USDT_ERC20",
});

console.log(addresses)
// ["2N3r9roRrHy7p6C5pGE8NQP9ZNT81H7ZKyU"]
```

{% endtab %}
{% endtabs %}

### 1.8 Convert cryptocurrencies

In this example, we will request the amount of Ethereum (ETH) we would receive if we used 1000 Soles (PEN). Then we will check the promised amount, which is valid for 20 seconds and finally, we will execute the purchase.

{% hint style="success" %}
The conversion is not limited to transactions between cryptocurrencies, but to any possible combination: cryptocurrency to cryptocurrency, fiat currency to cryptocurrency, cryptocurrency to fiat currency and fiat currency to fiat currency.
{% endhint %}

{% hint style="info" %}
The amounts attached in the examples are for educational purposes and do not represent the current state of the market.
{% endhint %}

#### 1.8.1 Request quote

{% tabs %}
{% tab title="Node" %}

```js
const quoteId = await restClient.getQuoteService().createDirectQuote({
  from_currency: "PEN",
  from_amount: 1000,
  to_currency: "ETH",
  operation: 3, // CONVERSION
  account_id: clientAccountId,
});

console.log(quoteId)
// fc4ffe0e-b87a-4e1f-a727-f6ddae7dc1e0
```

{% endtab %}
{% endtabs %}

#### 1.8.2 Check quote

{% tabs %}
{% tab title="Node" %}

```js
// ...
const quote = await restClient.getQuoteService().getQuote({
  quote_id: "fc4ffe0e-b87a-4e1f-a727-f6ddae7dc1e0",
  account_id: clientAccountId,
});

console.log(quote.status)
// 0 // pending
console.log(quote.amount_out)
// 1.5 // ETH
```

{% endtab %}
{% endtabs %}

#### 1.8.3 Execute quote

{% tabs %}
{% tab title="Node" %}

```js
// ...
const quote = await restClient.getQuoteService().executeQuote({
  quote_id: "fc4ffe0e-b87a-4e1f-a727-f6ddae7dc1e0",
  account_id: clientAccountId,
});

console.log(quote.status)
// 0 // pending
console.log(quote.amount_out)
// 1.5 // ETH

// After a few moments, check the request status again
const quote = await restClient.getQuoteService().getQuote({
  quote_id: "fc4ffe0e-b87a-4e1f-a727-f6ddae7dc1e0",
  account_id: clientAccountId,
});

console.log(quote.status)
// 1 // executed
console.log(quote.amount_out)
// 1.5 // ETH
```

{% endtab %}
{% endtabs %}

### 1.9 Bank withdrawal notification

{% tabs %}
{% tab title="Node" %}

```js
await restClient.getWalletService().createFiatWithdraw({
  account_id: clientAccountId, 
  payment_method: 1,  // bank transfer
  currency: "PEN",
  amount: 1000,
  bank_account_id: "29cd83cf-3678-4207-80c7-7caaa1d24c27"
});
```

{% endtab %}
{% endtabs %}

### 1.10 Move USDT balance to the main account

{% tabs %}
{% tab title="Node" %}

```javascript
await restClient.getWalletService().transferFunds({
  "sender_account_id": subAccountId,
  "receiver_account_id": primaryAccountId,
  "currency_name": "USDT",
  "amount": 100,
  "notes": "transfer detail",
  "otp": "123456" // two-step authentication
});
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.notbank.com/learn/tutorial/en/subaccounts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
