# Subcontas

O serviço de subcontas do Notbank redefine a gestão financeira ao permitir uma segmentação total dos recursos dentro de uma mesma plataforma. Essa ferramenta facilita o controle preciso dos saldos, permitindo operar compras, vendas e conversões em ambientes independentes e seguros. Ao isolar cada fluxo de capital, os usuários podem otimizar suas estratégias comerciais e manter uma organização contábil impecável. É a solução ideal para quem busca agilidade operacional sem comprometer a clareza nem a estrutura de seus movimentos financeiros.

### 1.1 Criar uma subconta

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

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

{% endtab %}
{% endtabs %}

### 1.2 Obter subcontas

{% 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 Obter lista de bancos suportados

{% 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 Obter províncias

{% 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 Adicionar conta bancária

{% 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 Obter as redes disponíveis

Dada a grande quantidade de moedas e redes que o Notbank suporta, primeiro é necessário obter as redes disponíveis para uma criptomoeda.

{% 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 Obter uma carteira USDT ERC20

Utilizando o código da rede ( `network` ) obtido no passo anterior mais o código da moeda (`currency`) você pode solicitar seu endereço de carteira.&#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 Converter criptomoedas

Neste exemplo, vamos solicitar a quantidade de Ethereum (ETH) que receberíamos se usássemos 1000 Soles (PEN). Em seguida consultaremos o montante prometido, que tem validade de 20 segundos e, finalmente, executaremos a compra.

{% hint style="success" %}
A conversão não se limita a transações entre criptomoedas, mas a qualquer combinação possível: criptomoeda para criptomoeda, moeda fiat para criptomoeda, criptomoeda para moeda fiat e moeda fiat para moeda fiat.
{% endhint %}

{% hint style="info" %}
Os valores anexados nos exemplos são para fins educativos e não representam o estado atual do mercado.
{% endhint %}

#### 1.8.1 Solicitar cotação

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

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

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

{% endtab %}
{% endtabs %}

#### 1.8.2 Consultar cotação

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

{% endtab %}
{% endtabs %}

#### 1.8.3 Executar cotação

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

// Após alguns momentos, consulte novamente o status da solicitação
const quote = await restClient.getQuoteService().getQuote({
  quote_id: "fc4ffe0e-b87a-4e1f-a727-f6ddae7dc1e0",
  account_id: clientAccountId,
});

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

{% endtab %}
{% endtabs %}

### 1.9 Notificação de retirada bancária

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

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

{% endtab %}
{% endtabs %}

### 1.10 Mover saldo USDT para a conta principal

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

```javascript
await restClient.getWalletService().transferFunds({
  "sender_account_id": subAccountId,
  "receiver_account_id": primaryAccountId,
  "currency_name": "USDT",
  "amount": 100,
  "notes": "detalhe da transferência",
  "otp": "123456" // autenticação de dois fatores
});
```

{% 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/pt-br/subcontas.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.
