Docs/Reseller API/Reference

Reseller Platform - Master Documentation

Complete API reference with verified responses

Version: 1.0.0Last Updated: January 19, 2026API Base URL: https://api.proxies.sx/v1

1. Platform Overview

What is the Reseller Platform?

The Proxies.sx Reseller Platform enables authorized partners to build their own mobile proxy business on top of our infrastructure. As a reseller, you can:

  • Create sub-accounts for your customers
  • Set your own pricing with configurable margins
  • Manage quotas for port slots and traffic
  • Receive webhooks for real-time event notifications
  • Track revenue with detailed analytics

Business Model

┌─────────────────────────────────────────────────────────────────┐
│                    RESELLER BUSINESS MODEL                       │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  Proxies.sx (Platform)                                          │
│  └── Provides: Infrastructure, Devices, API                     │
│       │                                                         │
│       ▼                                                         │
│  Reseller (You)                                                 │
│  └── Provides: Branding, Support, Custom Pricing                │
│       │                                                         │
│       ▼                                                         │
│  Your Customers                                                 │
│  └── Use: Proxies via YOUR application                         │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Key Concepts

ConceptDescription
ResellerYour account on Proxies.sx with `role: reseller`
Sub-AccountA customer you create under your reseller account
Port SlotAllocated capacity for creating proxy ports
PricebookYour pricing configuration (margins, overrides)
WebhookReal-time event notifications to your system

2. Architecture

System Architecture

┌─────────────────────────────────────────────────────────────────────────────┐
│                              ARCHITECTURE                                    │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│  ┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐       │
│  │ Your Customer   │     │ Your Backend    │     │  Proxies.sx API │       │
│  │ (End User)      │     │ (Your Code)     │     │  (Our System)   │       │
│  └────────┬────────┘     └────────┬────────┘     └────────┬────────┘       │
│           │                       │                       │                │
│           │ "Buy proxy"           │                       │                │
│           │──────────────────────▶│                       │                │
│           │                       │                       │                │
│           │                       │ POST /reseller/ports  │                │
│           │                       │──────────────────────▶│                │
│           │                       │                       │                │
│           │                       │    { port details }   │                │
│           │                       │◀──────────────────────│                │
│           │                       │                       │                │
│           │ "Your proxy: IP:8080" │                       │                │
│           │◀──────────────────────│                       │                │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

Data Model

User (role: reseller)
├── balance: number              # Your account balance
├── resellerConfig               # Platform settings
│
├── ResellerCustomers[]          # Your sub-accounts
│   ├── email, name, company
│   ├── allocatedPortSlots       # Quota limit
│   ├── usedPortSlots            # Current usage
│   ├── balance                  # Customer's balance
│   └── status: active|suspended
│
├── ResellerPricebook            # Your pricing
│   ├── pricingMode: margin|fixed|multiplier
│   ├── defaultMarginPercent
│   └── countryOverrides[]
│
├── ResellerWebhooks[]           # Event subscriptions
│   ├── url, events[], secret
│   └── isActive
│
└── Ports[]                      # Created for customers
    ├── resellerId               # Links to you
    ├── resellerCustomerId       # Links to customer
    └── (port details)

3. Getting Started

Prerequisites

  1. A Proxies.sx account with reseller role
  2. Sufficient balance in your account
  3. An API key with appropriate scopes

Step 1: Get Your Account Ready

Contact Proxies.sx support to upgrade your account to reseller role, or if you have admin access:

# Admin assigns reseller role
PATCH /v1/users/{userId}/role
{"role": "reseller"}

Step 2: Add Balance to Your Account

Your balance is the pool from which customer topups and port purchases are deducted.

# Admin adds balance (or use payment methods)
POST /v1/billing/payment
{
  "userId": "your_user_id",
  "amount": 1000,
  "method": "admin_credit"
}

Step 3: Create an API Key

curl -X POST https://api.proxies.sx/v1/api-keys \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production API Key",
    "scopes": [
      "customers:read", "customers:write",
      "ports:read", "ports:write",
      "webhooks:read", "webhooks:write",
      "billing:read", "billing:write"
    ]
  }'

Step 4: Create Your First Customer

curl -X POST https://api.proxies.sx/v1/reseller/customers \
  -H "X-API-Key: psx_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "customer@example.com",
    "name": "My First Customer",
    "company": "Customer Corp",
    "allocatedPortSlots": 10,
    "allocatedTrafficGB": 100
  }'

4. Authentication

Methods

