NodeJS SDK
You can refer to the Cobalt’s GitHub repo for the NodeJS SDK here.
Install
First install @cobaltio/cobalt
via the terminal.
The Cobalt SDK for JavaScript bundles TypeScript definition files for use in TypeScript projects. We aim to keep these TypeScript definition files updated with each release for any public api.
Pre-requisites for Typescript
- Use TypeScript v2.x
- If you are targeting at es5 or older ECMA standards, your tsconfig.json has to include ‘es5’ and ‘es2015.promise’ under compilerOptions.lib. See tsconfig.json for an example.
- Includes the TypeScript definitions for node. You can use npm to install this by typing the following into a terminal window:
Initialise
.createLinkedAccount()
The “Create Linked Account” fucntion allows you to create a new linked account for your customer within Cobalt’s platform. Linked accounts represent your end-users or customers, and they are essential for enabling connections with third-party applications.
Param | Required | Type | Description |
---|---|---|---|
linked_account_id | Mandatory | String | Unique customer identifier |
name | Optional | String | Name of the customer |
UDF | Optional | Object | User specific preliminary data |
your_app | Optional | Object | Auth specific data |
Example response:
.upsertLinkedAccount()
The “Upsert Linked Account” function allows you to create or update a linked account for your customer within Cobalt’s platform. Linked accounts represent your end-users or customers, and they are essential for enabling connections with third-party applications. The API will either create a new linked account if it does not exist or update the existing linked account if it is already present.
Param | Required | Type | Description |
---|---|---|---|
linked_account_id | Mandatory | String | Unique customer identifier |
name | Optional | String | Name of the customer |
UDF | Optional | Object | User specific preliminary data |
your_app | Optional | Object | Auth specific data |
Example response:
.getTokenForLinkedAccount()
The “Session Token” API is used to generate a secure session token that provides authorized access to Cobalt’s APIs for a specific linked account. The session token serves as a temporary authentication credential for accessing the Cobalt JS SDK.
Param | Required | Type | Description |
---|---|---|---|
linked_account_id | Mandatory | String | Unique customer identifier |
Example response:
.getApplications()
Returns the application details for the specified application, provided the application is enabled in Cobalt. If no application is specified, it returns all the enabled applications.
Param | Required | Type | Description |
---|---|---|---|
linked_account_id | Mandatory | String | Unique customer identifier |
Example Response:
.getApplicationBySlug()
Returns the application details for the specified application, provided the application is enabled in Cobalt. If no application is specified, it returns all the enabled applications.
Param | Required | Type | Description |
---|---|---|---|
linked_account_id | Mandatory | String | Unique customer identifier |
Example response:
.event()
Triggers a webhook event created for your app. This would trigger all the workflows associated with the specified event. If slug is specified, only workflows of that particular app associated with the event would be triggered.
Param | Required | Type | Description |
---|---|---|---|
linked_account_id | Mandatory | String | Unique customer identifier |
event | Mandatory | String | Event Name |
slug | Optional | String | Application slug |
config_id | Optional | String | Unique id |
payload | Optional | Object | Event payload |
Example Response
.config()
Returns the application details for the specified application, provided the application is enabled in Cobalt. If no application is specified, it returns all the enabled applications.
Param | Required | Type | Description |
---|---|---|---|
linked_account_id | Mandatory | String | Unique customer identifier |
slug | Mandatory | String | Application slug |
config_id | Optional | String | Unique id |
labels | Optional | Object | dynamic labels |
Example response: