Appearance
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.
| Property | Value |
|---|---|
| Endpoint | Fetch All Packages |
| Method | GET |
| URL | /api/v1/packages |
| 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 |
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"
}Code Examples:
bash
curl -X GET "https://your-domain.com/api/v1/packages?isp_id=1&branch_id=1&user_id=1" \
-H "Accept: application/json" \
-H "Authorization: Bearer your-auth-token"php
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://your-domain.com']);
$response = $client->request('GET', '/api/v1/packages', [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer your-auth-token',
],
'query' => [
'isp_id' => 1,
'branch_id' => 1,
'user_id' => 1,
],
]);
$data = json_decode($response->getBody(), true);
print_r($data);javascript
const BASE_URL = 'https://your-domain.com';
const TOKEN = 'your-auth-token';
const params = new URLSearchParams({
isp_id: 1,
branch_id: 1,
user_id: 1,
});
const response = await fetch(`${BASE_URL}/api/v1/packages?${params}`, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${TOKEN}`,
},
});
const data = await response.json();
console.log(data);python
import requests
BASE_URL = "https://your-domain.com"
TOKEN = "your-auth-token"
response = requests.get(
f"{BASE_URL}/api/v1/packages",
headers={
"Accept": "application/json",
"Authorization": f"Bearer {TOKEN}",
},
params={
"isp_id": 1,
"branch_id": 1,
"user_id": 1,
},
)
data = response.json()
print(data)go
package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
const baseURL = "https://your-domain.com"
const token = "your-auth-token"
func main() {
endpoint := baseURL + "/api/v1/packages"
q := url.Values{}
q.Set("isp_id", "1")
q.Set("branch_id", "1")
q.Set("user_id", "1")
endpoint += "?" + q.Encode()
req, _ := http.NewRequest("GET", endpoint, nil)
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(body))
}rust
use reqwest::Client;
const BASE_URL: &str = "https://your-domain.com";
const TOKEN: &str = "your-auth-token";
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let response = client
.get(format!("{BASE_URL}/api/v1/packages"))
.header("Accept", "application/json")
.bearer_auth(TOKEN)
.query(&[
("isp_id", "1"),
("branch_id", "1"),
("user_id", "1"),
])
.send()
.await?;
let data: serde_json::Value = response.json().await?;
println!("{data:#}");
Ok(())
}Fetch Package
Retrieve details of a specific package.
| Property | Value |
|---|---|
| Endpoint | Fetch Package |
| Method | GET |
| URL | /api/v1/packages/{id} |
| Authentication | Bearer Token |
Path Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | Yes | Package ID |
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
isp_id | integer | Yes | ISP ID |
branch_id | integer | Yes | Branch ID |
user_id | integer | Yes | User 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"
}Code Examples:
bash
curl -X GET "https://your-domain.com/api/v1/packages/1?isp_id=1&branch_id=1&user_id=1" \
-H "Accept: application/json" \
-H "Authorization: Bearer your-auth-token"php
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://your-domain.com']);
$packageId = 1;
$response = $client->request('GET', "/api/v1/packages/{$packageId}", [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer your-auth-token',
],
'query' => [
'isp_id' => 1,
'branch_id' => 1,
'user_id' => 1,
],
]);
$data = json_decode($response->getBody(), true);
print_r($data);javascript
const BASE_URL = 'https://your-domain.com';
const TOKEN = 'your-auth-token';
const packageId = 1;
const params = new URLSearchParams({
isp_id: 1,
branch_id: 1,
user_id: 1,
});
const response = await fetch(`${BASE_URL}/api/v1/packages/${packageId}?${params}`, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${TOKEN}`,
},
});
const data = await response.json();
console.log(data);python
import requests
BASE_URL = "https://your-domain.com"
TOKEN = "your-auth-token"
package_id = 1
response = requests.get(
f"{BASE_URL}/api/v1/packages/{package_id}",
headers={
"Accept": "application/json",
"Authorization": f"Bearer {TOKEN}",
},
params={
"isp_id": 1,
"branch_id": 1,
"user_id": 1,
},
)
data = response.json()
print(data)go
package main
import (
"fmt"
"io"
"net/http"
"net/url"
"strconv"
)
const baseURL = "https://your-domain.com"
const token = "your-auth-token"
func main() {
packageId := 1
endpoint := baseURL + "/api/v1/packages/" + strconv.Itoa(packageId)
q := url.Values{}
q.Set("isp_id", "1")
q.Set("branch_id", "1")
q.Set("user_id", "1")
endpoint += "?" + q.Encode()
req, _ := http.NewRequest("GET", endpoint, nil)
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(body))
}rust
use reqwest::Client;
const BASE_URL: &str = "https://your-domain.com";
const TOKEN: &str = "your-auth-token";
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let package_id = 1;
let response = client
.get(format!("{BASE_URL}/api/v1/packages/{package_id}"))
.header("Accept", "application/json")
.bearer_auth(TOKEN)
.query(&[
("isp_id", "1"),
("branch_id", "1"),
("user_id", "1"),
])
.send()
.await?;
let data: serde_json::Value = response.json().await?;
println!("{data:#}");
Ok(())
}Create Package
Create a new internet package.
| Property | Value |
|---|---|
| Endpoint | Create Package |
| Method | POST |
| URL | /api/v1/packages |
| 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": "10MB Package",
"price": 1000,
"validity_days": 30,
"bandwidth_up": "10M",
"bandwidth_down": "10M"
}| Parameter | Type | Required | Description |
|---|---|---|---|
isp_id | integer | Yes | ISP ID |
branch_id | integer | Yes | Branch ID |
user_id | integer | Yes | User ID |
name | string | Yes | Package name |
price | decimal | Yes | Package price |
validity_days | integer | No | Validity in days |
bandwidth_up | string | No | Upload bandwidth (e.g., "10M") |
bandwidth_down | string | No | Download 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."]
}
}Code Examples:
bash
curl -X POST "https://your-domain.com/api/v1/packages" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-auth-token" \
-d '{
"isp_id": 1,
"branch_id": 1,
"user_id": 1,
"name": "10MB Package",
"price": 1000,
"validity_days": 30,
"bandwidth_up": "10M",
"bandwidth_down": "10M"
}'php
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://your-domain.com']);
$response = $client->request('POST', '/api/v1/packages', [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer your-auth-token',
],
'json' => [
'isp_id' => 1,
'branch_id' => 1,
'user_id' => 1,
'name' => '10MB Package',
'price' => 1000,
'validity_days' => 30,
'bandwidth_up' => '10M',
'bandwidth_down' => '10M',
],
]);
$data = json_decode($response->getBody(), true);
print_r($data);javascript
const BASE_URL = 'https://your-domain.com';
const TOKEN = 'your-auth-token';
const response = await fetch(`${BASE_URL}/api/v1/packages`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${TOKEN}`,
},
body: JSON.stringify({
isp_id: 1,
branch_id: 1,
user_id: 1,
name: '10MB Package',
price: 1000,
validity_days: 30,
bandwidth_up: '10M',
bandwidth_down: '10M',
}),
});
const data = await response.json();
console.log(data);python
import requests
BASE_URL = "https://your-domain.com"
TOKEN = "your-auth-token"
response = requests.post(
f"{BASE_URL}/api/v1/packages",
headers={
"Accept": "application/json",
"Authorization": f"Bearer {TOKEN}",
},
json={
"isp_id": 1,
"branch_id": 1,
"user_id": 1,
"name": "10MB Package",
"price": 1000,
"validity_days": 30,
"bandwidth_up": "10M",
"bandwidth_down": "10M",
},
)
data = response.json()
print(data)go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
const baseURL = "https://your-domain.com"
const token = "your-auth-token"
func main() {
endpoint := baseURL + "/api/v1/packages"
payload, _ := json.Marshal(map[string]any{
"isp_id": 1,
"branch_id": 1,
"user_id": 1,
"name": "10MB Package",
"price": 1000,
"validity_days": 30,
"bandwidth_up": "10M",
"bandwidth_down": "10M",
})
req, _ := http.NewRequest("POST", endpoint, bytes.NewBuffer(payload))
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(body))
}rust
use reqwest::Client;
use serde_json::json;
const BASE_URL: &str = "https://your-domain.com";
const TOKEN: &str = "your-auth-token";
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let response = client
.post(format!("{BASE_URL}/api/v1/packages"))
.header("Accept", "application/json")
.bearer_auth(TOKEN)
.json(&json!({
"isp_id": 1,
"branch_id": 1,
"user_id": 1,
"name": "10MB Package",
"price": 1000,
"validity_days": 30,
"bandwidth_up": "10M",
"bandwidth_down": "10M"
}))
.send()
.await?;
let data: serde_json::Value = response.json().await?;
println!("{data:#}");
Ok(())
}Update Package
Update an existing package.
| Property | Value |
|---|---|
| Endpoint | Update Package |
| Method | PUT |
| URL | /api/v1/packages/{id} |
| Authentication | Bearer Token |
Path Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | Yes | Package 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"
}Code Examples:
bash
curl -X PUT "https://your-domain.com/api/v1/packages/1" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-auth-token" \
-d '{
"isp_id": 1,
"branch_id": 1,
"user_id": 1,
"name": "10MB Package Updated",
"price": 1200
}'php
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://your-domain.com']);
$packageId = 1;
$response = $client->request('PUT', "/api/v1/packages/{$packageId}", [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer your-auth-token',
],
'json' => [
'isp_id' => 1,
'branch_id' => 1,
'user_id' => 1,
'name' => '10MB Package Updated',
'price' => 1200,
],
]);
$data = json_decode($response->getBody(), true);
print_r($data);javascript
const BASE_URL = 'https://your-domain.com';
const TOKEN = 'your-auth-token';
const packageId = 1;
const response = await fetch(`${BASE_URL}/api/v1/packages/${packageId}`, {
method: 'PUT',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${TOKEN}`,
},
body: JSON.stringify({
isp_id: 1,
branch_id: 1,
user_id: 1,
name: '10MB Package Updated',
price: 1200,
}),
});
const data = await response.json();
console.log(data);python
import requests
BASE_URL = "https://your-domain.com"
TOKEN = "your-auth-token"
package_id = 1
response = requests.put(
f"{BASE_URL}/api/v1/packages/{package_id}",
headers={
"Accept": "application/json",
"Authorization": f"Bearer {TOKEN}",
},
json={
"isp_id": 1,
"branch_id": 1,
"user_id": 1,
"name": "10MB Package Updated",
"price": 1200,
},
)
data = response.json()
print(data)go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"strconv"
)
const baseURL = "https://your-domain.com"
const token = "your-auth-token"
func main() {
packageId := 1
endpoint := baseURL + "/api/v1/packages/" + strconv.Itoa(packageId)
payload, _ := json.Marshal(map[string]any{
"isp_id": 1,
"branch_id": 1,
"user_id": 1,
"name": "10MB Package Updated",
"price": 1200,
})
req, _ := http.NewRequest("PUT", endpoint, bytes.NewBuffer(payload))
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(body))
}rust
use reqwest::Client;
use serde_json::json;
const BASE_URL: &str = "https://your-domain.com";
const TOKEN: &str = "your-auth-token";
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let package_id = 1;
let response = client
.put(format!("{BASE_URL}/api/v1/packages/{package_id}"))
.header("Accept", "application/json")
.bearer_auth(TOKEN)
.json(&json!({
"isp_id": 1,
"branch_id": 1,
"user_id": 1,
"name": "10MB Package Updated",
"price": 1200
}))
.send()
.await?;
let data: serde_json::Value = response.json().await?;
println!("{data:#}");
Ok(())
}Delete Package
Delete a package from the system.
| Property | Value |
|---|---|
| Endpoint | Delete Package |
| Method | DELETE |
| URL | /api/v1/packages/{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 | User 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"
}Code Examples:
bash
curl -X DELETE "https://your-domain.com/api/v1/packages/1?isp_id=1&branch_id=1&user_id=1" \
-H "Accept: application/json" \
-H "Authorization: Bearer your-auth-token"php
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://your-domain.com']);
$packageId = 1;
$response = $client->request('DELETE', "/api/v1/packages/{$packageId}", [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer your-auth-token',
],
'query' => [
'isp_id' => 1,
'branch_id' => 1,
'user_id' => 1,
],
]);
$data = json_decode($response->getBody(), true);
print_r($data);javascript
const BASE_URL = 'https://your-domain.com';
const TOKEN = 'your-auth-token';
const packageId = 1;
const params = new URLSearchParams({
isp_id: 1,
branch_id: 1,
user_id: 1,
});
const response = await fetch(`${BASE_URL}/api/v1/packages/${packageId}?${params}`, {
method: 'DELETE',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${TOKEN}`,
},
});
const data = await response.json();
console.log(data);python
import requests
BASE_URL = "https://your-domain.com"
TOKEN = "your-auth-token"
package_id = 1
response = requests.delete(
f"{BASE_URL}/api/v1/packages/{package_id}",
headers={
"Accept": "application/json",
"Authorization": f"Bearer {TOKEN}",
},
params={
"isp_id": 1,
"branch_id": 1,
"user_id": 1,
},
)
data = response.json()
print(data)go
package main
import (
"fmt"
"io"
"net/http"
"net/url"
"strconv"
)
const baseURL = "https://your-domain.com"
const token = "your-auth-token"
func main() {
packageId := 1
endpoint := baseURL + "/api/v1/packages/" + strconv.Itoa(packageId)
q := url.Values{}
q.Set("isp_id", "1")
q.Set("branch_id", "1")
q.Set("user_id", "1")
endpoint += "?" + q.Encode()
req, _ := http.NewRequest("DELETE", endpoint, nil)
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(body))
}rust
use reqwest::Client;
const BASE_URL: &str = "https://your-domain.com";
const TOKEN: &str = "your-auth-token";
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let package_id = 1;
let response = client
.delete(format!("{BASE_URL}/api/v1/packages/{package_id}"))
.header("Accept", "application/json")
.bearer_auth(TOKEN)
.query(&[
("isp_id", "1"),
("branch_id", "1"),
("user_id", "1"),
])
.send()
.await?;
let data: serde_json::Value = response.json().await?;
println!("{data:#}");
Ok(())
}Get My Packages
Get packages assigned to the current salesperson/reseller.
| Property | Value |
|---|---|
| Endpoint | Get My Packages |
| Method | GET |
| URL | /api/v1/packages/my-packages |
| Authentication | Bearer Token |
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
isp_id | integer | Yes | ISP ID |
branch_id | integer | Yes | Branch ID |
salesperson_id | integer | Yes | Salesperson ID |
Success Response (200 OK):
json
{
"success": true,
"data": [
{
"id": 1,
"name": "10MB Package",
"price": 800,
"profit": 100,
"original_price": 1000
}
]
}Code Examples:
bash
curl -X GET "https://your-domain.com/api/v1/packages/my-packages?isp_id=1&branch_id=1&salesperson_id=1" \
-H "Accept: application/json" \
-H "Authorization: Bearer your-auth-token"php
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://your-domain.com']);
$response = $client->request('GET', '/api/v1/packages/my-packages', [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer your-auth-token',
],
'query' => [
'isp_id' => 1,
'branch_id' => 1,
'salesperson_id' => 1,
],
]);
$data = json_decode($response->getBody(), true);
print_r($data);javascript
const BASE_URL = 'https://your-domain.com';
const TOKEN = 'your-auth-token';
const params = new URLSearchParams({
isp_id: 1,
branch_id: 1,
salesperson_id: 1,
});
const response = await fetch(`${BASE_URL}/api/v1/packages/my-packages?${params}`, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${TOKEN}`,
},
});
const data = await response.json();
console.log(data);python
import requests
BASE_URL = "https://your-domain.com"
TOKEN = "your-auth-token"
response = requests.get(
f"{BASE_URL}/api/v1/packages/my-packages",
headers={
"Accept": "application/json",
"Authorization": f"Bearer {TOKEN}",
},
params={
"isp_id": 1,
"branch_id": 1,
"salesperson_id": 1,
},
)
data = response.json()
print(data)go
package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
const baseURL = "https://your-domain.com"
const token = "your-auth-token"
func main() {
endpoint := baseURL + "/api/v1/packages/my-packages"
q := url.Values{}
q.Set("isp_id", "1")
q.Set("branch_id", "1")
q.Set("salesperson_id", "1")
endpoint += "?" + q.Encode()
req, _ := http.NewRequest("GET", endpoint, nil)
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(body))
}rust
use reqwest::Client;
const BASE_URL: &str = "https://your-domain.com";
const TOKEN: &str = "your-auth-token";
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let response = client
.get(format!("{BASE_URL}/api/v1/packages/my-packages"))
.header("Accept", "application/json")
.bearer_auth(TOKEN)
.query(&[
("isp_id", "1"),
("branch_id", "1"),
("salesperson_id", "1"),
])
.send()
.await?;
let data: serde_json::Value = response.json().await?;
println!("{data:#}");
Ok(())
}Assign Package
Assign a package to a reseller with custom pricing.
| Property | Value |
|---|---|
| Endpoint | Assign Package |
| Method | POST |
| URL | /api/v1/packages/{id}/assign |
| Authentication | Bearer Token |
Path Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | Yes | Package ID |
Request Body:
json
{
"reseller_id": 2,
"price": 800,
"profit": 100
}| Parameter | Type | Required | Description |
|---|---|---|---|
reseller_id | integer | Yes | Reseller user ID |
price | decimal | Yes | Reseller's selling price |
profit | decimal | No | Profit margin |
Success Response (201 Created):
json
{
"success": true,
"message": "Package assigned successfully"
}Code Examples:
bash
curl -X POST "https://your-domain.com/api/v1/packages/1/assign" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-auth-token" \
-d '{
"reseller_id": 2,
"price": 800,
"profit": 100
}'php
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://your-domain.com']);
$packageId = 1;
$response = $client->request('POST', "/api/v1/packages/{$packageId}/assign", [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer your-auth-token',
],
'json' => [
'reseller_id' => 2,
'price' => 800,
'profit' => 100,
],
]);
$data = json_decode($response->getBody(), true);
print_r($data);javascript
const BASE_URL = 'https://your-domain.com';
const TOKEN = 'your-auth-token';
const packageId = 1;
const response = await fetch(`${BASE_URL}/api/v1/packages/${packageId}/assign`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${TOKEN}`,
},
body: JSON.stringify({
reseller_id: 2,
price: 800,
profit: 100,
}),
});
const data = await response.json();
console.log(data);python
import requests
BASE_URL = "https://your-domain.com"
TOKEN = "your-auth-token"
package_id = 1
response = requests.post(
f"{BASE_URL}/api/v1/packages/{package_id}/assign",
headers={
"Accept": "application/json",
"Authorization": f"Bearer {TOKEN}",
},
json={
"reseller_id": 2,
"price": 800,
"profit": 100,
},
)
data = response.json()
print(data)go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"strconv"
)
const baseURL = "https://your-domain.com"
const token = "your-auth-token"
func main() {
packageId := 1
endpoint := baseURL + "/api/v1/packages/" + strconv.Itoa(packageId) + "/assign"
payload, _ := json.Marshal(map[string]any{
"reseller_id": 2,
"price": 800,
"profit": 100,
})
req, _ := http.NewRequest("POST", endpoint, bytes.NewBuffer(payload))
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(body))
}rust
use reqwest::Client;
use serde_json::json;
const BASE_URL: &str = "https://your-domain.com";
const TOKEN: &str = "your-auth-token";
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let package_id = 1;
let response = client
.post(format!("{BASE_URL}/api/v1/packages/{package_id}/assign"))
.header("Accept", "application/json")
.bearer_auth(TOKEN)
.json(&json!({
"reseller_id": 2,
"price": 800,
"profit": 100
}))
.send()
.await?;
let data: serde_json::Value = response.json().await?;
println!("{data:#}");
Ok(())
}Get Package Assignments
Get all reseller assignments for a package.
| Property | Value |
|---|---|
| Endpoint | Get Package Assignments |
| Method | GET |
| URL | /api/v1/packages/{id}/assignments |
| Authentication | Bearer Token |
Success Response (200 OK):
json
{
"success": true,
"data": [
{
"assignment_id": 1,
"reseller_id": 2,
"reseller_name": "Reseller One",
"price": 800,
"profit": 100
}
]
}Code Examples:
bash
curl -X GET "https://your-domain.com/api/v1/packages/1/assignments" \
-H "Accept: application/json" \
-H "Authorization: Bearer your-auth-token"php
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://your-domain.com']);
$packageId = 1;
$response = $client->request('GET', "/api/v1/packages/{$packageId}/assignments", [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer your-auth-token',
],
]);
$data = json_decode($response->getBody(), true);
print_r($data);javascript
const BASE_URL = 'https://your-domain.com';
const TOKEN = 'your-auth-token';
const packageId = 1;
const response = await fetch(`${BASE_URL}/api/v1/packages/${packageId}/assignments`, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${TOKEN}`,
},
});
const data = await response.json();
console.log(data);python
import requests
BASE_URL = "https://your-domain.com"
TOKEN = "your-auth-token"
package_id = 1
response = requests.get(
f"{BASE_URL}/api/v1/packages/{package_id}/assignments",
headers={
"Accept": "application/json",
"Authorization": f"Bearer {TOKEN}",
},
)
data = response.json()
print(data)go
package main
import (
"fmt"
"io"
"net/http"
"strconv"
)
const baseURL = "https://your-domain.com"
const token = "your-auth-token"
func main() {
packageId := 1
endpoint := baseURL + "/api/v1/packages/" + strconv.Itoa(packageId) + "/assignments"
req, _ := http.NewRequest("GET", endpoint, nil)
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(body))
}rust
use reqwest::Client;
const BASE_URL: &str = "https://your-domain.com";
const TOKEN: &str = "your-auth-token";
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let package_id = 1;
let response = client
.get(format!("{BASE_URL}/api/v1/packages/{package_id}/assignments"))
.header("Accept", "application/json")
.bearer_auth(TOKEN)
.send()
.await?;
let data: serde_json::Value = response.json().await?;
println!("{data:#}");
Ok(())
}Update Assignment
Update a package assignment for a reseller.
| Property | Value |
|---|---|
| Endpoint | Update Assignment |
| Method | PUT |
| URL | /api/v1/packages/{id}/assignments/{assignment_id} |
| Authentication | Bearer Token |
Request Body:
json
{
"price": 850,
"profit": 150
}Success Response (200 OK):
json
{
"success": true,
"message": "Assignment updated successfully"
}Code Examples:
bash
curl -X PUT "https://your-domain.com/api/v1/packages/1/assignments/1" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-auth-token" \
-d '{
"price": 850,
"profit": 150
}'php
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://your-domain.com']);
$packageId = 1;
$assignmentId = 1;
$response = $client->request('PUT', "/api/v1/packages/{$packageId}/assignments/{$assignmentId}", [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer your-auth-token',
],
'json' => [
'price' => 850,
'profit' => 150,
],
]);
$data = json_decode($response->getBody(), true);
print_r($data);javascript
const BASE_URL = 'https://your-domain.com';
const TOKEN = 'your-auth-token';
const packageId = 1;
const assignmentId = 1;
const response = await fetch(`${BASE_URL}/api/v1/packages/${packageId}/assignments/${assignmentId}`, {
method: 'PUT',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${TOKEN}`,
},
body: JSON.stringify({
price: 850,
profit: 150,
}),
});
const data = await response.json();
console.log(data);python
import requests
BASE_URL = "https://your-domain.com"
TOKEN = "your-auth-token"
package_id = 1
assignment_id = 1
response = requests.put(
f"{BASE_URL}/api/v1/packages/{package_id}/assignments/{assignment_id}",
headers={
"Accept": "application/json",
"Authorization": f"Bearer {TOKEN}",
},
json={
"price": 850,
"profit": 150,
},
)
data = response.json()
print(data)go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"strconv"
)
const baseURL = "https://your-domain.com"
const token = "your-auth-token"
func main() {
packageId := 1
assignmentId := 1
endpoint := baseURL + "/api/v1/packages/" + strconv.Itoa(packageId) + "/assignments/" + strconv.Itoa(assignmentId)
payload, _ := json.Marshal(map[string]any{
"price": 850,
"profit": 150,
})
req, _ := http.NewRequest("PUT", endpoint, bytes.NewBuffer(payload))
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(body))
}rust
use reqwest::Client;
use serde_json::json;
const BASE_URL: &str = "https://your-domain.com";
const TOKEN: &str = "your-auth-token";
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let package_id = 1;
let assignment_id = 1;
let response = client
.put(format!("{BASE_URL}/api/v1/packages/{package_id}/assignments/{assignment_id}"))
.header("Accept", "application/json")
.bearer_auth(TOKEN)
.json(&json!({
"price": 850,
"profit": 150
}))
.send()
.await?;
let data: serde_json::Value = response.json().await?;
println!("{data:#}");
Ok(())
}Remove Assignment
Remove a package assignment from a reseller.
| Property | Value |
|---|---|
| Endpoint | Remove Assignment |
| Method | DELETE |
| URL | /api/v1/packages/{id}/assignments/{assignment_id} |
| Authentication | Bearer Token |
Success Response (200 OK):
json
{
"success": true,
"message": "Assignment removed successfully"
}Code Examples:
bash
curl -X DELETE "https://your-domain.com/api/v1/packages/1/assignments/1" \
-H "Accept: application/json" \
-H "Authorization: Bearer your-auth-token"php
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://your-domain.com']);
$packageId = 1;
$assignmentId = 1;
$response = $client->request('DELETE', "/api/v1/packages/{$packageId}/assignments/{$assignmentId}", [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer your-auth-token',
],
]);
$data = json_decode($response->getBody(), true);
print_r($data);javascript
const BASE_URL = 'https://your-domain.com';
const TOKEN = 'your-auth-token';
const packageId = 1;
const assignmentId = 1;
const response = await fetch(`${BASE_URL}/api/v1/packages/${packageId}/assignments/${assignmentId}`, {
method: 'DELETE',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${TOKEN}`,
},
});
const data = await response.json();
console.log(data);python
import requests
BASE_URL = "https://your-domain.com"
TOKEN = "your-auth-token"
package_id = 1
assignment_id = 1
response = requests.delete(
f"{BASE_URL}/api/v1/packages/{package_id}/assignments/{assignment_id}",
headers={
"Accept": "application/json",
"Authorization": f"Bearer {TOKEN}",
},
)
data = response.json()
print(data)go
package main
import (
"fmt"
"io"
"net/http"
"strconv"
)
const baseURL = "https://your-domain.com"
const token = "your-auth-token"
func main() {
packageId := 1
assignmentId := 1
endpoint := baseURL + "/api/v1/packages/" + strconv.Itoa(packageId) + "/assignments/" + strconv.Itoa(assignmentId)
req, _ := http.NewRequest("DELETE", endpoint, nil)
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(body))
}rust
use reqwest::Client;
const BASE_URL: &str = "https://your-domain.com";
const TOKEN: &str = "your-auth-token";
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let package_id = 1;
let assignment_id = 1;
let response = client
.delete(format!("{BASE_URL}/api/v1/packages/{package_id}/assignments/{assignment_id}"))
.header("Accept", "application/json")
.bearer_auth(TOKEN)
.send()
.await?;
let data: serde_json::Value = response.json().await?;
println!("{data:#}");
Ok(())
}