Getting started with our APIs via Postman

Today we will begin connecting with DrChrono's APIs using Postman. Before we start let's make sure you download Postman here: https://www.postman.com/downloads/ 

If you have not set up an API application in your account, please review our "What is an API application" article.

A complete Postman collection of our APIs is at the bottom of this page.

Authorization

[If you are using our DrChrono Postman Collection skip to the Authorization tab from the collection's overview screen. Fill out the configure token section using the table below]

Let's begin by opening Postman and creating a collection. Navigate to the left-hand side of the page and select "Create Collection".

Screenshot 2024-03-14 at 8.45.35 AM.png

Once the collection is created, there are tabs from the collection's overview screen. Select the "Authorization" tab, and choose "OAUTH 2.0" from the "Type" dropdown box.

Screenshot 2024-03-14 at 8.50.25 AM.png

Under the "Configure New Token" section, please fill out the following:

Token NameThis can be anything. EX: Token A
Grant TypeLeave as is
Callback URL

https://oauth.pstmn.io/v1/browser-callback

[This should match the 'Redirect URIs' box from the DrChrono API page. Found in Account > API.]

Auth URLhttps://drchrono.com/o/authorize/
Access Token URLhttps://drchrono.com/o/token/
Client IDFrom the DrChrono API Page
Client SecretFrom the DrChrono API Page
Scopelabs:read labs:write messages:read messages:write patients:read patients:write patients:summary:read patients:summary:write settings:read settings:write tasks:read tasks:write user:read user:write billing:patient-payment:read billing:patient-payment:write billing:read billing:write calendar:read calendar:write clinical:read clinical:write
StateLeave as is
Client Authentication

Leave as is

Once everything is filled, select the orange button at the bottom of the page - "Get New Access Token".

Screenshot 2024-03-14 at 9.32.52 AM.png

You will be redirected to a prompt box to sign into DrChrono and then redirected to another screen to Authorize the connection...select "Authorize"

Congratulations! You received Access and Refresh Tokens. Select "Use Token" from Postman to set the access token to your collection.

Screenshot 2024-05-15 at 3.24.01 PM.png

 

First Request Call

Add a request within your collection. The screenshots below show how to add a request within the collection. 

Screenshot 2024-05-15 at 3.25.51 PM.pngScreenshot 2024-05-15 at 3.19.40 PM.png

 

Let's call the following endpoint: https://app.drchrono.com/api/users/current

Here is how the request appears in Postman:

Screenshot 2024-05-15 at 3.21.17 PM.png

I want to point out that adding a request within the collection is important. Postman defaults the authorization to "Inherit auth from parent" when doing so. This means you do not need to input or configure the access token for each request, it will automatically pull from the collection.

Here is an example of what that looks like in the DrChrono Postman Collection.

Screenshot 2024-08-06 at 3.03.18 PM.png

 

Alternative Configuration:

Instead of creating a collection, you can configure a connection from the request level.

To start, select the "New" or "+" button. If you select "New" you will be prompted to choose a specific method, select HTTP.

If you select "+" icon, Postman will automatically create a new HTTP request.

Screenshot 2024-06-11 at 10.26.58 AM.png

From the new request, navigate to the Authorization tab and configure the new token. You can use the same details from above.

Screenshot 2024-06-11 at 10.30.37 AM.png

Once you are finished select "Get New Access Token" and you should be able to receive a set of tokens to use.

 

Refresh Method

Lastly, I would like to introduce the refresh token method. This will help automate the process of grabbing new access tokens. Our access token has an expiration date of 48 hours. Our refresh token does not have an expiration, the refresh token only invalidates if you go through the OAuth process again or utilize the /o/revoke_token endpoint. 

Here is a Python snippet depicting the refresh method.

import requests

url = "https://drchrono.com/o/token/"

payload = 'client_id=1234&client_secret=1234&grant_type=refresh_token&refresh_token=1234'
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

 

Let's also take a look at this in Postman.

Screenshot 2024-03-14 at 10.38.18 AM.png

 

I hope this information was useful! If you have any questions please reach out to api@drchrono.com

References

https://app.drchrono.com/api-docs/#section/Introduction

https://app.drchrono.com/api-docs-old/v4/documentation#orevoke_token 

DrChrono Postman Collection

DrChrono API Collection.postman_collection.json