---
title: Advance WhiteLabel
slug: connect/advance-whitelabel
docTags: 
createdAt: 2023-11-24T06:57:55.527Z
---

# Introduction

The Advanced Whitelabel is the integration method to use Klavi's services with the medium development effort for your company.

Klavi will create one or more [partner applications](docId\:CjeYEOENGiD2TKwNBBzMv), each with its own set of configurations and a corresponding pair of credentials (Access Key & Secret Key)

The Advanced Whitelabel URL will provide to your end-user access to Klavi's whitelabel consent journey so you can start collecting data sharing consents.&#x20;

# 1. Generate Your Credentials

As a first step, obtain your application(s) credentials through the [Klavi Console](https://www.console.klavi.ai/). These will give you access to Klavi Sandbox environment WhiteLabel/APIs and enable you to test consent creation and product requests until you are ready to upgrade to a paid plan with live financial institutions and real customers.

:::hint{type="warning"}
Regardless of the environment, please ensure the security of these credentials since they provide full access to Klavi APIs.
:::

# 2. Welcome Your First Customer

Follow the 2 steps below to create a test customer and share some test accounts with Open finance.

::::ExpandableHeading
## Step 1. Create Access Token

You should use the backend system to create an `accessToken`.

Command:

```shell
curl --location 'https://api-sandbox.klavi.ai/data/v1/auth' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"accessKey":"string","secretKey":"string"}'
```

Expected response:

```json
{
    "accessToken": "JhbGciOiJFUzI1NiIs.QtYjAyOC1hN2ZhMWFjZGRjZjkiLCJ0.nlTqpAZHeq4P2xFD",
    "expireIn": 1800
}
```

:::hint{type="info"}
If you need to keep a valid `accessToken` in the backend system at all times, please use the `refresh` endpoint to refresh or call the `auth` endpoint again to apply for a new `accessToken` before the `accessToken` reaches its expiration.
:::
::::

::::ExpandableHeading
## Step 2. Create a Link

Create a Link using the `accessToken` generated earlier.

Command:

```shell
curl --location 'https://api-sandbox.klavi.ai/data/v1/links' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"personalTaxId":"string","businessTaxId":"string","email":"string","phone":"string","redirectURL":"string","productsCallbackURL":"Object","externalInfo":"Object"}'
```

Expected response:

```json
{
    "linkId": "4437b139-8a16-11ee-b636-487b6bad036a",
    "linkURL": "https://conecte-sandbox.klavi.ai/path?v=AhbGciOiJFUzI1NiIs.CtYjAyOC1hN2ZhMWFjZGRjZjkiLCJ0.UlTqpAZHeq4P2xFD",
    "linkToken": "AhbGciOiJFUzI1NiIs.CtYjAyOC1hN2ZhMWFjZGRjZjkiLCJ0.UlTqpAZHeq4P2xFD",
    "expireIn": 1800
}
```

:::hint{type="info"}
You should notice that using this endpoint has generated another `linkToken`, yes, these are two different tokens.
`accessToken`: You can assume that this is the token used by your backend system
`linkToken`: You can assume that this is the token used by the `linkURL` generated by this endpoint, and its lifecycle is the lifecycle of the `linkId` and `linkURL`.
:::

### Supported Body Parameters

| **Parameter name**      | **Description**                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **personalTaxId**       | Automatically fills the user's CPF in the consent journey                                                                                                                                                                                                                                                                                                                                                                                             |
| **businessTaxId**       | Automatically fills the business CNPJ in the consent journey                                                                                                                                                                                                                                                                                                                                                                                          |
| **email**               | Automatically fills the user/business e-mail in the consent journey                                                                                                                                                                                                                                                                                                                                                                                   |
| **phone**               | Automatically fills the user/business phone in the consent journey                                                                                                                                                                                                                                                                                                                                                                                    |
| **institutionCode**     | Pre-determines the institution from which data will be shared. Skips institution selection page                                                                                                                                                                                                                                                                                                                                                       |
| **redirectUrl**         | The URL Klavi will redirect your end-user once the consent journey is completed                                                                                                                                                                                                                                                                                                                                                                       |
| **productsCallbackUrl** | Set one or more product callback URLs. Has higher priority than the receival address configured in Klavi Console                                                                                                                                                                                                                                                                                                                                      |
| **externalInfo**        | Used for:<br />* Partners to transmit information, which will be carried in reports sent to partners
*  Customization of the consent journey UI, more details below                                                                                                                                                                                                                                                                                   |
| **appLink**             | Used when the partner wants to display the LGPD step inside their own app (via WebView). After the Open Finance authorization step is completed in the bank environment, the end-user is redirected to the URL provided in the`app_link` parameter. The redirect includes a query parameter whose name is defined by `app_redirect_url_key`. The value of this parameter is the Klavi-hosted LGPD URL, which the partner’s app must open in a WebView |
| **appRedirectUrlKey**   | Defines the name of the query parameter that Klavi will add to the `app_link` URL. This parameter will contain the Klavi-hosted LGPD step URL as its value. The partner’s application must read this parameter and open its value inside a WebView                                                                                                                                                                                                    |
::::

# 3. Fetch Product Data

You can use web or webview to open the `linkURL`, make subsequent selection of institutions, redirect to that institution for authentication, and return to the final result web page.

Klavi backend will send you the results through event webhook(even if it is a failed state), after the status change to `AUTHORISED`, you can send the specific report generation request you want based on the end user type(personal or business, their endpoints are different).

Command:

```shell
curl --location 'https://api-sandbox.klavi.ai/data/personal/institution-data' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer JhbGciOiJFUzI1NiIs.QtYjAyOC1hN2ZhMWFjZGRjZjkiLCJ0.nlTqpAZHeq4P2xFD' \
--data '{"taxId":"string","institutionId":"string","linkId":"String","consentId":"Array","products":"Array","productsCallbackURL":"Object"}'
```

Expected response:

```json
{
    "requestId": "1325412e-e566-4f4e-ac5b-2f4471586b89",
    "message": "ok"
}
```

After you submit a request to generate specific or all report(The report you want to purchase has already been limited by Klavi backend), Klavi randomly starts retrieving data from the institution and processing it to generate the corresponding report, which will be sent to you through the report webhook.

:::hint{type="info"}
Klavi also supports not having to actively call this endpoint. After you go living or move to production, you can proactively send all the reports you need through the report webhook after authorization is completed, or send them to Klavi's storage space. You can download them at any time through the [Klavi Console](https://console.klavi.ai).
:::

