Docs/Reseller API Quick Start

Reseller API Quick Start Guide

A practical guide to building your proxy business with Proxies.sx

Welcome, Reseller!

This guide will get you up and running in 15 minutes. By the end, you'll know how to:

  1. Create customers under your account
  2. Set up your pricing with margins
  3. Create proxies for your customers
  4. Handle real-time events with webhooks

How It Works

┌─────────────────────────────────────────────────────────────────┐
│                                                                 │
│    YOUR CUSTOMER                YOUR APP                 US     │
│    ────────────                ────────                ────     │
│                                                                 │
│    "I need 5 proxies"   ──▶   Your Website    ──▶   API Call   │
│                               (calls our API)                   │
│                                                                 │
│    Sees: YOUR brand          Charges: YOUR price   You pay: BASE│
│    Pays: YOUR price          Keeps: the difference              │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Example:
- Base cost to you: $2.00/day
- Your margin: 25%
- You charge customer: $2.50/day
- Your profit: $0.50/day per proxy

Step 1: Authentication

Get Your API Key

First, login to get a tokenbash
# First, login to get a token
curl -X POST https://api.proxies.sx/v1/login/signin \
  -H "Content-Type: application/json" \
  -d '{"email": "your@email.com", "password": "your_password"}'

# Save the access_token from the response
Create an API key for your appbash
curl -X POST https://api.proxies.sx/v1/api-keys \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My App",
    "scopes": ["customers:read", "customers:write", "ports:read", "ports:write"]
  }'

Now use your API key for all requests:

X-API-Key: psx_your_key_here

Step 2: Set Your Pricing

Understanding Pricing Modes

The pricebook determines how much YOU charge YOUR customers (not what we charge you).

ModeHow it worksExample (base $2/day)
Margin (default)Add a percentage to base costBase $2 + 20% = $2.40 (you charge customer)
FixedIgnore base cost, use fixed priceAlways $3.00/day regardless of cost
MultiplierMultiply the base costBase $2 × 1.5 = $3.00 (you charge customer)
Important: Your pricebook calculates resellerPrice (what you charge customers). You always pay us the basePrice (our cost to you). Your profit is the difference.

Default Pricebook

When your account is created, you get:

  • Pricing Mode: margin
  • Default Margin: 20%
  • Port Pricing Margin: 20%
  • Traffic Pricing Margin: 20%

Configure Your Pricebook

View current pricingbash
curl https://api.proxies.sx/v1/reseller/pricebook \
  -H "X-API-Key: psx_xxx"
Set 25% margin on all portsbash
curl -X PUT https://api.proxies.sx/v1/reseller/pricebook \
  -H "X-API-Key: psx_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "pricingMode": "margin",
    "defaultMarginPercent": 25,
    "portPricing": {
      "marginPercent": 25
    }
  }'

Premium Pricing for Specific Countries

Charge 40% margin for US proxiesbash
curl -X POST https://api.proxies.sx/v1/reseller/pricebook/country-override \
  -H "X-API-Key: psx_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "countryId": "usa_country_id",
    "marginPercent": 40
  }'

Calculate a Price

Before charging your customer, calculate the price using your pricebook:

curl -X POST https://api.proxies.sx/v1/reseller/pricebook/calculate \
  -H "X-API-Key: psx_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "port",
    "basePrice": 2.00,
    "days": 30,
    "countryId": "optional_country_id",
    "customerId": "optional_customer_id"
  }'
Responsejson
{
  "basePrice": 60.00,        // What YOU pay us ($2 × 30 days)
  "resellerPrice": 75.00,    // What YOU charge YOUR customer
  "marginAmount": 15.00,     // Your profit
  "marginPercent": 25,       // Your margin percentage
  "appliedRules": [          // Which pricing rules were applied
    "Margin: +25%",
    "30 days"
  ]
}

Note: The customerId parameter applies customer-specific discounts if configured.

Step 3: Create Customers

Create a Customer

curl -X POST https://api.proxies.sx/v1/reseller/customers \
  -H "X-API-Key: psx_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "john@company.com",
    "name": "John Smith",
    "company": "Acme Corp",
    "allocatedPortSlots": 10,
    "externalId": "CRM-12345"
  }'

What's externalId? Your own customer ID from your system. Makes it easy to find customers later.

Top Up Customer Balance

Transfer credit from your reseller balance to a customer's internal balance:

