Create proxy replacement

This endpoint lets you create a proxy replacements which replaces proxies from your proxy list. The proxies_removed and proxies_added must always match.

Cannot create proxy replacement if plan.pool_filter is residential.

POST https://proxy.webshare.io/api/v2/proxy/replace/

Parameters

AttributesTypeDescription
to_replacedict

Dictionary indicating which proxies to replace.

replace_withlist

List of dictionaries indicating which proxies to replace with.

dry_runbool

You can dry-run a replacement to learn number of proxies removed/added prior to actually replacing the proxy list. dry_run=True does not modify the proxy list.

Request & Response

create_replacement.py
import requests
 
response = requests.post(
    "https://proxy.webshare.io/api/v2/proxy/replace/",
    json={
        "to_replace": {"type": "ip_range", "ip_ranges": ["1.2.3.0/24"]},
        "replace_with": [{"type": "country", "country_code": "US"}],
        "dry_run": False
    },
    headers={"Authorization": "Token "}
)
 
response.json()

The commands above return JSON structured like this:

response.json
{
    "id": 98315,
    "reason": "proxy_replaced",
    "to_replace": {"type": "ip_range", "ip_ranges": ["1.2.3.0/24"]},
    "replace_with": [{"type": "country", "country_code": "US"}],
    "dry_run": false,
    "state": "completed",
    "proxies_removed": 1,
    "proxies_added": 1,
    "created_at": "2022-07-26T21:25:13.966946-07:00",
    "completed_at": "2022-07-26T21:25:13.966946-07:00",
}

400 Error Types

Error CodeHTTP CodeDescription
proxies_removed_doesnt_match_added400

There is a mismach between added and replaced proxies.

not_enough_replacements_in_subscription400

Account holder doesn't have enough proxy replacements.