User Management
These endpoints allow administrators to manage users in the system. All endpoints in this section require administrator privileges.
List Users
Retrieve a list of all users in the system.
GET
/api/v1/users
Query Parameters
Parameter | Type | Required | Description |
---|---|---|---|
page | integer | No | Page number for pagination (default: 1) |
per_page | integer | No | Number of items per page (default: 15) |
Response
{
"data": [
{
"user_id": 1,
"username": "johndoe",
"first_name": "John",
"last_name": "Doe",
"email": "[email protected]",
"gender": "male",
"birthday": "1990-01-01",
"country_id": 1,
"user_status": "active",
"role_id": 2
},
// ... more users
],
"meta": {
"current_page": 1,
"per_page": 15,
"total": 50
}
}
Get User Details
Retrieve details of a specific user.
GET
/api/v1/users/{id}
Path Parameters
Parameter | Type | Description |
---|---|---|
id | integer | User ID |
Response
{
"data": {
"user_id": 1,
"username": "johndoe",
"first_name": "John",
"last_name": "Doe",
"email": "[email protected]",
"gender": "male",
"birthday": "1990-01-01",
"country_id": 1,
"user_status": "active",
"role_id": 2
}
}
Error Responses
Status | Description |
---|---|
404 | User not found |
Create User
Create a new user in the system.
POST
/api/v1/users
Request Body
Parameter | Type | Required | Description |
---|---|---|---|
username | string | Yes | Username (max 64 characters) |
string | Yes | Valid email address | |
password | string | Yes | Password (min 8 characters) |
password_confirmation | string | Yes | Password confirmation |
first_name | string | Yes | First name (max 64 characters) |
last_name | string | Yes | Last name (max 64 characters) |
gender | string | Yes | Gender (male or female) |
birthday | date | Yes | Date of birth |
country_id | integer | No | ID of the user's country |
role_id | integer | No | User role ID (default: 2 - regular user) |
Response
{
"message": "User created successfully",
"data": {
"user_id": 1,
"username": "johndoe",
"first_name": "John",
"last_name": "Doe",
"email": "[email protected]",
"gender": "male",
"birthday": "1990-01-01",
"country_id": 1,
"user_status": "active",
"role_id": 2
}
}
Update User
Update an existing user's information.
PUT
/api/v1/users/{id}
Path Parameters
Parameter | Type | Description |
---|---|---|
id | integer | User ID |
Request Body
Parameter | Type | Required | Description |
---|---|---|---|
username | string | No | Username (max 64 characters) |
string | No | Valid email address | |
first_name | string | No | First name (max 64 characters) |
last_name | string | No | Last name (max 64 characters) |
gender | string | No | Gender (male or female) |
birthday | date | No | Date of birth |
country_id | integer | No | ID of the user's country |
role_id | integer | No | User role ID |
user_status | string | No | User status (active/inactive) |
Response
{
"message": "User updated successfully",
"data": {
"user_id": 1,
"username": "johndoe",
"first_name": "John",
"last_name": "Doe",
"email": "[email protected]",
"gender": "male",
"birthday": "1990-01-01",
"country_id": 1,
"user_status": "active",
"role_id": 2
}
}
Error Responses
Status | Description |
---|---|
404 | User not found |
422 | Validation Error - Invalid or missing fields |
Delete User
Delete a user from the system.
DELETE
/api/v1/users/{id}
Path Parameters
Parameter | Type | Description |
---|---|---|
id | integer | User ID |
Response
{
"message": "User deleted successfully"
}
Error Responses
Status | Description |
---|---|
404 | User not found |