How to get the list of users using REST API?
Authentication
All REST API endpoints are protected using OAuth 2.0. To access this API, you need to get an access token. Please refer to this document to get the authentication token.
Authorization
Header Name | Header Value |
Authorization | Bearer <access_token> |
Steps to get users using the REST API
- Pass the access token generated from the token endpoint in the Authorization header.
List all the active users using the following API endpoint.
METHOD GET
URL https://{yourdomain}/api/v2.0/users
Note: By default, this API returns the list of 25 users. You can get more users using pagination by passing the page and page_size parameters in the request URL. For example, refer to the URL below.
/api/v2.0/users?page_size=30 returns the first 30 users./api/v2.0/users?page=2&page_size=30 returns the 2nd group of 30 users.
- You will get a response message with the user information as follows.
{
"data": [
{
"user_id": "fd39e677-b5c8-49c5-b139-aa75c99e9770",
"user_name": "John",
"email": "john@example.com",
"first_name": "John",
"last_name": "Soundar",
"display_name": "John Soundar",
"contact": "",
"directory_type": {
"id": 1,
"name": "Local"
},
"role": "Admin",
"email_verified": true,
"user_status": "Active"
},
{
"user_id": "042e67f9-4e09-4d5e-ba46-ac4c023e7f3c",
"user_name": "sivabalan",
"email": "sivabalan@example.com",
"first_name": "Sivabalan",
"last_name": "Ganesan",
"display_name": "Sivabalan Ganesan",
"contact": "",
"directory_type": {
"id": 1,
"name": "Local"
},
"role": "Admin",
"email_verified": true,
"user_status": "Active"
},
{
"user_id": "539162ac-fe1c-4a8f-bf4c-4ce126b3d0ae",
"user_name": "tamil",
"email": "tamil@example.com",
"first_name": "Tamil",
"last_name": "Selvan",
"display_name": "Tamil Selvan",
"contact": "",
"directory_type": {
"id": 1,
"name": "Local"
},
"role": "",
"email_verified": true,
"user_status": "Active"
}
],
"total_results": 3,
"links": [
{
"link": "http://localhost:49709/api/v2.0/users?page=1&page_size=25",
"rel": "first",
"type": "GET"
},
{
"link": "http://localhost:49709/api/v2.0/users?page=1&page_size=25",
"rel": "last",
"type": "GET"
}
],
"status_message": null
}
Error Messages
HTTP Status Code | Description | Error Code | Error Message |
401 | Unauthorized | - | - |
500 | Internal Server Error | - | - |