Appearance
User - Users
Base URL:
https://your-domain.com
Admin endpoints for managing users (Admin/Staff/Reseller). All endpoints require admin authentication.
Fetch All Users
Retrieve a list of all users in the system.
| Property | Value |
|---|---|
| Endpoint | Fetch All Users |
| Method | GET |
| URL | /api/v1/users |
| Authentication | Bearer Token |
Request Headers:
| Header | Value | Required |
|---|---|---|
Accept | application/json | Yes |
Authorization | Bearer your-auth-token | Yes |
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
isp_id | integer | Yes | ISP ID |
branch_id | integer | Yes | Branch ID |
user_id | integer | Yes | User ID |
role_id | integer | No | Filter by role |
Request Body: None
Success Response (200 OK):
json
{
"success": true,
"data": [
{
"id": 1,
"name": "Admin User",
"email": "[email protected]",
"phone": "01712345678",
"role_id": 1,
"role_name": "Admin",
"status": "active",
"balance": 5000.00,
"created_at": "2024-01-01 00:00:00"
}
]
}Error Response (401 Unauthorized):
json
{
"success": false,
"message": "Unauthenticated"
}Fetch User
Retrieve details of a specific user.
| Property | Value |
|---|---|
| Endpoint | Fetch User |
| Method | GET |
| URL | /api/v1/users/{id} |
| Authentication | Bearer Token |
Path Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | Yes | User ID |
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
isp_id | integer | Yes | ISP ID |
branch_id | integer | Yes | Branch ID |
user_id | integer | Yes | Requesting user ID |
Success Response (200 OK):
json
{
"success": true,
"data": {
"id": 2,
"name": "Staff User",
"email": "[email protected]",
"phone": "01712345679",
"role_id": 2,
"role_name": "Staff",
"permissions": ["subscribers.view", "subscribers.create"],
"status": "active",
"balance": 1000.00,
"created_at": "2024-01-15 10:30:00"
}
}Error Response (404 Not Found):
json
{
"success": false,
"message": "User not found"
}Create User
Create a new user (Admin/Staff/Reseller).
| Property | Value |
|---|---|
| Endpoint | Create User |
| Method | POST |
| URL | /api/v1/users |
| Authentication | Bearer Token |
Request Headers:
| Header | Value | Required |
|---|---|---|
Content-Type | application/json | Yes |
Accept | application/json | Yes |
Authorization | Bearer your-auth-token | Yes |
Request Body:
json
{
"isp_id": 1,
"branch_id": 1,
"user_id": 1,
"name": "New Staff",
"email": "[email protected]",
"password": "password123",
"phone": "01712345680",
"role_id": 2
}| Parameter | Type | Required | Description |
|---|---|---|---|
isp_id | integer | Yes | ISP ID |
branch_id | integer | Yes | Branch ID |
user_id | integer | Yes | Creating user ID |
name | string | Yes | User's full name |
email | string | Yes | Unique email address |
password | string | Yes | Password (min 6 chars) |
phone | string | No | Phone number |
role_id | integer | Yes | Role ID to assign |
Success Response (201 Created):
json
{
"success": true,
"message": "User created successfully",
"data": {
"id": 3
}
}Error Response (422 Validation Error):
json
{
"success": false,
"message": "Validation failed",
"errors": {
"email": ["The email has already been taken."]
}
}Update User
Update an existing user's information.
| Property | Value |
|---|---|
| Endpoint | Update User |
| Method | PUT |
| URL | /api/v1/users/{id} |
| Authentication | Bearer Token |
Path Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | Yes | User ID |
Request Body:
json
{
"name": "Updated Name",
"phone": "01712345681",
"role_id": 2
}Success Response (200 OK):
json
{
"success": true,
"message": "User updated successfully"
}Error Response (404 Not Found):
json
{
"success": false,
"message": "User not found"
}Delete User
Delete a user from the system.
| Property | Value |
|---|---|
| Endpoint | Delete User |
| Method | DELETE |
| URL | /api/v1/users/{id} |
| Authentication | Bearer Token |
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
isp_id | integer | Yes | ISP ID |
branch_id | integer | Yes | Branch ID |
user_id | integer | Yes | Requesting user ID |
Success Response (200 OK):
json
{
"success": true,
"message": "User deleted successfully"
}Error Response (400 Bad Request):
json
{
"success": false,
"message": "Cannot delete user with active subscribers"
}