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/

Authorization

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 and named, you should see tabs from the overview screen. Select "Authorization", choose the "Type" dropdown box and select "OAUTH 2.0", then scroll down to the "Configure New Token" section.

Screenshot 2024-03-14 at 8.50.25 AM.png

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

Token Name This can be anything. EX: Token A
Grant Type Leave as is
Callback URL https://oauth.pstmn.io/v1/browser-callback
Auth URL https://drchrono.com/o/authorize/
Access Token URL https://drchrono.com/o/token/
Client ID From the DrChrono API Page
Client Secret From the DrChrono API Page
Scope labs: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
State Leave 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

Let's create your first DrChrono API Request Call. Add a request within your collection and let's call the following endpoint: https://app.drchrono.com/api/users/current

When adding a request, ensure that it is made inside your collection. We want to inherit the token we generated when making API calls.

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

Here is how the request appears in Postman:

Screenshot 2024-05-15 at 3.21.17 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 new set of tokens to use. In that same instance, you can run any API resource from that request tab.

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