Get list of users with pagination
curl --request GET \
--url http://localhost:2000/user/list/{start}/{end} \
--header 'Authorization: Bearer <token>'import requests
url = "http://localhost:2000/user/list/{start}/{end}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('http://localhost:2000/user/list/{start}/{end}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "2000",
CURLOPT_URL => "http://localhost:2000/user/list/{start}/{end}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://localhost:2000/user/list/{start}/{end}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("http://localhost:2000/user/list/{start}/{end}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:2000/user/list/{start}/{end}")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"message": "<string>",
"data": {
"total": 25,
"users": [
{
"emails": [
"user@example.com"
],
"personalInformation": {
"firstName": "John",
"lastName": "Doe"
},
"role": "employee",
"department": {
"id": "64ef3c29f9a1c27e1b2c3a4d",
"role": "manager"
},
"reportsTo": "64ef3c29f9a1c27e1b2c3a99",
"createdAt": "2025-09-12T08:30:00Z",
"config": {
"lastActive": "2025-09-12T09:15:00Z"
},
"linkedAccounts": {
"google": {
"meta": {
"email": "zain"
}
}
}
}
]
}
}User Administration
List Users
Admin-only endpoint to retrieve a list of users. - If both start and end are 0, all users are returned. - Otherwise, returns users between the given start and end indexes (zero-based).
GET
/
user
/
list
/
{start}
/
{end}
Get list of users with pagination
curl --request GET \
--url http://localhost:2000/user/list/{start}/{end} \
--header 'Authorization: Bearer <token>'import requests
url = "http://localhost:2000/user/list/{start}/{end}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('http://localhost:2000/user/list/{start}/{end}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "2000",
CURLOPT_URL => "http://localhost:2000/user/list/{start}/{end}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://localhost:2000/user/list/{start}/{end}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("http://localhost:2000/user/list/{start}/{end}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:2000/user/list/{start}/{end}")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"message": "<string>",
"data": {
"total": 25,
"users": [
{
"emails": [
"user@example.com"
],
"personalInformation": {
"firstName": "John",
"lastName": "Doe"
},
"role": "employee",
"department": {
"id": "64ef3c29f9a1c27e1b2c3a4d",
"role": "manager"
},
"reportsTo": "64ef3c29f9a1c27e1b2c3a99",
"createdAt": "2025-09-12T08:30:00Z",
"config": {
"lastActive": "2025-09-12T09:15:00Z"
},
"linkedAccounts": {
"google": {
"meta": {
"email": "zain"
}
}
}
}
]
}
}Admin-only endpoint to retrieve a list of users with pagination support.
Request
Headers
| Name | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Yes | Bearer token |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| start | integer | Yes | Starting index (0 for beginning) |
| end | integer | Yes | Ending index (0 to return all users) |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| departmentFilter | string | No | Department ID to filter users by |
departmentFilter Details
- Must be a valid MongoDB ObjectId of a department
- Can be
nullto return all users that are not part of any department - Example:
"64ef3c29f9a1c27e1b2c3a4d"
Response
200 OK - Successfully retrieved user list
{
"message": "Users retrieved successfully",
"data": {
"total": 25,
"users": [
{
"_id": "64b7f1a2e4b0a5d3f9c12345",
"emails": "user@example.com",
"firstName": "John",
"lastName": "Doe",
"role": "user",
"department": {
"_id": "64b7f2b3e4b0a5d3f9c54321",
"name": "Customer Support"
},
"rcExtension": "1234",
"phone": "+1-555-555-5555"
}
]
}
}
401 Unauthorized
{
"error": {
"code": "UNAUTHORIZED",
"message": "Missing or invalid token or insufficient permissions"
}
}
500 Internal Server Error
{
"error": {
"code": "SERVER_ERROR",
"message": "Internal server error"
}
}
Examples
Get first 10 users
curl -X GET 'http://localhost:2000/user/list/0/10' \
-H 'Authorization: Bearer your-jwt-token'
Get all users
curl -X GET 'http://localhost:2000/user/list/0/0' \
-H 'Authorization: Bearer your-jwt-token'
Get users from specific department
curl -X GET 'http://localhost:2000/user/list/0/10?departmentFilter=64ef3c29f9a1c27e1b2c3a4d' \
-H 'Authorization: Bearer your-jwt-token'
Get users without department
curl -X GET 'http://localhost:2000/user/list/0/10?departmentFilter=null' \
-H 'Authorization: Bearer your-jwt-token'
Notes
- This is an admin-only endpoint - requires administrative privileges
- Pagination is zero-based (start at 0)
- Setting both start and end to 0 returns all users
- The response includes a total count for pagination controls
- Users are returned with summary information, not full profile data
- Use departmentFilter to narrow down results by department
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Starting index (0 for beginning)
Required range:
x >= 0Ending index (0 to return all users)
Required range:
x >= 0Query Parameters
Department ID to filter users by. - Must be a valid MongoDB ObjectId of a department. - Can be null to return all users that is not a part of any department.
Was this page helpful?