Skip to main content
This example demonstrates how to create a proxy user with proxy-restricted access, where the user can only access specific individual proxies. This is ideal for reselling scenarios, dedicated proxy assignments, or maximum security with fine-grained control.

Overview

The process involves two steps:
  1. Create a proxy user with proxy_user_access_type: "proxy_restricted"
  2. Create Proxy User ACL entries to grant access to specific individual proxies
import requests

# API credentials
API_PUBLIC_KEY = "your_public_key"
API_PRIVATE_KEY = "your_private_key"
BASE_URL = "https://api.pingproxies.com/1.0/public"

# Headers for authentication
headers = {
    "X-API-Public-Key": API_PUBLIC_KEY,
    "X-API-Private-Key": API_PRIVATE_KEY,
    "Content-Type": "application/json"
}

def create_proxy_restricted_proxy_user(user_id, password, proxy_ids, metadata=None):
    """
    Create a proxy user with proxy-restricted access.

    Args:
        user_id: ID for the proxy user
        password: Password for the proxy user
        proxy_ids: List of proxy IDs to grant access to
        metadata: Optional metadata dictionary

    Returns:
        Tuple of (proxy_user_data, acl_ids) or (None, None) if failed
    """

    # Step 1: Create the proxy user with proxy_restricted access type
    create_user_payload = {
        "proxy_user_id": user_id,
        "proxy_user_password": password,
        "proxy_user_access_type": "proxy_restricted"
    }

    if metadata:
        create_user_payload["proxy_user_metadata"] = metadata

    response = requests.post(
        f"{BASE_URL}/user/proxy_user/create",
        json=create_user_payload,
        headers=headers
    )

    if response.status_code != 201:
        print(f"Error creating proxy user: {response.status_code}")
        print(response.text)
        return None, None

    user_data = response.json()
    print(f"Successfully created proxy user: {user_id}")

    # Step 2: Create ACL entries for each proxy
    acl_ids = []
    for proxy_id in proxy_ids:
        acl_payload = {
            "proxy_user_id": user_id,
            "proxy_id": proxy_id
        }

        acl_response = requests.post(
            f"{BASE_URL}/user/proxy_user_acl/create",
            json=acl_payload,
            headers=headers
        )

        if acl_response.status_code != 201:
            print(f"Error creating ACL for proxy {proxy_id}: {acl_response.status_code}")
            print(acl_response.text)
            continue

        acl_data = acl_response.json()
        acl_id = acl_data["created"][0]
        acl_ids.append(acl_id)
        print(f"Granted access to proxy: {proxy_id}")

    return user_data, acl_ids

# Example usage
if __name__ == "__main__":
    # Create a reseller customer with access to 3 specific proxies
    USER_ID = "customer_001"
    PASSWORD = "securepassword456"
    PROXY_IDS = [
        "550e8400-e29b-41d4-a716-446655440001",
        "550e8400-e29b-41d4-a716-446655440002",
        "550e8400-e29b-41d4-a716-446655440003"
    ]
    METADATA = {
        "customer_type": "reseller",
        "plan": "premium",
        "order_id": "ORD-12345"
    }

    user_data, acl_ids = create_proxy_restricted_proxy_user(
        user_id=USER_ID,
        password=PASSWORD,
        proxy_ids=PROXY_IDS,
        metadata=METADATA
    )

    if user_data:
        print("\n=== Setup Complete ===")
        print(f"Proxy User ID: {USER_ID}")
        print(f"Password: {PASSWORD}")
        print(f"Access Type: proxy_restricted")
        print(f"Proxies Granted: {len(PROXY_IDS)}")
        print(f"ACL Entries Created: {len(acl_ids)}")

Key Points

1. Access Type Must Be Set

When creating the proxy user, you must set proxy_user_access_type to "proxy_restricted":
{
  "proxy_user_id": "customer_001",
  "proxy_user_password": "securepassword456",
  "proxy_user_access_type": "proxy_restricted"
}

2. ACL Entries Grant Individual Proxy Access

After creating the proxy user, create one ACL entry for each individual proxy they should access:
{
  "proxy_user_id": "customer_001",
  "proxy_id": "550e8400-e29b-41d4-a716-446655440001"
}
The proxy user can only access the specific proxies listed in their ACL entries - nothing more.

3. One ACL Per Proxy

Unlike service-restricted access (where one ACL grants access to all proxies in a service), proxy-restricted requires one ACL entry per proxy:
  • ACL 1: customer_001 → Proxy 550e8400-e29b-41d4-a716-446655440001
  • ACL 2: customer_001 → Proxy 550e8400-e29b-41d4-a716-446655440002
  • ACL 3: customer_001 → Proxy 550e8400-e29b-41d4-a716-446655440003

Use Cases

Proxy Reselling

Scenario: You resell individual proxies to customers. Each customer should only access the specific proxies they purchased. Implementation:
  • Customer A → Proxies: proxy_001, proxy_002, proxy_003 (3 proxies purchased)
  • Customer B → Proxies: proxy_004, proxy_005 (2 proxies purchased)
  • Customer C → Proxy: proxy_006 (1 proxy purchased)

Dedicated Proxy Assignments

Scenario: Assign specific proxies to specific users or applications for performance tracking or security. Implementation:
  • Application A → Dedicated proxies: proxy_A1, proxy_A2
  • Application B → Dedicated proxies: proxy_B1, proxy_B2, proxy_B3

High-Security Environments

Scenario: Maximum security with granular control where each system component only accesses specific, pre-approved proxies. Implementation:
  • Production System → Pre-audited proxies only
  • Testing System → Separate set of test proxies
  • Development System → Another isolated set

Comparison with Service-Restricted

FeatureService-RestrictedProxy-Restricted
Grants access toAll proxies in a serviceSpecific individual proxies
ACLs neededOne per serviceOne per proxy
Best forTeam/department accessReselling, dedicated assignments
GranularityService levelProxy level
ScalabilityBetter for large proxy poolsBetter for small, specific sets

Verifying Access

After setup, you can verify the ACL entries were created:
curl --request GET \
  --url 'https://api.pingproxies.com/1.0/public/user/proxy_user_acl/search?proxy_user_id=customer_001' \
  --header 'X-API-Public-Key: your_public_key' \
  --header 'X-API-Private-Key: your_private_key'

Managing Access

Adding More Proxies

Create additional ACL entries to grant access to more proxies:
curl --request POST \
  --url 'https://api.pingproxies.com/1.0/public/user/proxy_user_acl/create' \
  --header 'Content-Type: application/json' \
  --header 'X-API-Public-Key: your_public_key' \
  --header 'X-API-Private-Key: your_private_key' \
  --data '{
    "proxy_user_id": "customer_001",
    "proxy_id": "550e8400-e29b-41d4-a716-446655440004"
  }'

Removing Proxy Access

Delete an ACL entry to revoke access to a specific proxy:
curl --request DELETE \
  --url 'https://api.pingproxies.com/1.0/public/user/proxy_user_acl/delete/{proxy_user_acl_id}' \
  --header 'X-API-Public-Key: your_public_key' \
  --header 'X-API-Private-Key: your_private_key'

Retrieving Proxy IDs

To get proxy IDs for creating ACLs, use the proxy search endpoint:
curl --request GET \
  --url 'https://api.pingproxies.com/1.0/public/user/proxy/search?service_id=API-1234-5678' \
  --header 'X-API-Public-Key: your_public_key' \
  --header 'X-API-Private-Key: your_private_key'
Each proxy in the response will have a proxy_id field you can use for creating ACL entries.