Sticky sessions for rotating proxies
Control how long a rotating proxy keeps the same exit IP — read and change the session mode and TTL, list, rotate and delete sticky sessions, and find the sticky ports.
Rotating proxies pick exit IPs from a shared pool. A sticky session keeps one exit for a while so that a multi-step task — a login followed by several page loads, for example — comes from the same address. This guide shows the REST endpoints that control sticky behavior for a rotating service.
Important: Sticky endpoints exist only for rotating services (
product_kind: "proxy_rotating"). For datacenter, ISP and other services they return404 {"detail":"Service not found."}. There are no MCP tools for sticky sessions; use REST.
Reading needs services:read; changes need services:write. Use the ID of a rotating service:
export SERVICE_ID="00000000-0000-0000-0000-000000000000"
Find the sticky ports
Read the connection settings of the service with GET .../proxy/config:
curl "https://fineproxy.org/account_new/api/v1/customer/services/$SERVICE_ID/proxy/config" \
-H "Authorization: Bearer $FINEPROXY_API_KEY"
{
"endpoint": "fineproxy.xyz",
"endpoints": ["fineproxy.xyz"],
"https_endpoints": ["eu01.mcccx.com", "us01.mcccx.com"],
"port": 3081,
"http_ports": [3081, 3082, 3083, 3084, 3085, 3086, 3087, 3088, 3089, 3090, 3091, 3092, 3093, 3094],
"socks_ports": [2081, 2082, 2083, 2084, 2085, 2086, 2087, 2088, 2089, 2090, 2091, 2092, 2093, 2094],
"sticky_http": 5080,
"sticky_socks5": 4080,
"sticky_https": 4443,
"session_format": "ip:port:username:password",
"mode": "sticky",
"sample_connection_strings": ["fineproxy.xyz:3081:USER:********"]
}
| Field | Meaning |
|---|---|
endpoints, http_ports, socks_ports | The regular rotating gateway: host and HTTP / SOCKS ports. |
sticky_http, sticky_socks5, sticky_https | Ports for sticky connections over HTTP, SOCKS5 and HTTPS. |
https_endpoints | Regional HTTPS hosts. GET .../proxy/auth lists the sticky hosts in rotating_gateway.sticky_hosts. |
session_format | How the connection string is put together. |
mode | The current session mode. |
The values above are an example. Always read host names and ports from proxy/config instead of hardcoding them. proxy/config also returns 404 for non-rotating services. Full connection details are in Connect to rotating proxies.
Reference: Get rotating config.
Read and set the session mode
curl "https://fineproxy.org/account_new/api/v1/customer/services/$SERVICE_ID/proxy/sticky/mode" \
-H "Authorization: Bearer $FINEPROXY_API_KEY"
A new rotating service starts in sticky mode:
{ "mode": "sticky" }
Change it with PUT:
curl -X PUT "https://fineproxy.org/account_new/api/v1/customer/services/$SERVICE_ID/proxy/sticky/mode" \
-H "Authorization: Bearer $FINEPROXY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"mode": "sticky"}'
const response = await fetch(
`https://fineproxy.org/account_new/api/v1/customer/services/${process.env.SERVICE_ID}/proxy/sticky/mode`,
{
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.FINEPROXY_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ mode: 'sticky' }),
},
);
if (!response.ok) throw new Error(`Mode change failed ${response.status}: ${await response.text()}`);
console.log(await response.json());
import os
import requests
response = requests.put(
f"https://fineproxy.org/account_new/api/v1/customer/services/{os.environ['SERVICE_ID']}/proxy/sticky/mode",
headers={"Authorization": f"Bearer {os.environ['FINEPROXY_API_KEY']}"},
json={"mode": "sticky"},
timeout=30,
)
response.raise_for_status()
print(response.json())
mode | Use it when |
|---|---|
sticky | Requests in a session should keep the same exit until the session TTL runs out. |
rotating | Every request may use a different exit. |
pinned | All traffic should use one fixed exit. Send it in pin as ip:port; pin is required for this mode. |
For pinned, the body is {"mode": "pinned", "pin": "<exit ip>:<port>"}; the exit is validated by the gateway. The response has the same shape as GET, {"mode": "...", "pin": "..."}. A body the server does not accept returns 422 {"detail":"Validation error"}; read the mode back with GET to confirm the change.
References: Get sticky mode, Set sticky mode.
Read and change the session TTL
The TTL is how long a sticky session keeps its exit. The default is 900 seconds (15 minutes).
curl "https://fineproxy.org/account_new/api/v1/customer/services/$SERVICE_ID/proxy/sticky/ttl" \
-H "Authorization: Bearer $FINEPROXY_API_KEY"
{
"ttl_seconds": 900,
"is_custom": false,
"global_default_ttl": 900,
"ttl_human": "15m"
}
Set your own value with PUT and seconds (minimum 30):
curl -X PUT "https://fineproxy.org/account_new/api/v1/customer/services/$SERVICE_ID/proxy/sticky/ttl" \
-H "Authorization: Bearer $FINEPROXY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"seconds": 300}'
The response returns the same fields; is_custom becomes true when an override is set. DELETE .../sticky/ttl removes the override and returns to global_default_ttl:
curl -X DELETE "https://fineproxy.org/account_new/api/v1/customer/services/$SERVICE_ID/proxy/sticky/ttl" \
-H "Authorization: Bearer $FINEPROXY_API_KEY"
Choose a TTL slightly longer than your longest task that must stay on one IP. A shorter TTL gives you fresh IPs more often.
References: Get TTL, Set TTL, Reset TTL.
List sticky sessions
curl "https://fineproxy.org/account_new/api/v1/customer/services/$SERVICE_ID/proxy/sticky/sessions" \
-H "Authorization: Bearer $FINEPROXY_API_KEY"
Before any traffic the list is empty:
{
"service_id": "00000000-0000-0000-0000-000000000000",
"username": "your_proxy_username",
"sessions": []
}
Each entry in sessions describes one session:
| Field | Meaning |
|---|---|
sid | Session handle used in the rotate and delete paths. |
session_id | Session identifier. |
server | Gateway server holding the session. |
exit, exit_addr | The exit currently assigned. |
is_default | Whether this is the default session. |
created, last_used | Timestamps. |
ttl_seconds, expires_at | Lifetime of the session. |
mode | Mode of the session. |
Reference: List sticky sessions.
Rotate, delete or purge sessions
Rotate one session to a new exit while keeping the session. This is free and is not an IP refresh.
curl -X POST "https://fineproxy.org/account_new/api/v1/customer/services/$SERVICE_ID/proxy/sticky/sessions/$SID/rotate" \
-H "Authorization: Bearer $FINEPROXY_API_KEY"
The response returns the session’s sid, its new exit and exit_addr, and status: "rotated".
Delete one session when you no longer need it. A successful delete returns 204 No Content.
curl -X DELETE "https://fineproxy.org/account_new/api/v1/customer/services/$SERVICE_ID/proxy/sticky/sessions/$SID" \
-H "Authorization: Bearer $FINEPROXY_API_KEY"
Purge all sessions of the service at once:
curl -X POST "https://fineproxy.org/account_new/api/v1/customer/services/$SERVICE_ID/proxy/sticky/purge" \
-H "Authorization: Bearer $FINEPROXY_API_KEY"
{ "deleted": 3 }
References: Rotate session, Delete session, Purge sessions.
Which operation to use
| Situation | Operation |
|---|---|
| One task got blocked or rate-limited on its current IP | Rotate that session |
| A task finished and its IP should not be reused | Delete that session |
| You start a new batch and want every session on a fresh IP | Purge |
| Sessions keep their IP too long or too short | Change the TTL |
| You need one stable exit for everything | Mode pinned with pin |
| You don’t need stickiness at all | Mode rotating |
Common pitfalls
- Calling sticky endpoints on a datacenter service. They return
404 Service not found.; checkproduct_kindfirst. - Hardcoding hosts and ports. Read them from
proxy/config— they can differ between services and regions. - Using a TTL below 30 seconds. The minimum is 30.
- Confusing rotate with refresh. Rotating a session changes the exit of one rotating session for free. Refreshing IPs replaces the allocated IPs of a datacenter or ISP service and may cost money.