---
updatedAt: 2026-10-01T07:04:14.000Z
agentTools:
  projectIndex: https://docs.nexhealth.com/v2.2.2/llms.txt
---

# Authentication

<Embed url="https://www.youtube.com/watch?v=sIj57-Kl938" title="[Appointment Booking with the NexHealth Synchronizer API ] Step 1: Authenticating" favicon="https://www.google.com/favicon.ico" image="https://i.ytimg.com/vi/sIj57-Kl938/hqdefault.jpg" provider="youtube.com" href="https://www.youtube.com/watch?v=sIj57-Kl938" typeOfEmbed="default" html="%3Ciframe%20class%3D%22embedly-embed%22%20src%3D%22%2F%2Fcdn.embedly.com%2Fwidgets%2Fmedia.html%3Fsrc%3Dhttps%253A%252F%252Fwww.youtube.com%252Fembed%252FsIj57-Kl938%253Ffeature%253Doembed%26display_name%3DYouTube%26url%3Dhttps%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DsIj57-Kl938%26image%3Dhttps%253A%252F%252Fi.ytimg.com%252Fvi%252FsIj57-Kl938%252Fhqdefault.jpg%26key%3D7788cb384c9f4d5dbbdbeffd9fe4b92f%26type%3Dtext%252Fhtml%26schema%3Dyoutube%22%20width%3D%22854%22%20height%3D%22480%22%20scrolling%3D%22no%22%20title%3D%22YouTube%20embed%22%20frameborder%3D%220%22%20allow%3D%22autoplay%3B%20fullscreen%3B%20encrypted-media%3B%20picture-in-picture%3B%22%20allowfullscreen%3D%22true%22%3E%3C%2Fiframe%3E" />

Create your [NexHealth Developer Portal Account](https://developers.nexhealth.com/signup)  and generate your [test API key](https://developers.nexhealth.com/test/api-key). Then you can make a POST request to `/authenticates` passing your key in the `Authorization` header. The response will contain a bearer token which is valid for 24 hours in sandbox and 1 hour in production. You must use this bearer token to access all other API routes.

The bearer token is a JSON Web Token. You can read more about JSON Web Tokens [here](https://jwt.io/introduction), and find libraries for working with them [here](https://jwt.io/libraries).

All unauthenticated requests will return a `401` status code.

You can see an example request to `/authenticates` below.

```curl
curl --request POST \
     --url https://nexhealth.info/authenticates \
     --header 'Accept: application/vnd.Nexhealth+json;version=2' \
     --header 'Authorization: YOUR_API_KEY'
```

Successful authentication will result in a response containing a bearer token.

```json
{
    "code": true,
    "data": {
        "token": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwic2NwIjoiYXBpX3VzZXIiLCJpYXQiOjE2Mjg3NDMyNzksImV4cCI6MTYyODc0Njg3OSwianRpIjoiNjYxNjY4YWYtMTZkYS00OWFhLTljM2ItNmI0MDNiOTQxZWExIn0.hzbAv-Bx8vhEMXM1sGmAa9tO3WzUyvgBN8aw4tdOrG0"
    },
    "description": "Authenticated",
    "error": []
}
```

> 📘 Using bearer tokens
>
> Once you've received your bearer token make sure you add the string "Bearer" to your authentication headers as shown below.

```curl
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwic2NwIjoiYXBpX3VzZXIiLCJpYXQiOjE2Mjg3NDMyNzksImV4cCI6MTYyODc0Njg3OSwianRpIjoiNjYxNjY4YWYtMTZkYS00OWFhLTljM2ItNmI0MDNiOTQxZWExIn0.hzbAv-Bx8vhEMXM1sGmAa9tO3WzUyvgBN8aw4tdOrG0'
```

Please note that if you are using these documentation pages to make calls, you must add "Bearer" to the Authentication header as a prefix before the bearer token as shown below for the request to be accepted.

![](https://files.readme.io/f61010c-Screenshot_2024-06-03_at_12.41.55_PM.png)