curl -X POST https://api.proxies.sx/v1/reseller/customers/{id}/topup \
  -H "X-API-Key: psx_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 100,
    "description": "Monthly credit",
    "referenceId": "INV-2024-001"
  }'

How this works:

  1. Checks YOUR reseller balance has at least $100
  2. Deducts $100 from YOUR reseller balance
  3. Adds $100 to customer's internal balance
Important: Customer balance is for YOUR internal accounting (tracking what the customer has prepaid). Port creation charges YOUR reseller balance, not the customer's balance. You're responsible for billing your customers externally.

Step 4: Create Proxies

Create a Proxy for Your Customer

When you create a port, the cost is deducted from YOUR reseller balance (not the customer's balance):

curl -X POST https://api.proxies.sx/v1/reseller/ports \
  -H "X-API-Key: psx_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "customerId": "customer_id_here",
    "countryId": "country_id_here",
    "cityId": "optional_city_id",
    "carrierId": "optional_carrier_id",
    "days": 30,
    "exclusive": false,
    "isPrivate": false
  }'

What happens:

  1. Verifies customer belongs to you and is active
  2. Checks customer has available port slots (quota)
  3. Checks YOUR balance (requires: basePrice × days)
  4. Creates the port on our infrastructure
  5. Deducts cost from YOUR reseller balance
  6. Updates customer's used port slots count
  7. Records your margin for analytics tracking
  8. Emits webhook (if configured)
Responsejson
{
  "port": {
    "_id": "port_123",
    "displayName": "psx_abc_xyz",
    "httpPort": 10001,
    "socksPort": 10002,
    "proxyLogin": "user123",
    "proxyPassword": "pass456",
    "serverIp": "185.123.45.67",
    "expiresAt": 1740000000000
  },
  "pricing": {
    "costToReseller": 60.00,    // What WE charged YOU
    "resellerPrice": 75.00,     // What YOU should charge YOUR customer
    "margin": 15.00             // Your profit (for your records)
  }
}
Important: The pricing object is informational - it tells you what to charge your customer. The actual deduction from your balance is costToReseller.

Rotate IP (Change Device)

curl -X POST https://api.proxies.sx/v1/reseller/ports/{portId}/rotate \
  -H "X-API-Key: psx_xxx"

Step 5: Set Up Webhooks

Get notified when things happen:

curl -X POST https://api.proxies.sx/v1/reseller/webhooks \
  -H "X-API-Key: psx_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Webhook",
    "url": "https://myapp.com/webhook",
    "events": ["port.created", "port.expired", "customer.quota_exceeded"]
  }'

Event Types

EventWhen it fires
port.createdNew proxy created
port.expiredProxy expired
port.rotatedIP changed
customer.quota_exceededCustomer hit limit
balance.lowLow balance warning

Code Examples

Node.js Integration

const RESELLER_API_KEY = 'psx_your_key';
const API_BASE = 'https://api.proxies.sx/v1';

class ResellerAPI {
  async createCustomer(email, name, portSlots) {
    const response = await fetch(`${API_BASE}/reseller/customers`, {
      method: 'POST',
      headers: {
        'X-API-Key': RESELLER_API_KEY,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        email,
        name,
        allocatedPortSlots: portSlots
      })
    });
    return response.json();
  }

  async createProxyForCustomer(customerId, countryId, days = 30) {
    const response = await fetch(`${API_BASE}/reseller/ports`, {
      method: 'POST',
      headers: {
        'X-API-Key': RESELLER_API_KEY,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({ customerId, countryId, days })
    });
    return response.json();
  }

  async rotateProxy(portId) {
    const response = await fetch(`${API_BASE}/reseller/ports/${portId}/rotate`, {
      method: 'POST',
      headers: { 'X-API-Key': RESELLER_API_KEY }
    });
    return response.json();
  }
}

// Usage
const api = new ResellerAPI();

// Create customer
const customer = await api.createCustomer('john@acme.com', 'John', 10);

// Create proxy for them
const proxy = await api.createProxyForCustomer(customer._id, 'germany_id', 30);

console.log(`Proxy ready: ${proxy.port.serverIp}:${proxy.port.httpPort}`);

Python Integration

import requests

