Bearer Tokens

This page will help you get started with the CareTend APIs. You'll be up and running in a jiffy!

WellSky uses bearer tokens for all API calls to the integration hub. These tokens are good for 30 minutes after they have been generated. To generate a token, you will need your Client ID and the Secret Key for the account which will be placed in the body of the request. Here is an example of how to generate a token:

import json
import urllib3

client_id = 'Enter Client ID'
secret = 'Enter Secret Key'
auth_url = 'https://auth.wellsky.io/connect/token'
client = urllib3.PoolManager()

creds = {
    'client_id': client_id, 
    'client_secret': secret, 
    'scope': 'api.wellsky.caretend.integrationhub', 
    'grant_type': 'client_credentials'}

auth_headers = {
    'Content-Type': 'application/x-www-form-urlencoded',
    'Accept-Encoding': 'gzip,deflate,br',
    'Accept': '*/*'
}

r = client.request_encode_body('POST', auth_url, fields=creds, headers=auth_headers, encode_multipart=False)

token = json.loads(r.data.decode('utf-8'))['access_token']
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using RestSharp;

var httpClient = new RestClient(_authUrl);

var request = new RestRequest("connect/token", Method.Post);
  request.AddHeader("content-type", "application/x-www-form-urlencoded");
  request.AddParameter("grant_type", grantType);
  request.AddParameter("client_id", clientId);
  request.AddParameter("client_secret", secretKey);
  request.AddParameter("scope", scope);

var response = httpClient.Execute(request).Content;
var tokenResponse = JsonConvert.DeserializeObject<Dictionary<string, object>>(response)["access_token"].ToString();
//Using axios for client side framework
var axios = require("axios").default;

var options = {
  method: 'POST',
  url: 'https://auth.stable.wellsky.io/connect/token',
  headers: {'content-type': 'application/x-www-form-urlencoded'},
  data: new URLSearchParams({
    grant_type: 'client_credentials',
    client_id: 'client_id',
    client_secret: 'secret',
    scope: 'api.wellsky.caretend'
  })
};

axios.request(options).then(function (response) {
  console.log(response.data);
}).catch(function (error) {
  console.error(error);
});
curl -i -X POST "https://auth.wellsky.io/connect/token" \
     -H "Content-Type: application/x-www-form-urlencoded" \
     -d "client_id=[client_id]" \
     -d "client_secret=[secret]" \
     -d "grant_type=client_credentials"

What’s Next