GET /api/users
Returns a paginated list of all users registered in the system. This endpoint is restricted to administrators.
Authentication
Requires a valid Bearer access token. The authenticated user must have the admin role. Non-admin requests will receive a 403 Forbidden response.
Authorization: Bearer <access_token>
Query Parameters
The page number to retrieve.
Number of users to return per page. Maximum value is 100.
sort_by
string
default:"created_at"
Field to sort results by. Allowed values: id, username, email, created_at, updated_at.
Sort direction. Allowed values: asc, desc.
Response
true when the request succeeds.
Array of user objects.
Unique identifier for the user.
The user’s unique username.
The user’s email address.
Concatenation of first_name and last_name. Falls back to username if names are not set.
Whether the user account is currently active.
Role name. Either admin or user.
Human-readable description of the role.
ISO 8601 timestamp of when the user was created.
ISO 8601 timestamp of the last update to the user record.
Number of items per page.
Total number of users across all pages.
Whether a next page exists.
Whether a previous page exists.
Errors
| Status | Description |
|---|
401 | Missing or invalid access token. |
403 | The authenticated user does not have the admin role. |
Example
curl -X GET "https://task-forge-gbd6h8gtg8hchve9.chilecentral-01.azurewebsites.net/api/users?page=1&per_page=10&sort_by=created_at&sort_order=desc" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
{
"success": true,
"data": {
"users": [
{
"id": 1,
"username": "jdoe",
"email": "[email protected]",
"first_name": "John",
"last_name": "Doe",
"full_name": "John Doe",
"is_active": true,
"role": {
"id": 2,
"name": "user",
"description": "Standard user"
},
"created_at": "2024-01-15T10:30:00",
"updated_at": "2024-03-01T08:12:45"
}
],
"pagination": {
"page": 1,
"per_page": 10,
"total": 1,
"total_pages": 1,
"has_next": false,
"has_prev": false
}
}
}