When to use them
Ephemeral sessions put the rules in the connection string, lock them on the first request, and expire after 60 seconds of inactivity. That’s the right fit for short, self-contained jobs. Stateful sessions fit when the setup has to outlive a single job:- You want to change location or rotation without redeploying. Move a session from the US to Germany with one API call. Every client using it follows.
- You run a fleet of workers or browser profiles. Each one gets its own named session, created in bulk with one call.
- You authenticate by IP. Each session gets its own port on IP allowlist packages, so you can use HTTP and SOCKS5 without sending credentials. See Connecting.
- You need to know the exit IP up front. A session is bound to a node when it’s created, so the response already carries its exit IP.
How it works
- Create a session with the rules you want: where (country, region, city, ISP, ASN, ZIP), what kind of network, and how the exit node should change over time.
- SOAX binds it to a matching exit node straight away and returns the exit IP and a connection string.
- Send traffic through the connection string like any other proxy.
- Change the rules at any time. The connection string doesn’t change.
- The exit node changes when your rules say so, or immediately when you rotate the session.
- Disable a session to pause it and enable it later, or delete it when you’re done.
proxy:packages:write scope (and proxy:packages:read to list and read sessions), plus the ID of the package the sessions belong to. See API authentication.
Create a session
ruleset is what you asked for. The top-level exit_ip, network_type and geo fields describe the node the session is bound to right now.
The ruleset is optional. Leave it out to get a session with the defaults: any location the package allows, a new exit node every 300 seconds, and a replacement node if the current one fails.
Creating many sessions at once
Setcount (up to 1,000) to create a pool in one call. Each session gets the base name plus a number:
w1 to w50. Each session is bound on its own, and any that can’t be bound are discarded, so the response can contain fewer sessions than you asked for. Always check failed: if it’s above 0, reason explains why and you can create the rest with another call. If none can be bound, the request fails with 503 and a Retry-After header. Retry after that delay, or broaden the rules (for example, drop city).
Connecting to a session
How you connect depends on how the package authenticates. Both methods work over HTTP, HTTPS and SOCKS5.connection_string from the API response rather than building it yourself. On IP allowlist packages, each session’s port identifies it, so your client’s public IP must be on the package’s IP allowlist.
Rules
A session’sruleset uses the same rules system as connection strings, written as JSON fields:
A few things to know:
- Geo fields need a country. Setting
region,city,isp,asnorziprequires a specificcountry(notany). Each value must belong to the one above it: a city inside its region, a region inside its country. Use thecodevalues from the location endpoints so they always validate. - The package sets the limits.
countryandnetwork_typemust be available on the package. on-errorkeeps the same node until it fails, with no timed or request-based rotation.bindpins the session to its current node. It can’t be combined witherror_handling: "replace"orlookalike: true, and its error handling defaults toretry_3. If the node goes offline, requests fail instead of moving to another node.
Changing a session
Send only what you want to change. Your client doesn’t need to do anything.- Omitted fields keep their value. Setting a geo field or
network_typetonullclears it.lookalike,rotation_triggeranderror_handlingalways have a value and can’t be set tonull. - Changing a location clears what’s beneath it. Changing
countryclearsregion,city,isp,asnandzipunless you send new values in the same request. Changingregionclearscity,isp,asnandzip. Changingcityclearsisp,asnandzip.isp,asnandzipnever clear one another. - Renaming changes the username. The username is
stateful-<name>, so update your client after a rename.
Disabling and enabling
Setstatus to "disabled" to stop a session carrying traffic without losing its name, port or rules. Set it back to "enabled" to resume: the session is bound to a fresh node. If no node is available, the call returns 502 and the session stays disabled. Disabled sessions still count toward the package’s session limit.
Rotating
Ask for a new exit node at any time:exit_ip and bound_since. You can rotate each session once per second; faster calls get 429 with Retry-After: 1.
Stateful doesn’t mean pinned
A stateful session keeps its configuration and connection string. Its exit IP can still change:- when its
rotation_triggerfires, - when the bound node fails and
error_handlingreplaces it, - when the node no longer matches the rules, for example after you change them,
- when the node leaves the network.
rotation_trigger: "bind" with error_handling: "fail" or "retry_<attempts>". Even then, a node that goes offline can’t be kept. Nodes are real devices; see Nodes and IPs.
Deleting
Delete one session withDELETE …/stateful-sessions/SESSION_ID, or up to 100 at once with POST …/stateful-sessions/delete. A deleted session stops working immediately, and its name and port can be reused.
Limits
Everything the package already enforces applies to stateful traffic unchanged: traffic limits, RPS and connection limits, allowed countries and the firewall. Sessions themselves aren’t billed; their traffic is billed as usual.
On a suspended or deleted package you can’t create or rotate sessions, but you can still list, read, update and delete them.
API errors
API errors return a JSON body. Endpoint-specific errors usedetail, shared API rate-limit errors use error, and schema-validation errors use a detail array. See Error handling for these response shapes. Common status codes:
See the Stateful Sessions API reference for every endpoint, and Error handling for the general error format.
Next steps
Create stateful sessions
Full request and response reference.
Core concepts
Sessions, rules and bindings explained.
Location endpoints
Look up valid region, city, ISP, ASN and ZIP codes.
Authentication
Username and password vs IP allowlist.