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

# Node.js SDK Configuration & Authentication Setup

> Configure the Corsa Node.js SDK with API credentials, custom headers, and HYOK encryption support.

Import `CorsaClient` and configure it with your API details:

```typescript theme={null}
import { CorsaClient } from '@corsa-labs/sdk';

const client = new CorsaClient({
    BASE: "https://api.corsa.finance",
    HEADERS: {
        "Authorization": `Bearer ${process.env.API_TOKEN}:${process.env.API_SECRET}`
    }
});
```

Alternatively, configure the global `OpenAPI` object:

```typescript theme={null}
import { CorsaClient, OpenAPI } from '@corsa-labs/sdk';

OpenAPI.BASE = 'https://api.corsa.finance';
OpenAPI.HEADERS = {
  "Authorization": `Bearer ${process.env.API_TOKEN}:${process.env.API_SECRET}`
};

const client = new CorsaClient();
```

## Configuration Options

| Option             | Type                                   | Default     | Description                                             |
| ------------------ | -------------------------------------- | ----------- | ------------------------------------------------------- |
| `BASE`             | `string`                               | `''`        | Base URL for the API.                                   |
| `VERSION`          | `string`                               | `'1.0'`     | API version.                                            |
| `HEADERS`          | `Record<string, string>`               | `undefined` | Custom request headers. Recommended for authentication. |
| `TOKEN`            | `string`                               | `undefined` | Bearer token (deprecated; prefer `HEADERS`).            |
| `USERNAME`         | `string`                               | `undefined` | Basic auth username.                                    |
| `PASSWORD`         | `string`                               | `undefined` | Basic auth password.                                    |
| `WITH_CREDENTIALS` | `boolean`                              | `false`     | Include credentials in requests.                        |
| `CREDENTIALS`      | `'include' \| 'omit' \| 'same-origin'` | `'include'` | Credentials mode for fetch.                             |
| `ENCODE_PATH`      | `(path: string) => string`             | `undefined` | Custom path encoder.                                    |

<Note>`ComplianceClient` is a deprecated alias for `CorsaClient`. Use `CorsaClient` in new code.</Note>

## Encrypted Client

For HYOK customers with field-level encryption:

```typescript theme={null}
import { EncryptedCorsaClient } from '@corsa-labs/sdk';

const client = EncryptedCorsaClient.withEncryptedFields(
  {
    baseUrl: "https://api.corsa.finance",
    apiKey: `${process.env.CORSA_API_TOKEN}:${process.env.CORSA_API_SECRET}`,
    apiSecret: process.env.ENCRYPTION_SERVICE_API_SECRET,
    encryptionServiceUrl: "https://your-encryption-service.example.com",
  },
  encryptedFieldSchema
);
```

`apiKey` authenticates requests to Corsa. `apiSecret` authenticates the encryption service and must not reuse your Corsa API secret.
