> ## Documentation Index
> Fetch the complete documentation index at: https://docs.artu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Bank Accounts

> Managing client bank account information

Bank accounts store financial account information for clients, including account numbers, bank details, and scope-specific identifiers like Mexico's CLABE.

## Bank Account Types

| Type       | Description        |
| ---------- | ------------------ |
| `Checking` | Checking account   |
| `Savings`  | Savings account    |
| `Other`    | Other account type |

## Creating Bank Accounts

<Tabs>
  <Tab title="Base">
    ```typescript theme={null}
    import { BankAccountType, Currency } from "@artu-ai/compliance-sdk";

    const account = await sdk.bankAccounts.create({
      clientId: "client_abc123",
      accountNumber: "1234567890",
      bankName: "BBVA México",
      type: BankAccountType.Checking,
      currency: Currency.MXN,
      country: "MX",
    });
    ```
  </Tab>

  <Tab title="Mexico">
    With a Mexico-scoped SDK, include the CLABE for Mexican bank accounts:

    ```typescript theme={null}
    import { BankAccountType, Currency } from "@artu-ai/compliance-sdk";

    const account = await sdk.bankAccounts.create({
      clientId: "client_abc123",
      accountNumber: "1234567890",
      bankName: "BBVA México",
      type: BankAccountType.Checking,
      currency: Currency.MXN,
      country: "MX",
      clabe: "012180001234567890",
    });

    // Returns MexBankAccount with CLABE helpers
    console.log(account.clabe);          // "012180001234567890"
    console.log(account.formattedClabe); // "012 180 00123456789 0"
    ```
  </Tab>
</Tabs>

## Retrieving Bank Accounts

<Tabs>
  <Tab title="Base">
    ```typescript theme={null}
    const account = await sdk.bankAccounts.retrieve("bank_xyz789");

    console.log(account.bankName);      // "BBVA México"
    console.log(account.accountNumber); // "1234567890"
    console.log(account.currency);      // "MXN"
    ```
  </Tab>

  <Tab title="Mexico">
    ```typescript theme={null}
    const account = await sdk.bankAccounts.retrieve("bank_xyz789");

    console.log(account.bankName);       // "BBVA México"
    console.log(account.clabe);          // "012180001234567890"
    console.log(account.formattedClabe); // "012 180 00123456789 0"
    console.log(account.maskedClabe);    // "**************7890"
    console.log(account.codigoBanco);    // "012" (bank code from CLABE)
    console.log(account.codigoPlaza);    // "180" (branch code from CLABE)
    ```
  </Tab>
</Tabs>

For lookups by your own IDs or metadata, use `retrieveByExternalId` or `retrieveByMetadata` (see [SDK reference](/sdk/resources)).

## Listing Bank Accounts

### List by Client

```typescript theme={null}
const { data: accounts } = await sdk.bankAccounts.listByClient("client_abc123");

for (const account of accounts) {
  console.log(`${account.bankName}: ${account.accountNumber}`);
}
```

### Filter by Currency

```typescript theme={null}
import { Currency } from "@artu-ai/compliance-sdk";

const { data: mxnAccounts } = await sdk.bankAccounts.list({
  filter: {
    clientId: "client_abc123",
    currency: Currency.MXN,
  },
});
```

## Updating Bank Accounts

<Tabs>
  <Tab title="Base">
    ```typescript theme={null}
    const updated = await sdk.bankAccounts.update("bank_xyz789", {
      bankName: "Banorte",
      accountNumber: "0987654321",
    });
    ```
  </Tab>

  <Tab title="Mexico">
    ```typescript theme={null}
    const updated = await sdk.bankAccounts.update("bank_xyz789", {
      clabe: "072180009876543210",
    });

    console.log(updated.formattedClabe); // "072 180 00987654321 0"
    ```
  </Tab>
</Tabs>

## Deleting Bank Accounts

```typescript theme={null}
await sdk.bankAccounts.delete("bank_xyz789");
```

## Primary Bank Account

Each client can have one primary bank account:

```typescript theme={null}
// Get the primary bank account
const primary = await sdk.bankAccounts.getPrimary("client_abc123");

if (primary) {
  console.log(`Primary account: ${primary.bankName}`);
}

// Set as primary
await sdk.bankAccounts.setPrimary("bank_xyz789");

// Or via update
await sdk.bankAccounts.update("bank_xyz789", {
  isPrimary: true,
});
```

## Activating/Deactivating Accounts

```typescript theme={null}
// Deactivate an account
await sdk.bankAccounts.deactivate("bank_xyz789");

// Reactivate an account
await sdk.bankAccounts.activate("bank_xyz789");
```

## Bank Account Model Properties

<Tabs>
  <Tab title="Base">
    | Property        | Type              | Description             |
    | --------------- | ----------------- | ----------------------- |
    | `id`            | `string`          | Unique identifier       |
    | `clientId`      | `string`          | Parent client ID        |
    | `accountNumber` | `string`          | Account number          |
    | `bankName`      | `string`          | Bank name               |
    | `type`          | `BankAccountType` | Account type            |
    | `currency`      | `Currency`        | Account currency        |
    | `country`       | `string`          | Country code            |
    | `isPrimary`     | `boolean`         | Whether primary account |
    | `isActive`      | `boolean`         | Whether account active  |
    | `createdAt`     | `Date`            | Creation timestamp      |
    | `updatedAt`     | `Date`            | Last update timestamp   |
  </Tab>

  <Tab title="Mexico">
    Includes all base properties plus:

    | Property         | Type                  | Description                     |
    | ---------------- | --------------------- | ------------------------------- |
    | `clabe`          | `string \| undefined` | CLABE (18-digit interbank code) |
    | `codigoBanco`    | `string \| undefined` | Bank code (digits 1-3 of CLABE) |
    | `codigoPlaza`    | `string \| undefined` | Branch code (digits 4-6)        |
    | `formattedClabe` | `string \| undefined` | CLABE with spaces for display   |
    | `maskedClabe`    | `string \| undefined` | CLABE showing last 4 digits     |
  </Tab>
</Tabs>

## Batch Operations

```typescript theme={null}
// Create multiple bank accounts
const result = await sdk.bankAccounts.createMany([
  {
    clientId: "client_abc123",
    accountNumber: "1111111111",
    bankName: "BBVA",
    type: BankAccountType.Checking,
    currency: Currency.MXN,
    country: "MX",
  },
  {
    clientId: "client_abc123",
    accountNumber: "2222222222",
    bankName: "Santander",
    type: BankAccountType.Savings,
    currency: Currency.MXN,
    country: "MX",
  },
]);
```

<Info>See [Batch Operations](/guides/batch-operations) for more details.</Info>
