Authenticates

The Authenticates endpoint allows you to get a bearer token that allows you to access all other API endpoints. Tokens expires in 24 hours in sandbox and 1 hour in production.

NexHealth bearer tokens are JSON Web Tokens. You can read more about JSON Web Tokens here, and find libraries for working with them here.

To get a bearer token make a request like the one below.

curl --request POST \
     --url https://sandbox.nexhealth.com/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 provided in the response body:

{
    "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.

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