> ## Documentation Index
> Fetch the complete documentation index at: https://anyip.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Sticky vs. Rotating Sessions

> Learn how to keep the same IP (Sticky Sessions) or rotate IPs per request. Essential for multi-step workflows, login sessions, and avoiding rate limits.

One of the most common questions: *"How do I get a Static IP?"* or *"Why did my IP change?"*
anyIP does not offer static IPs. We offer sticky sessions that keep the same IP for as long as it stays available, up to 7 days by default. The sections below explain the difference and how to get the most stable result
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Rotating Mode (Default)

**Best for:** Web scraping, crawling, bulk data collection.
If you **do not** add a session flag, every request you make will be routed through a fresh IP address.

```
Request 1 → IP A
Request 2 → IP B
Request 3 → IP C
```

## No configuration needed. This is the default behavior. With rotating mode, each request gets a new IP. On a page that loads many assets, each asset that is downloaded can use a different IP

## Sticky Sessions ("Static" IPs)

**Best for:** Account management (FB, IG, Amazon), filling forms, checkout bots, social media accounts.
To keep the same IP across multiple requests, define a **Session ID**.

| Flag             | Example                                       |
| :--------------- | :-------------------------------------------- |
| `session_[name]` | `user_XXXX,country_US,session_googleaccount1` |

As long as you use the same `session_googleaccount1`, we route you through the same device for as long as that device stays available.

```bash theme={null}
curl -x "http://user_XXXX,session_myprofile:pass@portal.anyip.io:1080" http://ip-api.com/
```

### Sticky is not static

<Warning>
  **Read This Before Asking Support**

  Remember that "Sticky" is NOT "Static."

  We use **real peer devices** (people's phones and home wifi), not datacenter servers. Real people turn off their phones, lose signal, or drive into tunnels. No mobile carrier hands out a dedicated, static IP to a real user, so anyIP cannot offer one either.

  1. **If the peer goes offline:** We automatically rotate you to a *new* IP in the same location to keep your connection alive. This is the smart replacement behavior.
  2. **Duration:** A session typically lasts **up to 7 days**, but can be shorter, and always depends on IP availability.

  This is expected behavior, not a bug.
</Warning>

We do not share IPs with other customers at the same time. The IP assigned to your session is dedicated to you for the duration of that session.

### Smart replacement: what happens when the IP drops

When your sticky IP goes offline, we replace it without you changing anything:

* We try to assign a new IP in the same area and ISP you targeted, so the change is transparent to you and the site you are visiting.
* If no IP is available in that exact area, we assign the closest available location to your target.

This applies to both residential and mobile sticky sessions. For mobile, see the carrier behavior in [Network Types](/guides/network-types).

### How to keep a stable location

The IP may change, but the session tries to stay in the location you set. To improve your chances of staying in the same area when the IP rotates:

* Target a location with a large IP pool. A popular country such as the United States gives a better chance of getting an IP in the same area after a rotation.
* Set a specific state or city so replacements stay close. For example, `country_US,region_newyork,city_newyork`.
* Add an ASN to keep the same ISP across replacements. For example, `asn_21928` for T-Mobile USA.

Example configuration for a stable United States social media setup:

```text theme={null}
user_XXXX,type_mobile,country_US,region_newyork,city_newyork,session_ig_client1
```

Set this on the [Proxies page](https://anyip.io/account/#/proxy-accounts), then paste the username into your tool. For more on selecting a location, see [Location Targeting](/guides/location-targeting).

***

## How to Manually Rotate a Sticky IP

If your current sticky IP gets blocked or is too slow, you can force a change:

### Method A: Change the Session Name

Simply rename your session in your code/bot:

```
session_profile1   →  session_profile1_v2
```

**Result:** Instant new IP.

### Method B: Use the Change IP URL (Rotation Link)

You can rotate your IP programmatically without changing your code by calling a special URL.
**Where to find it:**

1. Go to [Dashboard > Proxies](https://anyip.io/account/).
2. Click **"Get Proxy Details"**.
3. Look for the **"Change IP URL"** under the Proxy credentials section.

**URL Format:**

```
https://dashboard.anyip.io/api/proxy_accounts/[proxy_id]/invalidate/[hash]/session/[session_name]
```

**Example:**
If your session name is `twitter3`, your rotation link would look like:

```
https://dashboard.anyip.io/api/proxy_accounts/abc123/invalidate/xyz789/session/twitter3
```

**How to use it:**

* Click the link in a browser
* Call it from a script: `curl "https://dashboard.anyip.io/api/proxy_accounts/.../session/twitter3"`
* Set it as a "Rotate" button in your bot/tool

<Warning>
  **Important**

  The rotation link only works if you have a `session_[name]` flag in your username. The session name in the URL must match exactly.
</Warning>

***

## Advanced Session Options

### Set a Custom Session Duration

By default, sessions last up to 7 days. You can set a shorter duration (1 to 10,080 minutes) with the `sesstime_[minutes]` flag:

```bash theme={null}
# Session expires after 10 minutes
curl -x "http://user_XXXX,session_temp,sesstime_10:pass@portal.anyip.io:1080" http://ip-api.com/
```

After 10 minutes, the session expires and a new IP is assigned automatically.

### Disable Auto-Replacement When IP Disconnects

By default, if your sticky IP goes offline, we assign you a new one automatically.
To **disable** this and stop the session from switching to a new IP, use the flag `sessreplace_false`:

```bash theme={null}
curl -x "http://user_XXXX,session_unique1,sessreplace_false:pass@portal.anyip.io:1080" http://ip-api.com/
```

If the IP disconnects, you'll receive a `peer_not_found` error instead of being switched to a new IP. Use this when you would rather fail than be moved to a different IP.

### Avoid IP Collision Across Sessions

Managing multiple accounts? Use `sessipcollision_strict` to ensure no two sessions ever share the same IP:

```bash theme={null}
curl -x "http://user_XXXX,session_account1,sessipcollision_strict:pass@portal.anyip.io:1080" http://ip-api.com/
curl -x "http://user_XXXX,session_account2,sessipcollision_strict:pass@portal.anyip.io:1080" http://ip-api.com/
```

Each session is guaranteed a unique IP.

### Keep the Same ISP/ASN When IP Changes

If an IP disconnects, we try to find a replacement in the same area. To **strictly** require the same ISP (ASN), use the flag `sessasn_strict`:

```bash theme={null}
curl -x "http://user_XXXX,session_bank,sessasn_strict:pass@portal.anyip.io:1080" http://ip-api.com/
```

This increases success rates for sensitive use cases.
