Skip to content

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.

PropertyValue
EndpointFetch All Users
MethodGET
URL/api/v1/users
AuthenticationBearer Token

Request Headers:

HeaderValueRequired
Acceptapplication/jsonYes
AuthorizationBearer your-auth-tokenYes

Query Parameters:

ParameterTypeRequiredDescription
isp_idintegerYesISP ID
branch_idintegerYesBranch ID
user_idintegerYesUser ID
role_idintegerNoFilter 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.

PropertyValue
EndpointFetch User
MethodGET
URL/api/v1/users/{id}
AuthenticationBearer Token

Path Parameters:

ParameterTypeRequiredDescription
idintegerYesUser ID

Query Parameters:

ParameterTypeRequiredDescription
isp_idintegerYesISP ID
branch_idintegerYesBranch ID
user_idintegerYesRequesting 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).

PropertyValue
EndpointCreate User
MethodPOST
URL/api/v1/users
AuthenticationBearer Token

Request Headers:

HeaderValueRequired
Content-Typeapplication/jsonYes
Acceptapplication/jsonYes
AuthorizationBearer your-auth-tokenYes

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
}
ParameterTypeRequiredDescription
isp_idintegerYesISP ID
branch_idintegerYesBranch ID
user_idintegerYesCreating user ID
namestringYesUser's full name
emailstringYesUnique email address
passwordstringYesPassword (min 6 chars)
phonestringNoPhone number
role_idintegerYesRole 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.

PropertyValue
EndpointUpdate User
MethodPUT
URL/api/v1/users/{id}
AuthenticationBearer Token

Path Parameters:

ParameterTypeRequiredDescription
idintegerYesUser 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.

PropertyValue
EndpointDelete User
MethodDELETE
URL/api/v1/users/{id}
AuthenticationBearer Token

Query Parameters:

ParameterTypeRequiredDescription
isp_idintegerYesISP ID
branch_idintegerYesBranch ID
user_idintegerYesRequesting 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"
}

www.onezeroart.com