Import CorsaClient and configure it with your API details:
import { CorsaClient } from '@corsa-labs/sdk';
const client = new CorsaClient({
BASE: "https://api.corsa.finance",
HEADERS: {
"Authorization": `Bearer ${process.env.API_TOKEN}`
}
});
Alternatively, configure the global OpenAPI object:
import { CorsaClient, OpenAPI } from '@corsa-labs/sdk';
OpenAPI.BASE = 'https://api.corsa.finance';
OpenAPI.HEADERS = {
"Authorization": `Bearer ${process.env.API_TOKEN}`
};
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. |
ComplianceClient is a deprecated alias for CorsaClient. Use CorsaClient in new code.
Encrypted Client
For BYOK customers with field-level encryption:
import { EncryptedCorsaClient } from '@corsa-labs/sdk';
const client = EncryptedCorsaClient.withEncryptedFields(
{
baseUrl: "https://api.corsa.finance",
apiKey: process.env.API_TOKEN,
encryptionServiceUrl: "https://your-encryption-service.example.com",
},
encryptedFieldSchema
);