Prerequisites:
- A BrightHR administrator account
To create an API application:
- Browse to API Management
- Under Create new application click Create
- Give your application a name and create it
- Under that application you just created, note the Client ID and then click Create Secret
- Copy the Client Secret
Important: Store your client secret securely. You will not be able to view it again after closing the dialog.
The API uses OAuth2 client credentials flow for authentication.
To make a request to the API, you will first need to obtain a bearer token by following these steps:
- Use the client id and secret from your application
- Make a
POSTrequest tohttps://login.brighthr.com/connect/token - The request body must include:
grant_type:client_credentialsclient_id: your client idclient_secret: your client secret
- The
Content-Typemust beapplication/x-www-form-urlencoded
curl -X POST https://login.brighthr.com/connect/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET"{
"access_token": "eyJhbGciOiJSUzI1NiIs...",
"token_type": "Bearer",
"expires_in": 3600
}Once you have the bearer token, include it in the Authorization header of every API request:
Authorization: Bearer YOUR_BEARER_TOKENA bearer token is valid for 1 hour. Once it expires, you will need to obtain a new token by repeating the authentication process. If you make a request with an expired token, you will receive a 401 error with the problem type TokenExpired.
Once you have a bearer token, you can make your first API request. The following example calls the List Employees endpoint, which returns a list of employees in your organisation.
curl -X POST https://api.bright.hr/employees/v1/query \
-H "Authorization: Bearer YOUR_BEARER_TOKEN"{
"items": [
{
"id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"name": {
"givenName": "Jane",
"familyName": "Smith"
},
"employment": {
"jobTitle": "Software Engineer",
"start": "2023-01-15",
"end": null
},
"email": "jane.smith@example.com",
"externalReference": null,
"_metadata": {
"isRegistered": true,
"isTerminated": false
}
}
],
"continuationToken": null
}