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

# Overview

> Architecture for the End Browser Session endpoint

## Purpose

Ends a Browserbase session and cleans up resources. Called when the user leaves the page or the session is no longer needed.

## Architecture

```mermaid theme={null}
flowchart TD
    Request["DELETE /api/browser-session/{session_id}"]
    
    CancelTask["Cancel navigation task"]
    ReleaseSession["Request session release"]
    ClearCache["Remove from cache"]
    
    Request --> CancelTask
    CancelTask --> ReleaseSession
    ReleaseSession --> ClearCache
    ClearCache --> Response["Return success"]
```

## Cleanup Steps

1. **Cancel Navigation Task** - Stop any in-progress Playwright navigation
2. **Release Session** - Tell Browserbase to release the session
3. **Clear Cache** - Remove from `_ACTIVE_SESSION_BY_CLIENT`

## Browserbase Release

```python theme={null}
POST /v1/sessions/{session_id}
{
    "projectId": project_id,
    "status": "REQUEST_RELEASE"
}
```

## Code Location

```
src/website/browser_session/routes.py
# Lines 324-367: end_browser_session()
```

## Rate Limiting

* **10 requests per minute** per IP address
