Skip to content

User - Packages

Base URL: https://your-domain.com

Admin endpoints for managing internet packages. All endpoints require admin/staff authentication.


Fetch All Packages

Retrieve all packages available in the system.

PropertyValue
EndpointFetch All Packages
MethodGET
URL/api/v1/packages
AuthenticationBearer Token

Request Headers:

HeaderValueRequired
Acceptapplication/jsonYes
AuthorizationBearer your-auth-tokenYes

Query Parameters:

ParameterTypeRequiredDescription
isp_idintegerYesISP ID
branch_idintegerYesBranch ID
user_idintegerYesUser ID

Request Body: None

Success Response (200 OK):

json
{
    "success": true,
    "data": [
        {
            "id": 1,
            "name": "10MB Package",
            "price": 1000,
            "validity_days": 30,
            "bandwidth_up": "10M",
            "bandwidth_down": "10M",
            "data_limit": null,
            "status": "active",
            "subscriber_count": 45
        }
    ]
}

Error Response (401 Unauthorized):

json
{
    "success": false,
    "message": "Unauthenticated"
}

Fetch Package

Retrieve details of a specific package.

PropertyValue
EndpointFetch Package
MethodGET
URL/api/v1/packages/{id}
AuthenticationBearer Token

Path Parameters:

ParameterTypeRequiredDescription
idintegerYesPackage ID

Query Parameters:

ParameterTypeRequiredDescription
isp_idintegerYesISP ID
branch_idintegerYesBranch ID
user_idintegerYesUser ID

Success Response (200 OK):

json
{
    "success": true,
    "data": {
        "id": 1,
        "name": "10MB Package",
        "price": 1000,
        "validity_days": 30,
        "bandwidth_up": "10M",
        "bandwidth_down": "10M",
        "data_limit": null,
        "burst_limit": "12M/12M",
        "priority": 8,
        "status": "active"
    }
}

Error Response (404 Not Found):

json
{
    "success": false,
    "message": "Package not found"
}

Create Package

Create a new internet package.

PropertyValue
EndpointCreate Package
MethodPOST
URL/api/v1/packages
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": "10MB Package",
    "price": 1000,
    "validity_days": 30,
    "bandwidth_up": "10M",
    "bandwidth_down": "10M"
}
ParameterTypeRequiredDescription
isp_idintegerYesISP ID
branch_idintegerYesBranch ID
user_idintegerYesUser ID
namestringYesPackage name
pricedecimalYesPackage price
validity_daysintegerNoValidity in days
bandwidth_upstringNoUpload bandwidth (e.g., "10M")
bandwidth_downstringNoDownload bandwidth (e.g., "10M")

Success Response (201 Created):

json
{
    "success": true,
    "message": "Package created successfully",
    "data": {
        "id": 1
    }
}

Error Response (422 Validation Error):

json
{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "name": ["The name field is required."]
    }
}

Update Package

Update an existing package.

PropertyValue
EndpointUpdate Package
MethodPUT
URL/api/v1/packages/{id}
AuthenticationBearer Token

Path Parameters:

ParameterTypeRequiredDescription
idintegerYesPackage ID

Request Body:

json
{
    "isp_id": 1,
    "branch_id": 1,
    "user_id": 1,
    "name": "10MB Package Updated",
    "price": 1200
}

Success Response (200 OK):

json
{
    "success": true,
    "message": "Package updated successfully"
}

Error Response (404 Not Found):

json
{
    "success": false,
    "message": "Package not found"
}

Delete Package

Delete a package from the system.

PropertyValue
EndpointDelete Package
MethodDELETE
URL/api/v1/packages/{id}
AuthenticationBearer Token

Query Parameters:

ParameterTypeRequiredDescription
isp_idintegerYesISP ID
branch_idintegerYesBranch ID
user_idintegerYesUser ID

Success Response (200 OK):

json
{
    "success": true,
    "message": "Package deleted successfully"
}

Error Response (400 Bad Request):

json
{
    "success": false,
    "message": "Cannot delete package with active subscribers"
}

Get My Packages

Get packages assigned to the current salesperson/reseller.

PropertyValue
EndpointGet My Packages
MethodGET
URL/api/v1/packages/my-packages
AuthenticationBearer Token

Query Parameters:

ParameterTypeRequiredDescription
isp_idintegerYesISP ID
branch_idintegerYesBranch ID
salesperson_idintegerYesSalesperson ID

Success Response (200 OK):

json
{
    "success": true,
    "data": [
        {
            "id": 1,
            "name": "10MB Package",
            "price": 800,
            "profit": 100,
            "original_price": 1000
        }
    ]
}

Assign Package

Assign a package to a reseller with custom pricing.

PropertyValue
EndpointAssign Package
MethodPOST
URL/api/v1/packages/{id}/assign
AuthenticationBearer Token

Path Parameters:

ParameterTypeRequiredDescription
idintegerYesPackage ID

Request Body:

json
{
    "reseller_id": 2,
    "price": 800,
    "profit": 100
}
ParameterTypeRequiredDescription
reseller_idintegerYesReseller user ID
pricedecimalYesReseller's selling price
profitdecimalNoProfit margin

Success Response (201 Created):

json
{
    "success": true,
    "message": "Package assigned successfully"
}

Get Package Assignments

Get all reseller assignments for a package.

PropertyValue
EndpointGet Package Assignments
MethodGET
URL/api/v1/packages/{id}/assignments
AuthenticationBearer Token

Success Response (200 OK):

json
{
    "success": true,
    "data": [
        {
            "assignment_id": 1,
            "reseller_id": 2,
            "reseller_name": "Reseller One",
            "price": 800,
            "profit": 100
        }
    ]
}

Update Assignment

Update a package assignment for a reseller.

PropertyValue
EndpointUpdate Assignment
MethodPUT
URL/api/v1/packages/{id}/assignments/{assignment_id}
AuthenticationBearer Token

Request Body:

json
{
    "price": 850,
    "profit": 150
}

Success Response (200 OK):

json
{
    "success": true,
    "message": "Assignment updated successfully"
}

Remove Assignment

Remove a package assignment from a reseller.

PropertyValue
EndpointRemove Assignment
MethodDELETE
URL/api/v1/packages/{id}/assignments/{assignment_id}
AuthenticationBearer Token

Success Response (200 OK):

json
{
    "success": true,
    "message": "Assignment removed successfully"
}

www.onezeroart.com