# Managing bank accounts

## Add a new bank account

Here's an example code to add a new bank account.

```typescript
import { createSignature } from "./createSignature";
const axios = require('axios');

const apiKey = "{YOUR API KEY}";
const secret = "{YOUR SECRET}";

async function addBankAccount() {
  const path = "https://idrx.co/api/auth/add-bank-account";

  const req = {
    "bankAccountNumber" : "{BANK ACCOUNT NUMBER}",
    "bankCode"          : "{BANK CODE}",
  };
  const bufferReq = Buffer.from(JSON.stringify(req), 'base64').toString('utf8');
  const timestamp = Math.round((new Date()).getTime()).toString();
  const sig = createSignature('POST', path, bufferReq, timestamp, secret);

  const res = await axios.post(path, req, {
    headers: {
      'Content-Type': 'application/json',
      'idrx-api-key': apiKey,
      'idrx-api-sig': sig,
      'idrx-api-ts' : timestamp,
    },
  });

  console.log('res.data: ');
  console.log(JSON.stringify(res.data, null, 4));
}

addBankAccount();
```

You can get a list of available bank codes from [this api](/api/transaction-api/get-api-transaction-method.md).

After a successful request, you will get a response as follows:

```typescript
{
    "statusCode": 201,
    "message": "success",
    "data": {
        "id": 108,
        "userId": 411,
        "bankAccountNumber": "5017332241",
        "bankAccountName": "JOHN SMITH",
        "bankAccountNumberHash": null,
        "bankCode": "014",
        "bankName": "BANK CENTRAL ASIA",
        "maxAmountTransfer": "100000000",
        "deleted": false,
        "DepositWalletAddress": {
            "walletAddress": "0x07C158ab29f23D0821e7D24B191c5e5d9d72738b",
            "createdAt": "2024-01-17T10:34:22.304Z"
        }
    }
}
```

Notice that a deposit wallet address is also included. Users can send funds to this deposit address to request a redeem to the associated bank account.

To list currently registered bank accounts, you can use [this api](/api/onboarding-api/get-api-auth-get-bank-accounts.md).

## Delete a bank account

Here's an example code to delete an existing bank account.

```typescript
import { createSignature } from "./createSignature";
const axios = require('axios');

const apiKey = "{YOUR API KEY}";
const secret = "{YOUR SECRET}";

async function deleteBank(bankId: string) {
  const path = "https://idrx.co/api/auth/delete-bank-account/"+bankId;

  const bufferReq = Buffer.from('', 'base64').toString('utf8');
  const timestamp = Math.round((new Date()).getTime()).toString();
  const sig = createSignature('GET', path, bufferReq, timestamp, secret);

  const res = await axios.delete(path, {
    headers: {
      'Content-Type': 'application/json',
      'idrx-api-key': apiKey,
      'idrx-api-sig': sig,
    },
  });

  console.log('res.data: ');
  console.log(JSON.stringify(res.data, null, 4));
}

deleteBank('108');
```

After a successful request, you will get a response as follows:

```typescript
{
    "statusCode": 200,
    "message": "deleted",
    "data": null
}
```


---

# 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://docs.idrx.co/integration/managing-bank-accounts.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.
