# Авторизація

Для роботи з SDK необхідно створити екземпляр класу `AllianceBankClient`. Він автоматично керує станом токенів та їх оновленням за допомогою `RetryHttpClient` та внутрішнього сервісу авторизації.

Приклад ініціалізації:

```
import { AllianceBankClient, AllianceSDKConfig } from '@alliancepay/sdk-nodejs';

const config: AllianceSDKConfig = {
    authentificationData: {
        baseUrl: '[https://api-ecom-prod.bankalliance.ua/](https://api-ecom-prod.bankalliance.ua/)', // Базовий URL сервісу надається банком
        merchantId: 'YOUR_MERCHANT_ID', 
        serviceCode: 'YOUR_SERVICE_CODE', 
        authenticationKey: 'YOUR_AUTH_KEY' // Надається банком
    },
    // ВАЖЛИВО: Використовуйте цей колбек для збереження оновлених токенів у вашій базі даних
    onTokenUpdate: async (updatedAuth) => {
        // Наприклад: await db.saveAuthToken(updatedAuth);
    }
};

const client = new AllianceBankClient(config);
```

**Особливість архітектури:**

SDK використовує Lazy Loading (ліниву ініціалізацію).

Внутрішні сервіси створюються лише в момент першого виклику, що робить клієнт максимально легким та економить пам'ять.


---

# 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.merchant.alb.ua/platizhni-vidzheti-dlya-cms/nodejs-sdk/avtorizaciya.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.
