Skip to main content
The Cobalt Link flow has the following steps:
  1. Call  https://api.usecobalt.com/link/token/create to create a link_token and pass it to your app’s client.
  2. Use the link_token to open Link for your user. In the onSuccess callback, Link will provide a temporary public_token.
  3. Call https://api.usecobalt.com/link/token/exchange to exchange the public_token for a permanent access_token.
  4. Store the access_token and use it to make API requests.

Detailed Steps

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.
The request requires the following parameters:
  • 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 the user_id.
  • org_id this is a unique identifier for 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. You choose this identifier - it can be any string that uniquely identifies the organization in your system.

Creating a New Organization

If this is the first user from a new organization, you’ll need to provide additional parameters to create the organization:
  • emr_name (required for new orgs) - The name of the EMR system. Contact support for a list of supported EMR systems.
  • emr_instance_domain (required for new orgs) - The EMR instance URL (e.g., https://mypractice.example.com). Domain requirements vary by EMR.
Example request for a new organization:
Example response:
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 temporary link_token from the create link token step.
  • onSuccess this callback is called when a user successfully links their account. It takes one argument: the public_token. The public_token can then be used in the exchange public token step.
New Window Mode If you prefer to not include the Cobalt Link code in your site you can use the Cobalt dashboard to generate a Link to share with your users so they can enter their credentials. You will then be able to view the access_token in the Cobalt dashboard.

Exchange Public Token

The /link/token/exchange endpoint exchanges a public_token for an access_token.
The request requires the following parameters:
  • 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.
Example response:

Examples

Code snippet

Javascript

React