Users API

API endpoints to manage user data, roles, and statuses.

Get All Users

Retrieve a paginated list of all users.

GET /api/admin/users

Response Example

{
  "users": [
    {
      "id": 1,
      "email": "user1@example.com",
      "fullName": "User One",
      "role": "USER",
      "isVerified": true,
      "createdAt": "2025-01-20T14:45:00Z"
    },
    /* ...more users */
  ],
  "pagination": {
    "page": 1,
    "pageSize": 20,
    "total": 100
  }
}

Get User by ID

Retrieve detailed info for a specific user.

GET /api/admin/users/{id}

Response Example

{
  "id": 1,
  "email": "user1@example.com",
  "fullName": "User One",
  "role": "USER",
  "isVerified": true,
  "wallet": {
    "balance": 150.50
  },
  "createdAt": "2025-01-20T14:45:00Z"
}

Update User Role

Change the user's role. Only Super Admins can perform this action.

PATCH /api/admin/users/{id}/role

Request Body

{
  "role": "ADMIN" // Valid values: USER, DEVELOPER, ADMIN, SUPERADMIN
}

Response Example

{
  "message": "User role updated successfully",
  "user": {
    "id": 1,
    "role": "ADMIN"
  }
}

Delete User

Permanently delete a user account. Only Super Admins can perform this action.

DELETE /api/admin/users/{id}

Response Example

{
  "message": "User deleted successfully"
}

Common Errors

Status CodeErrorDescription
400Bad RequestInvalid or missing parameters
401UnauthorizedAuthentication failed or token expired
403ForbiddenInsufficient permissions
404Not FoundUser not found
500Internal Server ErrorUnexpected error occurred
Back to Introduction
Next: Coins API