Links

Create a linked account

Step 1: Initialising SDK

The best way to interact with our API is to use one of our official SDK. You can find the detailed documentation here:
Javascript
Typescript
# Install via NPM
npm i @cobaltio/cobalt
# Getting Started
const Cobalt = require('@cobaltio/cobalt');
const Client = new Cobalt({
apiKey:"<Your Api Key>"
});
# Install via NPM
npm i @cobaltio/cobalt
#Getting started
import Cobalt from '@cobaltio/cobalt';
const Client:Cobalt = new Cobalt({
apiKey:"<Your Api Key>"
});
You can find your api key from here

Step 2: Creating Linked Account

Whenever a new user or organisation signs up on your platform, use the below call to create a linked account. If there are multiple users in an organisation DO NOT create linked account for all the users. In this case create linked account incase of a new organisation.
Linked account creation should always happen server-side to prevent token leakage.
## The below API implementation supports the following parameters:
linked_account_id (Mandatory): String,
payload (Optional): {
name (Optional): String,
udf (Optional): Record<String, Any>,
your_app (Optional): {
app_id (Mandatory): String,
auth_credentials (Mandatory): Record<String, Any>
}
}
Javascript
# Create linked account when user signs up
/**
* Create Linked Accounts
* @param {String} linked_account_id expects unique id
* @param {Object} payload - Optional Data for the linked account
* @returns {Promise<Account>}
*/
const createLinkedAccount = async (linked_account_id) => {
try{
return await Client.createLinkedAccount({
linked_account_id: linked_account_id,
payload:{
name: "<Name for the account>",
udf:{
"<Key name 1>":"<Data 1>",
"<Key name 2>":"<Data 2>",
"<Key name 3>":"<Data 3>"
},
app:{
app_id:"<Id of the app created in cobalt>",
auth_credentials:{
"<Header Key eg; x-api-key or Authorization>": "<Value eg; Value for x-api-key or Bearer Ejy245f3dd4d1.....>"
}
}
}
})
}catch(error){
//Catch any error
}
};
You will be able to see the accounts created under the linked account section for each new sign up.