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

# Sessions

A session is an isolated Chrome instance. Cookies and browser storage persist between requests within the session.

The session ends when deleted, after `idle_timeout` seconds of inactivity, or when its `ttl` expires. Browser actions and CDP or Playwright activity reset the inactivity timer. Reading session metadata does not reset it.

Billing for Free and credit-funded accounts: session creation, browser time, drive actions and traffic are charged separately at the rates in `GET /v1/credits`. Developer and Team have no per-call wallet debits. Reads (`GET /v1/session/{id}`, `/status`, `/sessions`, `/tabs`, `GET /context`, `/connect`, `/regions`, the token mints) add no action charge.

## POST /v1/session

Create a browser session and return its connection URLs. All request fields are optional. Send `{}` to use the defaults.

Auth: Bearer API key. Optional header `Idempotency-Key`: a retry with the same key returns the same session instead of starting a second one. The key is remembered for about an hour. A concurrent retry waits for the create to settle, for up to about 185 seconds; only an unsettled create answers 409 `idempotency_key_in_use`.

Request:

| Field | Type | Default | Meaning |
| - | - | - | - |
| `mode` | `"ephemeral"` or `"persistent"` | `ephemeral` | Session mode. Both honour `ttl` and `idle_timeout`. |
| `region` | string | nearest | A `code` from `GET /v1/regions` (`us`, `de`, `sg`). Unknown codes answer 422. |
| `persona` | string, max 64 | rotated | Pin the device identity (screen, cores, GPU, fonts). Omit it and the session gets one of your account's personas; the one used is returned as `persona`. |
| `ttl` | number, 5 to 604800 | mode and plan dependent | Absolute lifetime in seconds. Ephemeral defaults to 3600, lowered to the plan cap (1800 on Free). Persistent defaults to the plan's longest session when capped; inspect the returned `ttl` for the applied value. An explicit value above the plan maximum answers 422 `ttl_exceeds_plan` with `max_ttl`. |
| `idle_timeout` | number, 1 to 3600 | 300 | Seconds without a drive or CDP call before the session ends. |
| `proxy` | object `{server, username, password}` | none | Route browser traffic through your own HTTP or HTTPS proxy. All three fields are required when provided. See [Custom proxies](https://docs.tilion.dev/sessions/custom-proxy.md) for validation, conflicting fields, and billing. |
| `residential` | boolean | fleet default (direct) | `true` routes the session through a residential exit, metered as premium egress. Every current plan includes premium egress; Free includes 1 GB and then answers 402 `premium_egress_exhausted`. `false` forces direct datacenter egress. Strict boolean: `"yes"` or `1` answers 422. |
| `proxy_type` | `"residential"` or `"mobile"` | none | Pin the paid exit type. Implies `residential: true`. A type not served right now answers 409 `proxy_type_unavailable`. |
| `geo` | object `{zip, city, state, country}` | none | Place a residential exit near a US ZIP (5 digits), a city (lowercase, no spaces), a state (2 letter) or a country (2 letter). Ignored on a direct session. The response says what landed in `geo_applied` and `geo_unsupported`. |
| `exit_region` | string like `us-east-1` | none | Narrow the exit choice to one region. |
| `exit_id` | string `eipalloc-...` | none | Start on one specific exit, for example the `exit_id` a previous session returned. |
| `proxy_rotation` | `per_session`, `per_request`, `manual` | `per_session` | Accepted for compatibility and served as `per_session`. Use `POST /v1/session/{id}/rotate-ip` to change a Tilion exit. Custom-proxy sessions return `409 customer_proxy_session`; manage their exit through your proxy provider. |
| `stealth` | `true` or `"max"` | `true` | Sessions are always stealth hardened; `false` answers 400 `stealth_always_on`. `"max"` starts on residential egress with a sticky exit from the first request, metered as premium egress. `"max"` with `residential: false` answers 400 `stealth_max_needs_premium_egress`. |
| `block_ads` | `false`, `true`, `"basic"`, `"strict"`, `"off"` | `false` | Ad and tracker blocking. `true` or `basic` is the host blocklist; `strict` is the full filter engine, disables the HTTP cache and is detectable, so do not use it on an anti-bot target. |
| `full_browser` | boolean | `false` | Boot a headful Chrome with a visible desktop, watchable over VNC (`/vnc-token`). The response's `full_browser` tells you whether it was honoured. |
| `kiosk` | boolean | `false` | Same as `full_browser`. |
| `start_url` | URL, max 2048 | none | Navigate here before the session is returned. A URL that cannot be opened fails the create with 502. |
| `warm` | list of up to 3 URLs | none | Accepted for compatibility; has no effect on the hosted service. |
| `warm_up` | boolean | `false` | Accepted for compatibility; has no effect on the hosted service. |
| `record` | boolean or null | deployment default | Capture a frame replay. `true` requests recording; `false` disables it; null uses the deployment default. See [Recordings](https://docs.tilion.dev/sessions/live-view.md#recordings). |
| `record_minutes` | integer or null | plan's number | Lower the [recording cap](https://docs.tilion.dev/sessions/live-view.md#recording-minutes) for this session. Above the plan's number answers 422 `record_minutes_exceeds_plan` with `max_minutes`. |
| `profile` | object | none | Start from a [browser profile](https://docs.tilion.dev/sessions/profiles.md): `{name or profile_id, save, domains, coherence, full, folder, cache}`. |
| `profile_id` | string | none | Shorthand for `profile: {"profile_id": ...}`, read only. |
| `end_user_ref` | string, 1 to 128 | none | Open a protected session for one of your users, so it can sign in with that user's [end-user credentials](https://docs.tilion.dev/automation/end-user-credentials.md). Needs the `end_user_credentials:use` scope. The response adds `end_user_ref` and `protected: true`. Cannot be combined with `proxy` (400 `proxy_not_allowed`). |
| `cdp_observe` | boolean | `true` | Watch main-client CDP or Playwright page loads for blocks and challenges and hold the next command until the page settles (0.5 to 3 s per page load). `false` disables automatic recovery for those page loads. CDP observers bypass automatic recovery regardless of this setting; this field does not select the observer role. |

```bash theme={"dark"}
curl -X POST https://back.tilion.dev/v1/session \
  -H "Authorization: Bearer ph_live_..." \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: my-create-1" \
  -d '{}'
```

Response (201):

```json theme={"dark"}
{
  "session_id": "sess_3d245e56b86d4bc8ae32095b644117d4",
  "state": "ready",
  "mode": "ephemeral",
  "region": null,
  "owner": "acme",
  "created_at": 1792420179.1767488,
  "last_active": 1792420179.1897585,
  "idle_timeout": 300.0,
  "ttl": 3600.0,
  "expires_at": 1792420479.1897585,
  "connect_url": "wss://back.tilion.dev/v1/session/sess_3d245e56b86d4bc8ae32095b644117d4/cdp?token=<token>",
  "connect_expires_in": 1800,
  "playwright_url": "wss://back.tilion.dev/v1/session/sess_3d245e56b86d4bc8ae32095b644117d4/playwright?token=<token>",
  "exit_id": null,
  "persona": "tenant-018658e41dd54701e9bf45c6",
  "full_browser": false,
  "geo_applied": null,
  "geo_unsupported": null,
  "site_check": null,
  "replay_url": null
}
```

Response fields:

| Field | Type | Meaning |
| - | - | - |
| `session_id` | string | Use it in every session route. |
| `state` | string | `ready` is drivable. `remote` can appear briefly in the list while a session created elsewhere is being registered. Ended sessions report `closed` or `expired` in their terminal record. |
| `mode` | string | `ephemeral` or `persistent`. |
| `region` | string or null | The region you asked for; null when you let the API choose. |
| `owner` | string | Your account. |
| `created_at`, `last_active` | float | Unix seconds. `last_active` moves on every drive or CDP call. |
| `idle_timeout`, `ttl` | float | The values in force, after defaults and the plan cap. |
| `expires_at` | float | When the session ends if nothing else happens: the sooner of `last_active + idle_timeout` and `created_at + ttl`. |
| `connect_url` | string or null | Raw CDP endpoint with a 1800 second token. Only on create and `/connect`; null on reads. |
| `connect_expires_in` | number or null | Seconds the token in `connect_url` and `playwright_url` stays valid: 1800. |
| `playwright_url` | string or null | Native Playwright endpoint for `chromium.connect(...)`, same token. |
| `exit_id` | string or null | The exit the session started on, when one was chosen for it. Pass it as `exit_id` on a later create to reuse it. |
| `persona` | string or null | The device identity when selected by the API. Do not rely on a caller-supplied persona being echoed. |
| `site_check` | object or null | The site-check outcome when a site check was requested; null otherwise. |
| `replay_url` | string or null | Tokenized path to the frame replay when recording is enabled. Prefix `https://back.tilion.dev`. Null when no recording was started. |
| `full_browser` | boolean | Whether the session has a visible desktop (VNC). |
| `profile` | object or null | The [profile](https://docs.tilion.dev/sessions/profiles.md) the session started from: `name`, `version`, `save`, `restored`, `coherence`. Null with no profile. |
| `geo_applied` | boolean or null | Null without `geo`; `true` when the exit was placed as asked; `false` when the exit provider refused the target and the session fell back to the country exit. |
| `geo_unsupported` | list or null | The `geo` fields that could not be honoured, for example `["city", "zip"]`. |

Errors:

Custom-proxy creation can also return `customer_proxy_*` errors. See the [custom proxy error table](https://docs.tilion.dev/sessions/custom-proxy.md#errors).

| Status | `error` or message | When |
| - | - | - |
| 400 | `stealth_always_on` | `stealth: false`. |
| 400 | `stealth_max_needs_premium_egress` | `stealth: "max"` together with `residential: false`. |
| 401 | `Missing API key` or `Invalid API key` | No or bad bearer. |
| 402 | `insufficient_credits` (`required`, `balance`) | The wallet cannot cover the session charge plus one minute. |
| 402 | `quota_exceeded` (`reason`, `tier`) | The plan's monthly allowance is used up and the plan has no overage. |
| 402 | `premium_egress_exhausted` | The included premium-egress allowance is used up on a plan without overage. |
| 409 | `region_unavailable` (`available`), `proxy_type_unavailable`, `idempotency_key_in_use` | No exit in that region; the exit type is not served now; a create with that key could not settle within the wait budget. |
| 422 | validation list | Unknown `region`, `ttl` outside 5 to 604800, `idle_timeout` outside 1 to 3600, non-boolean `residential`, bad `geo`. |
| 422 | `ttl_exceeds_plan` (`max_ttl`) | `ttl` above the plan's maximum session length. |
| 429 | `concurrency_limit` (`limit`, `tier`) or a creates-per-minute throttle | Too many live sessions, or too many creates. |
| 502 | `session_launch_failed` | The browser could not start; retry. |
| 502 | `Data Plane start URL navigation failed` | `start_url` could not be opened; the session was released. |
| 503 | `capacity_unavailable` (`Retry-After: 5`) | No capacity in the region right now. |
| 503 | `recording_unavailable` | Recording was requested but recording storage is unavailable. |
| 503 | `residential_egress_unavailable`, `residential_vendor_unavailable` (`Retry-After: 60`), `full_browser_unavailable` | The requested exit type or the visible desktop cannot be provided; only the vendor case is worth a retry. |

Examples as returned:

```jsonl theme={"dark"}
{"detail": [{"type": "value_error", "loc": ["body", "region"], "msg": "Value error, unknown region 'zz'; see GET /v1/regions", "input": "zz", "ctx": {"error": {}}}]}
{"detail": {"error": "stealth_always_on", "message": "sessions are stealth-hardened by construction; stealth cannot be disabled"}}
```

The browser is running when this request returns. The first browser action can take a few hundred milliseconds longer than subsequent actions. Delete the session in a `finally` block to stop browser-time metering when your code finishes or fails.

## GET /v1/session/\{session\_id}

Read a session without touching its idle clock. `connect_url`, `connect_expires_in` and `playwright_url` are always null here; mint them with `/connect`.

```bash theme={"dark"}
curl https://back.tilion.dev/v1/session/sess_3d245e56b86d4bc8ae32095b644117d4 \
  -H "Authorization: Bearer ph_live_..."
```

Response (200):

```json theme={"dark"}
{
  "session_id": "sess_3d245e56b86d4bc8ae32095b644117d4",
  "state": "ready",
  "mode": "ephemeral",
  "region": null,
  "owner": "acme",
  "created_at": 1792420179.1767488,
  "last_active": 1792420197.5259109,
  "idle_timeout": 300.0,
  "ttl": 3600.0,
  "expires_at": 1792420497.5259109,
  "connect_url": null,
  "connect_expires_in": null,
  "playwright_url": null,
  "exit_id": null,
  "persona": null,
  "full_browser": false,
  "geo_applied": null,
  "geo_unsupported": null
}
```

Errors: 404 `No such session` for an id that never existed, is not yours, or whose record has aged out (about an hour after it ended); 410 with the terminal record while the ended session is still remembered; 410 `browser_crashed` (`retryable: false`) when the browser died, in which case the session is released for you.

## GET /v1/session/\{session\_id}/status

Lifecycle state of a session, live or ended, without extending its idle deadline. For a live session the body is the same as `GET /v1/session/{id}`. For an ended one it is the terminal record with status 200 rather than 410, which makes it the route to poll from a monitor.

Response for an ended session (200):

```json theme={"dark"}
{
  "session_id": "sess_3d245e56b86d4bc8ae32095b644117d4",
  "owner": "acme",
  "state": "closed",
  "mode": "ephemeral",
  "region": null,
  "reason": "closed",
  "origin": "customer",
  "cause": null,
  "created_at": 1792420179.1767488,
  "last_active": 1792420909.7551606,
  "idle_timeout": 300.0,
  "ttl": 3600.0,
  "closed_at": 1792420909.7551966,
  "cleanup": "done",
  "cleaned_at": 1792420910.0134642,
  "cleanup_finished_at": 1792420910.0134647,
  "retained_until": 1792424509.7551966
}
```

Terminal record fields: `state` is `closed` or `expired`; `reason` is `closed`, `idle_expired`, `ttl_expired` or a service reason; `origin` is `customer`, `expired`, `data_plane` or `host` (who ended it); `cause` names the failure that ended it when the service did, else null; `cleanup` is `pending`, `done` or `failed`; `retained_until` is when the record disappears (one hour after close) and the id starts answering 404.

Errors: 404 `No such session`.

## GET /v1/sessions

Every live session on your account, across all regions. `connect_url` is null on every entry. `last_active` can be null for sessions held by another server; their `expires_at` is the absolute `ttl` deadline. Read one session for its current idle deadline.

Response (200):

```json theme={"dark"}
[
  {
    "session_id": "sess_3d245e56b86d4bc8ae32095b644117d4",
    "state": "ready",
    "mode": "ephemeral",
    "region": null,
    "owner": "acme",
    "created_at": 1792420179.1767488,
    "last_active": null,
    "idle_timeout": 300.0,
    "ttl": 3600.0,
    "expires_at": 1792423779.1767488,
    "connect_url": null,
    "connect_expires_in": null,
    "playwright_url": null,
    "exit_id": null,
    "persona": null,
    "full_browser": false,
    "geo_applied": null,
    "geo_unsupported": null
  }
]
```

An empty account answers `[]`. Use it to find sessions you forgot to release; an unexpected 429 `concurrency_limit` on create is almost always that.

## DELETE /v1/session/\{session\_id}

End the session and destroy its browser. 204 with no body once the session is removed from your account; the browser is torn down right after. The `Location` header points at `/status`, where the terminal record is readable for an hour.

```bash theme={"dark"}
curl -X DELETE https://back.tilion.dev/v1/session/sess_3d245e56b86d4bc8ae32095b644117d4 \
  -H "Authorization: Bearer ph_live_..."
```

Response: `HTTP 204`, header `location: /v1/session/sess_3d245e56b86d4bc8ae32095b644117d4/status`.

What the id answers afterwards:

* `GET /v1/session/{id}` answers 410 with the terminal record as `detail`.
* `GET /v1/session/{id}/status` answers 200 with the terminal record.
* `DELETE` again answers 204 (safe to repeat).
* `GET /v1/session/{id}/connect`, `POST .../view-token`, `POST .../navigate` and every other session route answer 410 with the same record.
* A CDP or Playwright connect with a token minted before the delete is refused at the handshake.

Errors: 404 `No such session` for an id that never existed or is not yours; 503 `session worker unavailable; retry cleanup` when the session's host could not be reached, in which case the browser is not confirmed gone and you should retry.

## GET /v1/regions

The region codes `POST /v1/session` accepts. The response header `X-Tillion-Region-Registry-Version` identifies the region table.

```json theme={"dark"}
[
  {"code": "us", "name": "United States", "country": "us", "timezone": "America/New_York"},
  {"code": "de", "name": "Germany", "country": "de", "timezone": "Europe/Berlin"},
  {"code": "sg", "name": "Singapore", "country": "sg", "timezone": "Asia/Singapore"}
]
```

The region decides the exit's country and the browser's timezone and locale. Only regions where a session can really be placed are listed.

## GET /v1/session/\{session\_id}/connect

Mint a fresh CDP connect URL and Playwright URL for a live session. Call it when the URLs from create have expired (1800 seconds) or when another process needs to attach.

For [multiple CDP clients](https://docs.tilion.dev/sessions/playwright-cdp.md#multiple-cdp-clients), use `connect_url` unchanged for the main client and append `&role=observer` for up to 4 observers. The feature must be enabled for the account.

```json theme={"dark"}
{
  "session_id": "sess_3d245e56b86d4bc8ae32095b644117d4",
  "connect_url": "wss://back.tilion.dev/v1/session/sess_3d245e56b86d4bc8ae32095b644117d4/cdp?token=<token>",
  "playwright_url": "wss://back.tilion.dev/v1/session/sess_3d245e56b86d4bc8ae32095b644117d4/playwright?token=<token>",
  "expires_in": 1800,
  "protocol": "raw_cdp"
}
```

The expiry field is `expires_in` here and `connect_expires_in` on create. Errors: 403 when the key lacks the `sessions:write` (or `cdp`) scope; 404 and 410 as for GET; 409 `session browser not ready` right after a create that is still booting; 410 `browser_crashed`; 503 when connect URLs cannot be minted.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.