- Call
https://api.usecobalt.com/link/token/create
to create alink_token
and pass it to your app’s client. - Use the
link_token
to open Link for your user. In theonSuccess
callback, Link will provide a temporarypublic_token
. - Call
https://api.usecobalt.com/link/token/exchange
to exchange thepublic_token
for a permanentaccess_token
. - Store the
access_token
and use it to make API requests.
Detailed Steps
Create Link Token
The/link/token/create
endpoint creates a link_token
, which is required as a parameter when initializing Link. Once Link has been initialized, it returns a public_token
, which can then be exchanged for an access_token
via /link/token/exchange
as part of the main Link flow.
client_id
this is your Cobalt API client id.client_secret
this is your Cobalt API secret.user_id
this is a unique ID representing the end user. Typically this will be a user ID number from your application. Personally identifiable information, such as an email address or phone number, should not be used in theuser_id
.org_id
this is the ID of the organization that this user belongs to in your system. This is often a clinic or hospital. This association is important to handle any custom settings that an org has.
Initialize Client Link
Lightbox Mode Lightbox Mode will activate the Cobalt Link experience in a modal rather than having the element appear directly embedded elsewhere on the page. The lightbox takes up the entire user’s screen, darkening the background content with a semi-transparent overlay of the page and centering Cobalt’s Link UI in a modal located at the center of the user’s screen. To utilize Lightbox mode, include the Javascript snippet on your site, before the closing</body>
tag. Make sure to attach a button’s onClick
event to call the launch_cobalt()
function. Alternatively, you can call the window.CobaltLink.init()
function directly within an event callback of your choice.
CobaltLink.init
accepts one argument, a configuration Object
. The configuration object requires the following parameters:
token
this is the temporarylink_token
from the create link token step.onSuccess
this callback is called when a user successfully links their account. It takes one arguments: thepublic_token
. Thepublic_token
can then be used in the exchange public token step.
https://link.usecobalt.com?token={link_token}
. Once the user completes the flow they will be redirected back to your callback_url
along with the public_token
(eg. https://{YOUR_CALLBACK_URL}?token={public_token}
). You can then use the public_token
in the next step. If you haven’t set up a callback_url
yet it will default to google.com and you’ll see the token in the browser’s address bar after the redirect.
Exchange Public Token
The/link/token/exchange
endpoint exchanges a public_token
for an access_token
.
client_id
this is your Cobalt API client id.client_secret
this is your Cobalt API secret.public_token
this is the token acquired during the Initialize Client Link step.