DEVELOPER GUIDE
How to integrate Link

API Only

6min

1. Generate Your Credentials

As a first step, please contact Klavi business personnel([email protected]) to create Sandbox environment API credentials for you. These will give you access to Klavi Sandbox environment WhiteLabel/APIs and test financial institutions until you are ready to upgrade to a paid plan with live financial institutions and real customers.

Regardless of the environment, please ensure the security of this credentials, which means that the backend must be saved.

2. Welcome Your First Customer

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

You should use the backend system to create an accessToken.

Command:

Shell


Expected response:

JSON


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.

Create a Link using the accessToken generated earlier.

Command:

Shell


Expected response:

JSON


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.

Obtain a list of participants using the linkToken generated earlier, which needs to be loaded into the page of your developed application for end users to choose the institution to which they want to share their account data. This list includes participants in the Brazilian Central Bank's Open finance and passive participants in the Open data supported by Klavi.

Command:

Shell


Expected response:

JSON


In API-Only integration mode, only linkToken is useful to you, and you don't need to pay attention to linkURL because it is used by WhiteLabel.

Create a consent using the linkToken generated earlier.

Command:

Shell


Expected response:

JSON


When your application requests the consentRedirectURL, the browser or App will redirect to the previously selected institution related web page or app (depending on how the user uses your application) for authorization.

You can record the consentId in the backend and update the user's latest data according to your business requirements (of course, this requires that the consentId has not expired or has been revoked by the user from other channels)

Klavi will also send you relevant consent information and status through the event webhook.

3. Fetch Product Data

You can use the consentId to poll the consents endpoint to obtain the status of this consentId. When the status of the consentId change to AUTHORISED (it is better to wait for the event through webhook, and after the status change to AUTHORISED, Klavi backend will send you the results, even if it is a failed state), 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


Expected response:

JSON


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.

Klavi also supports not having to actively call this endpoint. After you go online, 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.