# Subcuentas

El servicio de subcuentas de Notbank redefine la gestión financiera al permitir una segmentación total de los recursos dentro de una misma plataforma. Esta herramienta facilita el control preciso de los balances, permitiendo operar compras, ventas y conversiones en entornos independientes y seguros. Al aislar cada flujo de capital, los usuarios pueden optimizar sus estrategias comerciales y mantener una organización contable impecable. Es la solución ideal para quienes buscan agilidad operativa sin comprometer la claridad ni la estructura de sus movimientos financieros.

### 1.1 Crear una subcuenta

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

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

{% endtab %}
{% endtabs %}

### 1.2 Obtener subcuentas

{% 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 Obtener lista de bancos soportados

{% 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 Obtener provincias

{% 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 Agregar cuenta bancaria

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

```js
// ...
const userBankAccount =  restClient.getWalletService().AddClientBankAccount({
  country: "PEN",
  bank: "6e83d105-83ff-4a1e-ba62-cd23b21e9d37",
  number: "111111111111111111111", // número CCI
  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 Obtener las redes disponibles

Dada la gran cantidad de monedas y redes que soporta Notbank, primero es necesario obtener las redes disponibles para una criptomoneda.

{% 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 Obtener una billetera USDT ERC20

Utilizando el código de la red ( `network` ) obtenido en el paso anterior más el código de la moneda (`currency`) puedes solicitar tu dirección de billetera.&#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 Convertir criptomonedas

En este ejemplo, vamos a solicitar la cantidad de Ethereum (ETH) que recibiríamos si utilizáramos 1000 Soles (PEN).  Luego consultaremos el monto prometido, que tiene una vigencia de 20 segundos y finalmente, ejecutaremos la compra.

{% hint style="success" %}
La conversión no se limita a transacciones entre criptomonedas, si no que a cualquier combinación posible: criptomoneda a criptomoneda, moneda fiat a criptomoneda, criptomoneda a moneda fiat y moneda fiat a moneda fiat.
{% endhint %}

{% hint style="info" %}
Los montos adjuntos en los ejemplos son con fines educativos y no representan el estado actual del mercado.
{% endhint %}

#### 1.8.1 Solicitar cotización

{% 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 Consultar cotización

{% 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 // pendiente
console.log(quote.amount_out)
// 1.5 // ETH
```

{% endtab %}
{% endtabs %}

#### 1.8.3 Ejecutar cotización

{% 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 // pendiente
console.log(quote.amount_out)
// 1.5 // ETH

// Luego de unos momentos, consultar de nuevo el estado de la solicitud
const quote = await restClient.getQuoteService().getQuote({
  quote_id: "fc4ffe0e-b87a-4e1f-a727-f6ddae7dc1e0",
  account_id: clientAccountId,
});

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

{% endtab %}
{% endtabs %}

### 1.9 Notificación de retiro bancario

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

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

{% endtab %}
{% endtabs %}

### 1.10 Mover balance USDT hacia la cuenta principal

{% 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" // autenticación de dos pasos
});
```

{% 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/subcuentas.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.