MethodHeaderUse Case
JWT BearerAuthorization: Bearer <token>Web apps, dashboards
API KeyX-API-Key: <key>Scripts, integrations, servers

Get JWT Token

POST /v1/login/signin
Content-Type: application/json

{
  "email": "reseller@example.com",
  "password": "your_password"
}

API Key Scopes

ScopeDescription
customers:readView sub-accounts
customers:writeCreate, update, suspend customers
ports:readView port information
ports:writeCreate, rotate, delete ports
webhooks:readView webhook configurations
webhooks:writeManage webhooks
billing:readView pricing and analytics
billing:writeTop up customers

5. Customer Management

Create Customer

POST /v1/reseller/customers
Content-Type: application/json
X-API-Key: psx_xxx

{
  "email": "customer@example.com",
  "name": "Customer Name",
  "company": "Company Name",
  "allocatedPortSlots": 10,
  "allocatedTrafficGB": 100,
  "externalId": "YOUR-CRM-ID-123",
  "initialBalance": 50
}

List Customers

GET /v1/reseller/customers?status=active&limit=20&skip=0

Top Up Customer Balance

Important: This deducts from YOUR reseller balance! Customer balance is for YOUR internal accounting - tracking credits you've given your customers. Port creation still charges YOUR reseller balance, not the customer's balance.

Flow:

  1. Checks YOUR reseller balance ≥ amount
  2. Deducts amount from YOUR reseller balance
  3. Adds amount to customer's internal balance
POST /v1/reseller/customers/{customerId}/topup
Content-Type: application/json

{
  "amount": 100,
  "description": "Monthly credit",
  "referenceId": "INV-001"
}

Error 403: Insufficient reseller balance

Suspend/Unsuspend Customer

POST /v1/reseller/customers/{customerId}/suspend
{"reason": "Payment overdue"}

POST /v1/reseller/customers/{customerId}/unsuspend

Manage Quotas

# Set absolute quota
PUT /v1/reseller/customers/{customerId}/quota
{"portSlots": 20, "trafficGB": 200}

# Adjust quota incrementally
PATCH /v1/reseller/customers/{customerId}/quota
{"portSlotsDelta": 5, "trafficGBDelta": 50}

6. Port Operations

Create Port for Customer

