Skip to main content

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

page
integer
default:"1"
The page number to retrieve.
per_page
integer
default:"10"
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_order
string
default:"desc"
Sort direction. Allowed values: asc, desc.

Response

success
boolean
true when the request succeeds.
data
object

Errors

StatusDescription
401Missing or invalid access token.
403The 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
    }
  }
}

Build docs developers (and LLMs) love