# Session Lifecycle
URL: /overview/sessions-api/session-lifecycle

---
title: Session Lifecycle
sidebarTitle: Session Lifecycle
description: Learn how to start and release browser sessions programmatically.
llm: true
---

### Overview
Sessions are the foundation of browser automation in Steel. Each session represents an isolated browser instance that persists until it's either explicitly released or times out.

Each session can be in one of three states:

*   **Live**: The session is active and ready to accept commands/connections. This is the state right after creation and during normal operation.

*   **Released**: The session has been intentionally shut down, either through explicit release or timeout. Resources have been cleaned up. Can no longer accept commands/connections.

*   **Failed**: Something went wrong during the session's lifetime (like a crash or connection loss). These sessions are automatically cleaned up.


Browser sessions are billed and metered by the minute. A session can last up to 24 hours depending on your plan.

Understanding how sessions live and die helps you manage resources effectively and build more reliable applications.

### Session Lifetime and Timeout

When you start a session, it stays alive for 5 minutes by default but you can change it by passing the timeout parameter. After the time passes, the session will be automatically released.

<CodeTabs storage="languageSwitcher">

```typescript !! Typescript -wcn
import Steel from 'steel-sdk';

const client = new Steel();

// Create session and keep it running for 10 minutes.
const session = await client.sessions.create({
  timeout: 600000 // 10 minutes (NOTE: Units are in milliseconds)
});
```


```python !! Python -wcn
import os
from steel import Steel

client = Steel()

# Create session and keep it running for 10 minutes.
session = client.sessions.create(
    api_timeout=600000 # 10 minutes (NOTE: Units are in milliseconds)
)
```
</CodeTabs>

**Note:** Currently, Steel doesn’t support editing the timeout duration of a live session.

### Inactivity Timeout

By default a session runs until its `timeout` elapses, even when nothing is driving the browser. Set `inactivityTimeout` to release the session early once it stops seeing activity—any CDP command or remote input—so you don’t keep paying for an idle browser while waiting on an external step.

<CodeTabs storage="languageSwitcher">

```typescript !! Typescript -wcn
import Steel from 'steel-sdk';

const client = new Steel();

// Release the session after 1 minute with no CDP or input activity,
// capped at a 10-minute hard limit.
const session = await client.sessions.create({
  timeout: 600000,          // 10 minutes (hard cap)
  inactivityTimeout: 60000, // release after 1 minute of inactivity
});
```


```python !! Python -wcn
import os
from steel import Steel

client = Steel()

# Release the session after 1 minute with no CDP or input activity,
# capped at a 10-minute hard limit.
session = client.sessions.create(
    api_timeout=600000,       # 10 minutes (hard cap)
    inactivity_timeout=60000, # release after 1 minute of inactivity
)
```
</CodeTabs>

**Note:** `timeout` is always the hard cap on a session’s lifetime. If `inactivityTimeout` is greater than or equal to `timeout` it has no effect—`timeout` elapses first. Omit `inactivityTimeout` to disable inactivity-based release (the default).

### **Releasing a Session**

When you're done with a session, it's best practice to release it explicitly rather than waiting for the timeout. You can release a session any time before the timeout is up by calling the `release` method.


<CodeTabs storage="languageSwitcher">

```typescript !! Typescript -wcn
// Release a single session
const response = await client.sessions.release(session.id);
```


```python !! Python -wcn
# Release a single session
response = client.sessions.release(session.id)
```
</CodeTabs>

#### Bulk Session Release

Sometimes you need to clean up all active sessions at once. Steel provides a convenient way to do this:

<CodeTabs storage="languageSwitcher">

```typescript !! Typescript -wcn
// Release all active sessions
const response = await client.sessions.releaseAll();
console.log(response.message); // "All sessions released successfully"
```


```python !! Python -wcn
# Release all active sessions
response = client.sessions.release_all()
print(response.message) # "All sessions released successfully"
```

</CodeTabs>

:::callout
type: help
### Need help building with the Sessions API?
Reach out to us on the <span className="font-bold">#help</span> channel on [Discord](https://discord.gg/steel-dev) under the ⭐ community section.
:::

### FAQ

### How long does a Steel browser session stay alive by default?

5 minutes — after that the session is automatically released. You can change this by passing the `timeout` parameter (in milliseconds) when creating the session, e.g. `timeout: 600000` for 10 minutes.

### What is the maximum length of a Steel session?

Up to 24 hours, depending on your plan. Sessions are billed and metered by the minute.

### Can I extend the timeout of a running Steel session?

No — Steel currently doesn't support editing the timeout duration of a live session, so set the `timeout` you need at creation time.

### How do I avoid paying for an idle Steel session?

Set `inactivityTimeout` so the session releases itself if your side goes quiet — for example when your agent crashes, hangs, or simply stops sending commands. Without it (the default), a stalled client keeps the session alive and billed until the hard `timeout` cap; with it, any CDP command or remote input resets the timer, so normal automation is unaffected while you're protected from paying for a browser nobody is driving.

### How do I end a Steel session before it times out?

Call `client.sessions.release(session.id)` — releasing explicitly is best practice rather than waiting for the timeout. To clean up everything at once, `client.sessions.releaseAll()` releases all active sessions.