Important: Port creation charges YOUR reseller balance (not the customer's balance)!

Charging flow:

  1. We check YOUR balance has basePrice × days available
  2. We create the port
  3. We deduct basePrice × days from YOUR reseller balance
  4. The pricing.resellerPrice tells you what to charge your customer
POST /v1/reseller/ports
Content-Type: application/json

{
  "customerId": "customer_id",
  "countryId": "country_id",
  "cityId": "city_id",        // optional
  "carrierId": "carrier_id",   // optional
  "days": 30,
  "exclusive": false,
  "isPrivate": false
}
Responsejson
{
  "port": {
    "_id": "port_id",
    "displayName": "psx_abc_xyz",
    "httpPort": 10001,
    "socksPort": 10002,
    "proxyLogin": "user123",
    "proxyPassword": "pass456",
    "serverIp": "1.2.3.4",
    "expiresAt": 1740000000000
  },
  "pricing": {
    "costToReseller": 60.00,   // What WE charged YOU
    "resellerPrice": 75.00,    // What YOU should charge YOUR customer
    "margin": 15.00            // Your profit
  }
}

Error 402: Insufficient balance - your account doesn't have enough funds

List Ports

# All ports
GET /v1/reseller/ports

# Ports for specific customer
GET /v1/reseller/ports/customer/{customerId}

# Expiring soon
GET /v1/reseller/ports/expiring?hours=24

# Summary stats
GET /v1/reseller/ports/summary

Rotate Port

POST /v1/reseller/ports/{portId}/rotate

Suspend/Unsuspend Port

POST /v1/reseller/ports/{portId}/suspend
{"reason": "Customer request"}

POST /v1/reseller/ports/{portId}/unsuspend

Extend Port Time

POST /v1/reseller/ports/{portId}/extend
{"hours": 720}

7. Pricing & Margins

Understanding the Pricing Model

The pricebook calculates what you should charge your customers (resellerPrice). You always pay us the base cost regardless of your pricebook settings.

┌─────────────────────────────────────────────────────────────────┐
│                     PRICING CALCULATION                          │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  Base Price (our cost to you)         = $2.00/day               │
│  Your Margin Setting                  = 25%                     │
│  Days Requested                       = 30                      │
│                                                                 │
│  ───────────────────────────────────────────────────            │
│                                                                 │
│  Cost to YOU (what we charge)         = $2 × 30 = $60           │
│  Reseller Price (what you charge)     = $60 × 1.25 = $75        │
│  Your Profit                          = $75 - $60 = $15         │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Pricing Modes

ModeDescriptionExample (base $2/day × 30 days)
`margin` (default)Add percentage markup to costCost $60 + 25% = $75 (you charge customer)
fixedFixed price regardless of base costFixed $3/day × 30 = $90 (you charge)
multiplierMultiply base cost by factorCost $60 × 1.5 = $90 (you charge)

Default Pricebook Settings

When your account is created:

{
  "pricingMode": "margin",
  "portPricing": { "marginPercent": 20 },
  "trafficPricing": { "marginPercent": 20 },
  "defaultMarginPercent": 20,
  "countryOverrides": [],
  "customerOverrides": []
}

Get Pricebook

GET /v1/reseller/pricebook

Update Pricebook

PUT /v1/reseller/pricebook
{
  "pricingMode": "margin",
  "defaultMarginPercent": 25,
  "portPricing": {
    "marginPercent": 25,
    "minimumPrice": 1.50
  },
  "trafficPricing": {
    "marginPercent": 30,
    "minimumPricePerGB": 0.50
  }
}

Country Overrides

Set fixed prices for specific countries (overrides margin calculation):

POST /v1/reseller/pricebook/country-override
{
  "countryId": "country_id",
  "portPricePerDay": 3.50,
  "trafficPricePerGB": 0.75
}

Customer Overrides

Give specific customers different margins or discounts:

PUT /v1/reseller/pricebook
{
  "customerOverrides": [
    {
      "customerId": "vip_customer_id",
      "marginPercent": 15,
      "discountPercent": 5
    }
  ]
}

Calculate Price

Preview pricing before creating a port:

POST /v1/reseller/pricebook/calculate
{
  "type": "port",
  "basePrice": 2.00,
  "days": 30,
  "countryId": "optional_country_id",
  "customerId": "optional_customer_id"
}
Responsejson
{
  "basePrice": 60.00,
  "resellerPrice": 75.00,
  "marginAmount": 15.00,
  "marginPercent": 25,
  "appliedRules": ["Margin: +25%", "30 days"]
}

8. Webhooks

Event Types

CategoryEvents
Portport.created`, `port.deleted`, `port.expiring`, `port.expired`, `port.rotated`, `port.suspended`, `port.unsuspended
Customercustomer.created`, `customer.updated`, `customer.suspended`, `customer.unsuspended`, `customer.quota_warning`, `customer.quota_exceeded
Traffictraffic.threshold_50`, `traffic.threshold_80`, `traffic.threshold_100
Billingbalance.low`, `balance.topup`, `purchase.completed

Create Webhook

POST /v1/reseller/webhooks
{
  "name": "Production Webhook",
  "url": "https://your-server.com/webhook",
  "events": ["port.created", "port.expired", "customer.quota_exceeded"]
}

Webhook Payload

{
  "id": "delivery_id",
  "event": "port.created",
  "timestamp": "2026-01-19T12:00:00.000Z",
  "data": {
    "portId": "...",
    "customerId": "...",
    "details": {}
  }
}

HMAC Verification

const crypto = require('crypto');

function verifySignature(payload, signature, secret) {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(JSON.stringify(payload))
    .digest('hex');
  return signature === `sha256=${expected}`;
}

Test Webhook

POST /v1/reseller/webhooks/{webhookId}/test
{"eventType": "port.created"}

9. Analytics & Reporting

Dashboard Overview

GET /v1/reseller/analytics/dashboard
Responsejson
{
  "customers": {"total": 50, "active": 45, "suspended": 5},
  "ports": {"total": 500, "active": 450, "expired": 50},
  "revenue": {"today": 150, "thisMonth": 4500, "total": 50000},
  "topCustomers": [...]
}

Revenue Reports

# Summary
GET /v1/reseller/analytics/revenue

# By period
GET /v1/reseller/analytics/revenue/by-period?period=day

# By customer
GET /v1/reseller/analytics/revenue/by-customer?limit=10

Commissions

GET /v1/reseller/analytics/commissions?startDate=2026-01-01&endDate=2026-01-31

10. Rate Limits

Endpoint Limits

CategoryEndpointLimit
CustomerPOST /customers10/min
CustomerPATCH /customers/:id30/min
CustomerPOST /customers/:id/topup20/min
PortPOST /ports5/10sec
PortPOST /ports/:id/rotate10/min
WebhookPOST /webhooks/:id/test5/min
AnalyticsAll GET endpoints30/min
DefaultOther endpoints100/min

Rate Limit Headers

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640000000

11. API Reference

Base URLs

EnvironmentURL
Productionhttps://api.proxies.sx/v1
Swagger Docshttps://api.proxies.sx/docs/seller
OpenAPI SpecGET /v1/reseller/docs/openapi
LLM ReferenceGET /v1/reseller/docs/llm

Customers Endpoints

MethodEndpointDescription
POST/reseller/customersCreate customer
GET/reseller/customersList customers
GET/reseller/customers/:idGet customer
PATCH/reseller/customers/:idUpdate customer
DELETE/reseller/customers/:idDelete customer
GET/reseller/customers/by-external-id/:externalIdFind by external ID
POST/reseller/customers/:id/suspendSuspend customer
POST/reseller/customers/:id/unsuspendUnsuspend customer
POST/reseller/customers/:id/topupAdd balance
PUT/reseller/customers/:id/quotaSet quota
PATCH/reseller/customers/:id/quotaAdjust quota
GET/reseller/customers/:id/usageGet usage stats
GET/reseller/customers/:id/quota-statusGet quota status

Ports Endpoints

MethodEndpointDescription
POST/reseller/portsCreate port
GET/reseller/portsList all ports
GET/reseller/ports/customer/:customerIdList customer ports
GET/reseller/ports/expiringList expiring ports
GET/reseller/ports/summaryPort statistics
GET/reseller/ports/:portIdGet port details
DELETE/reseller/ports/:portIdDelete port
POST/reseller/ports/:portId/rotateRotate port
POST/reseller/ports/:portId/extendExtend time
POST/reseller/ports/:portId/suspendSuspend port
POST/reseller/ports/:portId/unsuspendUnsuspend port
POST/reseller/ports/check-quotaCheck quota
POST/reseller/ports/calculate-priceCalculate price

Webhooks Endpoints

MethodEndpointDescription
POST/reseller/webhooksCreate webhook
GET/reseller/webhooksList webhooks
GET/reseller/webhooks/event-typesGet event types
GET/reseller/webhooks/:idGet webhook
PUT/reseller/webhooks/:idUpdate webhook
DELETE/reseller/webhooks/:idDelete webhook
POST/reseller/webhooks/:id/testTest webhook
GET/reseller/webhooks/:id/deliveriesGet deliveries

Pricebook Endpoints

MethodEndpointDescription
GET/reseller/pricebookGet pricebook
PUT/reseller/pricebookUpdate pricebook
POST/reseller/pricebook/calculateCalculate price
POST/reseller/pricebook/country-overrideAdd override
DELETE/reseller/pricebook/country-override/:idRemove override

Analytics Endpoints

MethodEndpointDescription
GET/reseller/analytics/dashboardDashboard stats
GET/reseller/analytics/revenueRevenue summary
GET/reseller/analytics/revenue/by-periodRevenue by period
GET/reseller/analytics/revenue/by-customerRevenue by customer
GET/reseller/analytics/commissionsCommission history

12. Admin Dashboard

Admin Endpoints for Reseller Management

Admins can manage resellers via these endpoints:

MethodEndpointDescription
GET/admin/resellersList all resellers
GET/admin/resellers/:idGet reseller details
GET/admin/resellers/:id/customersView reseller's customers
GET/admin/resellers/:id/portsView reseller's ports
POST/admin/resellers/:id/suspendSuspend reseller
POST/admin/resellers/:id/unsuspendUnsuspend reseller
POST/admin/resellers/:id/topupAdd balance
PUT/admin/resellers/:id/commission-rateSet commission

Admin Panel Pages

admin-panel/
├── Resellers.tsx           # Reseller list
├── ResellerDetail.tsx      # Detail view with tabs
├── ResellerAnalytics.tsx   # Platform-wide analytics
└── ResellerWebhooks.tsx    # Webhook monitoring

13. Testing & Validation

Test Checklist

  • Authentication works (JWT and API Key)
  • Customer CRUD operations work
  • Balance deductions work correctly
  • Port creation deducts from reseller
  • Webhooks deliver successfully
  • Rate limits trigger correctly
  • Analytics return data

Test Credentials (Development)

Reseller: reseller@test.com / ResellerPass123
API Key: psx_test_key_xxxxx

Verified Test Results

CategoryPassedTotal
Customer Endpoints1212
Webhook Endpoints88
Pricebook Endpoints55
Analytics Endpoints55
Port Endpoints613
Total3643

Note: 7 port tests skipped (require physical devices)

14. Troubleshooting

Common Errors

ErrorCauseSolution
401 UnauthorizedInvalid/expired tokenRefresh JWT or check API key
403 ForbiddenMissing role/scopeEnsure reseller role and proper scopes
402 Insufficient BalanceLow reseller balanceTop up your account
400 Quota ExceededCustomer at limitIncrease quota allocation
429 Too Many RequestsRate limit hitWait and retry with backoff

Debugging Tips

  1. Check response body for detailed error messages
  2. Verify API key has required scopes
  3. Ensure customer belongs to your reseller account
  4. Check balance before operations that deduct

Support

15. Changelog

v1.0.0 (January 2026)

Initial Release:

  • Customer management (CRUD, suspend, topup)
  • Port operations (create, rotate, extend)
  • Webhook system (17 event types)
  • Pricing configuration (margin, fixed, multiplier)
  • Analytics dashboard
  • Rate limiting on all endpoints

Bug Fixes:

  • Fixed customer topup not deducting from reseller balance (BUG-001)
  • Fixed port creation not charging reseller (BUG-002)

16. Complete API Response Reference

All responses below are verified against the live production API (tested January 19, 2026).

Customer Responses

Create Customer (POST /reseller/customers)

{
  "_id": "696dea7dadd92285d1bb784d",
  "resellerId": "69344abf4e8861b9e9986744",
  "email": "customer@example.com",
  "name": "Customer Name",
  "company": "Company Name",
  "status": "active",
  "allocatedPortSlots": 10,
  "allocatedTrafficGB": 100,
  "usedPortSlots": 0,
  "usedTrafficGB": 0,
  "balance": 0,
  "totalSpent": 0,
  "totalTopUp": 0,
  "canCreatePorts": true,
  "canRotatePorts": true,
  "externalId": "YOUR-CRM-ID",
  "isDeleted": false,
  "deletedAt": null,
  "createdAt": "2026-01-19T08:25:33.009Z",
  "updatedAt": "2026-01-19T08:25:33.009Z",
  "__v": 0,
  "id": "696dea7dadd92285d1bb784d"
}

List Customers (GET /reseller/customers)

{
  "customers": [
    {
      "_id": "...",
      "email": "...",
      "name": "...",
      "status": "active",
      "allocatedPortSlots": 10,
      "usedPortSlots": 2,
      "balance": 100
    }
  ],
  "total": 1,
  "skip": 0,
  "limit": 20
}

Customer Usage Stats (GET /reseller/customers/:id/usage)

{
  "customer": { /* full customer object */ },
  "quotaUsage": {
    "portSlotsUsed": 0,
    "portSlotsAllocated": 10,
    "portSlotsPercent": 0,
    "trafficUsedGB": 0,
    "trafficAllocatedGB": 100,
    "trafficPercent": 0
  },
  "balanceStats": {
    "currentBalance": 0,
    "totalTopUp": 0,
    "totalSpent": 0
  }
}

Customer Quota Status (GET /reseller/customers/:id/quota-status)

{
  "customerId": "696dea7dadd92285d1bb784d",
  "portSlots": {
    "used": 0,
    "allocated": 10,
    "available": 10,
    "percentUsed": 0,
    "isAtCapacity": false
  },
  "traffic": {
    "usedGB": 0,
    "allocatedGB": 100,
    "availableGB": 100,
    "percentUsed": 0,
    "isExceeded": false
  },
  "canCreatePorts": true,
  "canRotatePorts": true,
  "warnings": []
}

Delete Customer (DELETE /reseller/customers/:id)

{
  "success": true,
  "message": "Customer deleted successfully"
}

Pricebook Responses

Get Pricebook (GET /reseller/pricebook)

{
  "_id": "696cee59daf5d3936cc10f24",
  "resellerId": "69344abf4e8861b9e9986744",
  "pricingMode": "margin",
  "portPricing": {
    "marginPercent": 20
  },
  "trafficPricing": {
    "marginPercent": 20
  },
  "defaultMarginPercent": 20,
  "countryOverrides": [],
  "customerOverrides": [],
  "createdAt": "2026-01-18T14:29:45.994Z",
  "updatedAt": "2026-01-18T14:29:45.994Z",
  "__v": 0,
  "id": "696cee59daf5d3936cc10f24"
}

Calculate Price (POST /reseller/pricebook/calculate)

{
  "basePrice": 60,
  "resellerPrice": 72,
  "marginAmount": 12,
  "marginPercent": 20,
  "appliedRules": [
    "Margin: +20%",
    "30 days"
  ]
}

Port Responses

List Ports (GET /reseller/ports)

{
  "ports": [],
  "total": 0,
  "skip": 0,
  "limit": 20
}

Port Summary (GET /reseller/ports/summary)

{
  "total": 0,
  "active": 0,
  "expired": 0,
  "suspended": 0,
  "expiringIn24h": 0,
  "byCustomer": []
}

Webhook Responses

Create Webhook (POST /reseller/webhooks)

{
  "_id": "696dea9dadd92285d1bb7a0b",
  "resellerId": "69344abf4e8861b9e9986744",
  "url": "https://your-server.com/webhook",
  "name": "Production Webhook",
  "events": ["port.created", "customer.created"],
  "isActive": true,
  "failureCount": 0,
  "isDeleted": false,
  "deletedAt": null,
  "createdAt": "2026-01-19T08:26:05.320Z",
  "updatedAt": "2026-01-19T08:26:05.320Z",
  "__v": 0,
  "id": "696dea9dadd92285d1bb7a0b"
}

List Webhooks (GET /reseller/webhooks)

{
  "webhooks": [],
  "total": 0,
  "skip": 0,
  "limit": 20
}

Get Event Types (GET /reseller/webhooks/event-types)

[
  "port.created",
  "port.deleted",
  "port.expiring",
  "port.expired",
  "port.rotated",
  "port.suspended",
  "port.unsuspended",
  "customer.created",
  "customer.updated",
  "customer.suspended",
  "customer.unsuspended",
  "customer.quota_warning",
  "customer.quota_exceeded",
  "traffic.threshold_50",
  "traffic.threshold_80",
  "traffic.threshold_100",
  "balance.low",
  "balance.topup",
  "purchase.completed"
]

Delete Webhook (DELETE /reseller/webhooks/:id)

{
  "success": true,
  "message": "Webhook deleted"
}

Analytics Responses

Dashboard (GET /reseller/analytics/dashboard)

{
  "customers": {
    "total": 50,
    "active": 45,
    "suspended": 5,
    "newThisMonth": 10
  },
  "ports": {
    "totalActive": 450,
    "expiringIn24h": 15
  },
  "revenue": {
    "thisMonth": 4500.00,
    "lastMonth": 4200.00,
    "growthPercent": 7.14
  },
  "margin": {
    "thisMonth": 900.00,
    "lastMonth": 840.00,
    "averagePercent": 20
  }
}

Revenue Summary (GET /reseller/analytics/revenue)

{
  "totalRevenue": 50000.00,
  "totalCost": 40000.00,
  "totalMargin": 10000.00,
  "marginPercent": 20,
  "transactionCount": 500,
  "byType": {
    "port_purchase": 45000.00,
    "port_extension": 5000.00
  }
}

Revenue by Period (GET /reseller/analytics/revenue/by-period?period=day)

[
  {
    "period": "2026-01-19",
    "revenue": 150.00,
    "cost": 120.00,
    "margin": 30.00,
    "transactions": 5
  }
]

Commissions (GET /reseller/analytics/commissions)

{
  "commissions": [
    {
      "_id": "...",
      "amount": 15.00,
      "portId": "...",
      "customerId": "...",
      "type": "port_purchase",
      "createdAt": "2026-01-19T..."
    }
  ],
  "total": 100,
  "skip": 0,
  "limit": 20
}

Error Responses

400 Bad Request

{
  "statusCode": 400,
  "message": "Validation failed",
  "error": "Bad Request"
}

401 Unauthorized

{
  "statusCode": 401,
  "message": "Unauthorized"
}

402 Insufficient Balance

{
  "statusCode": 402,
  "message": "Insufficient balance. Required: $60.00, Available: $45.00"
}

403 Forbidden

{
  "statusCode": 403,
  "message": "Insufficient reseller balance"
}

404 Not Found

{
  "statusCode": 404,
  "message": "Customer not found",
  "error": "Not Found"
}

429 Rate Limited

{
  "statusCode": 429,
  "message": "Too Many Requests"
}

Document generated: January 19, 2026
API responses verified: January 19, 2026