DEVELOPER GUIDE
How to integrate Link
API Only
6 min
1\ generate your credentials as a first step, please contact klavi business personnel( crie\@klavi ai mailto\ crie\@klavi ai ) 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 step 1 create access token you should use the backend system to create an accesstoken command 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 { "accesstoken" "jhbgcioijfuzi1niis qtyjayoc1hn2zhmwfjzgrjzjkilcj0 nltqpazheq4p2xfd", "expirein" 1800 } 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 step 2 create a link create a link using the accesstoken generated earlier command 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 { "linkid" "4437b139 8a16 11ee b636 487b6bad036a", "linkurl" "https //conecte sandbox klavi ai/path?v=ahbgcioijfuzi1niis ctyjayoc1hn2zhmwfjzgrjzjkilcj0 ultqpazheq4p2xfd", "linktoken" "ahbgcioijfuzi1niis ctyjayoc1hn2zhmwfjzgrjzjkilcj0 ultqpazheq4p2xfd", "expirein" 1800 } if you were a klavi customer before 22/11/2024, you may be able to use the links according to the old nomenclature, then, the expected linkurl may look like this https //open sandbox klavi ai/path?v=ahbgcioijfuzi1niis ctyjayoc1hn2zhmwfjzgrjzjkilcj0 ultqpazheq4p2xfd https //open sandbox klavi ai/path?v=ahbgcioijfuzi1niis ctyjayoc1hn2zhmwfjzgrjzjkilcj0 ultqpazheq4p2xfd 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 step 3 get institution list 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 curl location request get 'https //api sandbox klavi ai/data/v1/links/institutions' \\ \ header 'accept application/json' \\ \ header 'content type application/json' \\ \ header 'authorization bearer ahbgcioijfuzi1niis ctyjayoc1hn2zhmwfjzgrjzjkilcj0 ultqpazheq4p2xfd' expected response \[ { "institutioncode" "261", "name" "itau", "avatar" "https //avatarcredigo s3 sa east 1 amazonaws com/banklogo/4d9277e5 6d8b 11ee 8c78 0a8b9f03afaa of itau svg", "isoutage"\ false, "institutiontype" 1, "businesstype" "legal", "availableresources" \[ "registration", "accounts" ] }, { "institutioncode" "260", "name" "nubank", "avatar" "https //avatarcredigo s3 sa east 1 amazonaws com/banklogo/4d9277e5 6d8b 11ee 8c78 0a8b9f03afaa of nubank svg", "isoutage"\ false, "institutiontype" 1, "businesstype" "legal", "availableresources" \[ "registration", "accounts" ] } ] 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 step 4 create a consent create a consent using the linktoken generated earlier command curl location request post 'https //api sandbox klavi ai/data/v1/consents' \\ \ header 'accept application/json' \\ \ header 'content type application/json' \\ \ header 'authorization bearer ahbgcioijfuzi1niis ctyjayoc1hn2zhmwfjzgrjzjkilcj0 ultqpazheq4p2xfd' \\ \ data raw '{"externaltrackid" "string","personaltaxid" "string","businesstaxid" "string","institutioncode" "string","redirecturl" "string","phone" "string","email" "string"}' expected response { "consentid" "0325412e e566 4f4e ac5b 2f4471586b88", "consentredirecturl" "https //auth mockbank poc raidiam io/auth?client id= uwjusdgcwfqunokrjp0o\&scope=openid%20consent%3aurn%3araidiambank%3a76bfad6b", "expireat" "2024 11 21t23 59 59 999z" } 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 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 { "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 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