# Session Rotation

Source: https://docs.evomi.com/public-api/endpoints/rotate_session/

Force an IP address change for an existing proxy session while maintaining the same session identifier.

## Endpoint
`GET https://api.evomi.com/public/rotate_session`

## Authentication
Requires API key in either:
- `x-apikey` header
- `apikey` query parameter

## Parameters
| Parameter | Required | Description | Valid Values |
|-----------|----------|-------------|--------------|
| `sessionid` | Yes | Current session identifier | Active session ID |
| `product` | Yes | Proxy product type | `rpc`, `rp`, `sdc`, `mp` |

## Example Request
```bash
curl -X GET "https://api.evomi.com/public/rotate_session?sessionid=AAAAA&product=rpc" \\
  -H "x-apikey: YOUR_API_KEY"
```

Or, without headers:

```bash
curl -X GET "https://api.evomi.com/public/rotate_session?sessionid=AAAAA&product=rpc&apikey=YOUR_API_KEY"

```

## Success Response
```json
{
  "success": true,
  "message": "Session reset successfully"
}
```

## Error Responses
```json
{
  "error": "Session ID not provided",
  "success": false
}
```
`400 Bad Request` - Missing required parameters

```json
{
  "error": "Invalid product",
  "success": false
}
```
`400 Bad Request` - Invalid product type specified

```json
{
  "error": "Failed to reset session",
  "success": false
}
```
`500 Internal Server Error` - Rotation failure

## Rotation Behavior
1. Immediate termination of existing connection
2. Release of current IP address
3. New IP assignment from same geographic pool
4. Session ID remains identical
5. Authentication credentials stay unchanged

## Usage Notes
- Previous IP becomes immediately unavailable
- Session locks to new IP after first connection

## Python Example
```python
import requests

def rotate_session(api_key, session_id, product_type):
    url = "https://api.evomi.com/public/rotate_session"
    headers = {"x-apikey": api_key}
    params = {
        "sessionid": session_id,
        "product": product_type
    }

    response = requests.get(url, headers=headers, params=params)
    return response.json()

# Usage
print(rotate_session("YOUR_KEY", "SESSION_123", "rpc"))
```
