Skip to main content

Session API

The Session API is the core NexaLayer surface. Send Idempotency-Key on write operations.

Create a session

curl -X POST "https://api.nexalayer.net/v1/sessions" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $NEXALAYER_API_KEY" \
  -H "Idempotency-Key: create-session-001" \
  -d '{
    "session_type": "dynamic",
    "product_no": "dynamic_ipweb",
    "quantity": 0.25,
    "protocol": "socks5",
    "rotation_mode": "on_demand"
  }'
For dynamic sessions, quantity means GB and can be fractional; the current price is 4/GB.Forstaticsessions,quantitymeansIPcountandmustbeaninteger,witha4 / GB. For static sessions, `quantity` means IP count and must be an integer, with a 10 / month minimum. A static session may include:
{
  "session_type": "static",
  "product_no": "static_us_englewood",
  "quantity": 1,
  "duration": 30,
  "protocol": "socks5",
  "country_code": "US",
  "city_code": "ENGLEWOOD",
  "project_id": "game"
}

Get a session

curl "https://api.nexalayer.net/v1/sessions/$SID" \
  -H "X-API-Key: $NEXALAYER_API_KEY"
When status=active, the response includes proxy.full_url while keeping host, port, username, and password for compatibility.

Rotate a dynamic session

curl -X POST "https://api.nexalayer.net/v1/sessions/$SID/rotate" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $NEXALAYER_API_KEY" \
  -H "Idempotency-Key: rotate-timeout-001" \
  -d '{ "reason": "timeout" }'
Supported reasons:
manual, scheduled, http_403, http_429, captcha, timeout, block

Renew a static session

curl -X POST "https://api.nexalayer.net/v1/sessions/$SID/renew" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $NEXALAYER_API_KEY" \
  -H "Idempotency-Key: renew-static-001" \
  -d '{ "duration": 30 }'

Terminate a session

curl -X DELETE "https://api.nexalayer.net/v1/sessions/$SID" \
  -H "X-API-Key: $NEXALAYER_API_KEY"
Every automation workflow should terminate sessions it no longer needs. Early termination releases the underlying resource; session management is free for now, and static resources are not automatically refunded by default.