class ResellerAPI:
    def __init__(self, api_key):
        self.api_key = api_key
        self.base_url = 'https://api.proxies.sx/v1'
        self.headers = {
            'X-API-Key': api_key,
            'Content-Type': 'application/json'
        }

    def create_customer(self, email, name, port_slots=10):
        response = requests.post(
            f'{self.base_url}/reseller/customers',
            headers=self.headers,
            json={
                'email': email,
                'name': name,
                'allocatedPortSlots': port_slots
            }
        )
        return response.json()

    def create_proxy(self, customer_id, country_id, days=30):
        response = requests.post(
            f'{self.base_url}/reseller/ports',
            headers=self.headers,
            json={
                'customerId': customer_id,
                'countryId': country_id,
                'days': days
            }
        )
        return response.json()

    def rotate_proxy(self, port_id):
        response = requests.post(
            f'{self.base_url}/reseller/ports/{port_id}/rotate',
            headers=self.headers
        )
        return response.json()

# Usage
api = ResellerAPI('psx_your_key')

customer = api.create_customer('john@acme.com', 'John Smith')
proxy = api.create_proxy(customer['_id'], 'germany_country_id')

print(f"Proxy: {proxy['port']['serverIp']}:{proxy['port']['httpPort']}")

Money Flow & Charging Explained

Understanding how money moves in the reseller system:

┌─────────────────────────────────────────────────────────────────┐
│                     RESELLER MONEY FLOW                         │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  1. YOU (Reseller) add money to YOUR Proxies.sx account         │
│     └── Your Balance: $500                                      │
│                                                                 │
│  2. You CREATE CUSTOMER and TOP UP their balance $100           │
│     └── Your Balance: $400 (-$100 transferred to customer)      │
│     └── Customer Balance: $100 (for YOUR internal accounting)   │
│                                                                 │
│  3. You CREATE PROXY for customer (30 days @ $2/day base)       │
│     └── Your Balance: $340 (-$60 cost to you)                   │
│     └── Customer Balance: unchanged (still $100)                │
│                                                                 │
│  IMPORTANT: Port creation charges YOUR reseller balance,        │
│  NOT the customer's balance. Customer balance is for YOUR       │
│  internal accounting - you track what they owe you separately.  │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Key Charging Principles

1. Port Creation Cost = basePrice × days

  • This is what Proxies.sx charges YOU (the reseller)
  • Deducted from YOUR reseller balance when creating a port
  • Example: $2/day × 30 days = $60 cost to you

2. Reseller Price = Your cost + Your margin

  • This is what YOU charge YOUR customer
  • Calculated based on your pricebook settings
  • Example: $60 cost + 25% margin = $75 you charge customer
  • Your profit: $15 per port

3. Customer Balance = Internal accounting only

  • Money you transfer from your balance to track customer credits
  • NOT used for port purchases (all charges go to your balance)
  • You decide how to bill your customers externally

Charging Flow Diagram

Your Customer               You (Reseller)           Proxies.sx
    │                           │                        │
    │ "I need a proxy"          │                        │
    │──────────────────────────▶│                        │
    │                           │                        │
    │                           │ POST /reseller/ports   │
    │                           │───────────────────────▶│
    │                           │                        │
    │                           │    Check your balance  │
    │                           │    Deduct base cost    │
    │                           │    ($60 from you)      │
    │                           │◀───────────────────────│
    │                           │                        │
    │  "That'll be $75"         │                        │
    │◀──────────────────────────│                        │
    │                           │                        │
    │  (You collect payment     │                        │
    │   through YOUR system)    │                        │
    │                           │                        │
    └───────────────────────────┴────────────────────────┘

    Your profit: $75 (charged customer) - $60 (cost) = $15

Common Questions

Q: Do my customers get login access?

No. Your customers don't have accounts on Proxies.sx. You build your own app/website that calls our API. Your customers only interact with YOUR brand.

Q: How do I charge my customers?

You handle payments yourself. Use Stripe, PayPal, or any payment method you want. When a customer pays you, you use our API to create their proxies.

Q: What happens when a proxy expires?

We send a webhook to your server. You can then notify your customer or auto-renew.

Q: Can I set different prices for different countries?

Yes! Use country overrides in your pricebook to charge premium prices for high-demand locations.

Next Steps

  1. Test in development - Use our sandbox environment
  2. Set up webhooks - Don't miss important events
  3. Build your dashboard - Show customers their proxies
  4. Launch! - Start selling proxies under your brand

Happy Reselling!