Create a Link token
curl --request POST \
--url https://api.usecobalt.com/v1/link/token/create \
--header 'Content-Type: application/json' \
--header 'access_token: <api-key>' \
--header 'client_id: <api-key>' \
--header 'client_secret: <api-key>' \
--data '
{
"user_id": "<string>",
"org_id": "<string>",
"access_token": "<string>",
"emr_name": "<string>",
"emr_instance_domain": "<string>",
"timezone": "<string>",
"use_custom_domain": true,
"domain_name": "<string>"
}
'import requests
url = "https://api.usecobalt.com/v1/link/token/create"
payload = {
"user_id": "<string>",
"org_id": "<string>",
"access_token": "<string>",
"emr_name": "<string>",
"emr_instance_domain": "<string>",
"timezone": "<string>",
"use_custom_domain": True,
"domain_name": "<string>"
}
headers = {
"client_id": "<api-key>",
"client_secret": "<api-key>",
"access_token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
client_id: '<api-key>',
client_secret: '<api-key>',
access_token: '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
user_id: '<string>',
org_id: '<string>',
access_token: '<string>',
emr_name: '<string>',
emr_instance_domain: '<string>',
timezone: '<string>',
use_custom_domain: true,
domain_name: '<string>'
})
};
fetch('https://api.usecobalt.com/v1/link/token/create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.usecobalt.com/v1/link/token/create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'user_id' => '<string>',
'org_id' => '<string>',
'access_token' => '<string>',
'emr_name' => '<string>',
'emr_instance_domain' => '<string>',
'timezone' => '<string>',
'use_custom_domain' => true,
'domain_name' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"access_token: <api-key>",
"client_id: <api-key>",
"client_secret: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.usecobalt.com/v1/link/token/create"
payload := strings.NewReader("{\n \"user_id\": \"<string>\",\n \"org_id\": \"<string>\",\n \"access_token\": \"<string>\",\n \"emr_name\": \"<string>\",\n \"emr_instance_domain\": \"<string>\",\n \"timezone\": \"<string>\",\n \"use_custom_domain\": true,\n \"domain_name\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("client_id", "<api-key>")
req.Header.Add("client_secret", "<api-key>")
req.Header.Add("access_token", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.usecobalt.com/v1/link/token/create")
.header("client_id", "<api-key>")
.header("client_secret", "<api-key>")
.header("access_token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"user_id\": \"<string>\",\n \"org_id\": \"<string>\",\n \"access_token\": \"<string>\",\n \"emr_name\": \"<string>\",\n \"emr_instance_domain\": \"<string>\",\n \"timezone\": \"<string>\",\n \"use_custom_domain\": true,\n \"domain_name\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.usecobalt.com/v1/link/token/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["client_id"] = '<api-key>'
request["client_secret"] = '<api-key>'
request["access_token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_id\": \"<string>\",\n \"org_id\": \"<string>\",\n \"access_token\": \"<string>\",\n \"emr_name\": \"<string>\",\n \"emr_instance_domain\": \"<string>\",\n \"timezone\": \"<string>\",\n \"use_custom_domain\": true,\n \"domain_name\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"token": "<string>"
}{
"success": false,
"message": "<string>"
}{
"success": false,
"message": "<string>"
}{
"success": false,
"message": "<string>"
}Link
Create Link Token
Create a Link token to initialize the Link flow.
POST
/
link
/
token
/
create
Create a Link token
curl --request POST \
--url https://api.usecobalt.com/v1/link/token/create \
--header 'Content-Type: application/json' \
--header 'access_token: <api-key>' \
--header 'client_id: <api-key>' \
--header 'client_secret: <api-key>' \
--data '
{
"user_id": "<string>",
"org_id": "<string>",
"access_token": "<string>",
"emr_name": "<string>",
"emr_instance_domain": "<string>",
"timezone": "<string>",
"use_custom_domain": true,
"domain_name": "<string>"
}
'import requests
url = "https://api.usecobalt.com/v1/link/token/create"
payload = {
"user_id": "<string>",
"org_id": "<string>",
"access_token": "<string>",
"emr_name": "<string>",
"emr_instance_domain": "<string>",
"timezone": "<string>",
"use_custom_domain": True,
"domain_name": "<string>"
}
headers = {
"client_id": "<api-key>",
"client_secret": "<api-key>",
"access_token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
client_id: '<api-key>',
client_secret: '<api-key>',
access_token: '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
user_id: '<string>',
org_id: '<string>',
access_token: '<string>',
emr_name: '<string>',
emr_instance_domain: '<string>',
timezone: '<string>',
use_custom_domain: true,
domain_name: '<string>'
})
};
fetch('https://api.usecobalt.com/v1/link/token/create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.usecobalt.com/v1/link/token/create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'user_id' => '<string>',
'org_id' => '<string>',
'access_token' => '<string>',
'emr_name' => '<string>',
'emr_instance_domain' => '<string>',
'timezone' => '<string>',
'use_custom_domain' => true,
'domain_name' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"access_token: <api-key>",
"client_id: <api-key>",
"client_secret: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.usecobalt.com/v1/link/token/create"
payload := strings.NewReader("{\n \"user_id\": \"<string>\",\n \"org_id\": \"<string>\",\n \"access_token\": \"<string>\",\n \"emr_name\": \"<string>\",\n \"emr_instance_domain\": \"<string>\",\n \"timezone\": \"<string>\",\n \"use_custom_domain\": true,\n \"domain_name\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("client_id", "<api-key>")
req.Header.Add("client_secret", "<api-key>")
req.Header.Add("access_token", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.usecobalt.com/v1/link/token/create")
.header("client_id", "<api-key>")
.header("client_secret", "<api-key>")
.header("access_token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"user_id\": \"<string>\",\n \"org_id\": \"<string>\",\n \"access_token\": \"<string>\",\n \"emr_name\": \"<string>\",\n \"emr_instance_domain\": \"<string>\",\n \"timezone\": \"<string>\",\n \"use_custom_domain\": true,\n \"domain_name\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.usecobalt.com/v1/link/token/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["client_id"] = '<api-key>'
request["client_secret"] = '<api-key>'
request["access_token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_id\": \"<string>\",\n \"org_id\": \"<string>\",\n \"access_token\": \"<string>\",\n \"emr_name\": \"<string>\",\n \"emr_instance_domain\": \"<string>\",\n \"timezone\": \"<string>\",\n \"use_custom_domain\": true,\n \"domain_name\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"token": "<string>"
}{
"success": false,
"message": "<string>"
}{
"success": false,
"message": "<string>"
}{
"success": false,
"message": "<string>"
}Creates a Link token that you’ll use to initialize the Link flow in your frontend application.
Request Body Parameters
Required Parameters
user_id(string) - A unique identifier for the end user from your system. Do not use PII like email or phone.org_id(string) - A unique identifier for the organization from your system (e.g., clinic or hospital ID).
Optional Parameters (for creating new organizations)
If theorg_id doesn’t exist yet, provide these parameters to create the organization:
emr_name(string) - The EMR system name. Contact support for a list of supported EMR systems.emr_instance_domain(string) - The EMR instance URL (e.g.,https://your-emr-instance.com)
Other Optional Parameters
access_token(string) - Include to use update mode for an existing connection
Example Request (Existing Organization)
curl -X POST https://api.usecobalt.com/link/token/create \
-H 'Content-Type: application/json' \
-H 'client_id: ci_live_198908HJDKJSH98789OHKJL' \
-H 'client_secret: cs_live_9827hofdsklOYYHJLJh' \
-d '{
"user_id": "user_12345",
"org_id": "org_67890"
}'
Example Request (New Organization)
curl -X POST https://api.usecobalt.com/link/token/create \
-H 'Content-Type: application/json' \
-H 'client_id: ci_live_198908HJDKJSH98789OHKJL' \
-H 'client_secret: cs_live_9827hofdsklOYYHJLJh' \
-d '{
"user_id": "user_12345",
"org_id": "org_67890",
"emr_name": "YourEMRName",
"emr_instance_domain": "https://your-emr-instance.com"
}'
Example Response
{
"success": true,
"token": "lt_198908HJDKJSH98789OHKJL"
}
Update Mode
To use update mode for an existing connection, include theaccess_token in your request:
curl -X POST https://api.usecobalt.com/link/token/create \
-H 'Content-Type: application/json' \
-H 'client_id: ci_live_198908HJDKJSH98789OHKJL' \
-H 'client_secret: cs_live_9827hofdsklOYYHJLJh' \
-d '{
"user_id": "user_12345",
"org_id": "org_67890",
"access_token": "493JKLHIU98789hLKH9HHJH"
}'
The Link token is single-use and expires after 30 minutes.
Authorizations
Body
application/json
Your user ID for the account being linked.
Your organization ID for the account being linked.
Existing access token, when re-linking an account.
EMR to link. Required when creating a new org (org_id not seen before).
The EMR instance domain. Required when creating a new org.
IANA timezone for the account (e.g. America/New_York).
Whether emr_instance_domain is a custom domain.
Domain name to record for an existing org that lacks one.