User Management – Fetch Users with Pagination
Fetch organization users with server-side pagination, sorting, and search capabilities.
Authentication
Authorization: Bearer <YOUR_AUTH_TOKEN>
Endpoint
POSThttps://api.samvyo.com/api/user/fetchOrgUsersWithPagination
Required Headers
Content-Type: application/json
Authorization: Bearer <YOUR_AUTH_TOKEN>
Request Body
{
"role": "moderator",
"page": 1,
"limit": 25,
"sortBy": "name",
"sortOrder": "ASC",
"search": "john"
}
Request Parameters
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
role | string | Yes | - | User role to filter by (e.g., "moderator", "admin") |
page | number | No | 1 | Page number for pagination (starts from 1) |
limit | number | No | 25 | Number of users per page (10, 25, 50, 100) |
sortBy | string | No | "name" | Field to sort by ("name" or "createdAt") |
sortOrder | string | No | "ASC" | Sort order ("ASC" or "DESC") |
search | string | No | "" | Search term to filter users by name, email, or username |
Example Requests
JavaScript (fetch)
const res = await fetch('https://api.samvyo.com/api/user/fetchOrgUsersWithPagination', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${authToken}`
},
body: JSON.stringify({
role: 'moderator',
page: 1,
limit: 25,
sortBy: 'name',
sortOrder: 'ASC',
search: 'john'
})
});
const data = await res.json();
cURL
curl -X POST \
'https://api.samvyo.com/api/user/fetchOrgUsers' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <YOUR_AUTH_TOKEN>' \
-d '{
"role": "moderator",
"page": 1,
"limit": 25,
"sortBy": "name",
"sortOrder": "ASC",
"search": "john"
}'
Success Response
{
"success": true,
"users": [
{
"id": "<USER_ID_1>",
"email": "john.doe@example.com",
"name": "John Doe",
"createdAt": "2025-08-06T02:16:24.398Z",
"location": "New York",
"username": "john_doe_123",
"role": "moderator",
"accountSuspended": false,
"profileId": "1234567890",
"meetNowEnabled": true,
"displayRating": false,
"tags": ["sales"],
"admin": true,
"rooms": ["Sales Team", "General"],
"roomIds": ["room_123", "room_456"]
},
{
"id": "<USER_ID_2>",
"email": "johnny.smith@example.com",
"name": "Johnny Smith",
"createdAt": "2025-08-07T02:12:39.474Z",
"location": "San Francisco",
"username": "johnny_smith_456",
"role": "moderator",
"accountSuspended": false,
"profileId": "0987654321",
"meetNowEnabled": true,
"displayRating": true,
"tags": ["customer success"],
"admin": false,
"rooms": ["Support Team"],
"roomIds": ["room_789"]
}
],
"pagination": {
"page": 1,
"limit": 25,
"total": 150,
"totalPages": 6
}
}
Response Fields
Users Array
Each user object contains the same fields as the non-paginated endpoint, plus:
rooms
: Array of room names the user ownsroomIds
: Array of room IDs the user owns
Pagination Object
Field | Type | Description |
---|---|---|
page | number | Current page number |
limit | number | Number of users per page |
total | number | Total number of users matching the criteria |
totalPages | number | Total number of pages available |
Error Responses
Invalid Sort Field
{
"success": false,
"message": "Invalid sort field. Allowed fields: name, createdAt"
}
Invalid Sort Order
{
"success": false,
"message": "Invalid sort order. Must be ASC or DESC"
}
Database Error
{
"success": false,
"message": "Database error occurred",
"error": "column a.invalidfield does not exist"
}
Use Cases
Basic Pagination
{
"role": "moderator",
"page": 1,
"limit": 25
}
Search with Pagination
{
"role": "moderator",
"page": 1,
"limit": 25,
"search": "john"
}
Sort by Creation Date
{
"role": "moderator",
"page": 1,
"limit": 25,
"sortBy": "createdAt",
"sortOrder": "DESC"
}
Combined Search and Sort
{
"role": "moderator",
"page": 2,
"limit": 50,
"sortBy": "name",
"sortOrder": "ASC",
"search": "sales"
}
Performance Notes
- Search is case-insensitive and matches against name, email, and username
- Sorting is optimized for the allowed fields (name, createdAt)
- Pagination limits help manage large datasets efficiently
- Room information is included for each user to reduce additional API calls