# sessions.renew

`POST /api/public/v1/sessions/{id}/renew`

Extend your app hold by its ttl_seconds with the generation and holder_ref acquire returned; FENCED (with the reason superseded, detached, expired or session_ended) means acquire again before touching the browser.

- Capability: `session.start`
- Command: no
- MCP tool: `sessions_renew`

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string (uuid) | yes | Session id |
| `generation` | body | integer | yes | lease.generation from acquire (min 1, max 9007199254740991) |
| `holder_ref` | body | string | yes | Your stable name for this holder (worker, job); renew and detach must send the same value (min length 1, max length 120) |

## Response

`200` with `{ data, correlation_id }`.

| Field | Type | Always present | Description |
|---|---|---|---|
| `data` | object | yes |  |
| `data.lease` | object | yes |  |
| `data.lease.session_id` | string (uuid) | yes |  |
| `data.lease.app_id` | string | yes |  |
| `data.lease.binding_id` | string (uuid) \| null | no |  |
| `data.lease.holder_ref` | string | yes |  |
| `data.lease.generation` | integer | yes | Send with renew and detach; an older generation is FENCED (min -9007199254740991, max 9007199254740991) |
| `data.lease.state` | "active" \| "detached" \| "lapsed" \| "ended" | yes |  |
| `data.lease.ttl_seconds` | integer | yes | (min -9007199254740991, max 9007199254740991) |
| `data.lease.keep_warm_seconds` | integer | yes | (min -9007199254740991, max 9007199254740991) |
| `data.lease.acquired_at` | string (date-time) | yes |  |
| `data.lease.expires_at` | string (date-time) | yes |  |
| `data.lease.keep_warm_until` | string (date-time) | no |  |
| `data.lease.ended_reason` | string | no |  |
| `data.lifecycle` | "queued" \| "preflight" \| "starting" \| "ready" \| "quiescing" \| "stopping" \| "closed" \| "failed" \| … | yes |  |
| `correlation_id` | string (uuid) | yes |  |

New fields can appear at any time; ignore the ones you do not know.

## Errors

| Code | HTTP | Retryable |
|---|---|---|
| `UNAUTHENTICATED` | 401 | no |
| `FORBIDDEN` | 403 | no |
| `RATE_LIMITED` | 429 | yes |
| `VALIDATION_FAILED` | 422 | no |
| `NOT_FOUND` | 404 | no |
| `FENCED` | 409 | no |
| `DEPENDENCY_UNAVAILABLE` | 503 | yes |
| `UNKNOWN` | 500 | no |

## Example (curl)

```bash
curl -X POST "https://browlix.com/api/public/v1/sessions/<id>/renew" \
  -H "Authorization: Bearer $BROWLIX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"generation":0,"holder_ref":"<holder_ref>"}'
```

## Example (TypeScript SDK)

```ts
import { Browlix } from "@browlix/sdk";

const bx = new Browlix({ apiKey: process.env.BROWLIX_API_KEY! });
const reply = await bx.call("sessions.renew", { path: { id: "<id>" }, body: {"generation":0,"holder_ref":"<holder_ref>"} });
console.log(reply.data);
```

## Example (Python)

```python
import os
import requests

r = requests.post(
    "https://browlix.com/api/public/v1/sessions/<id>/renew",
    headers={"Authorization": f"Bearer {os.environ['BROWLIX_API_KEY']}"},
    json={"generation":0,"holder_ref":"<holder_ref>"},
    timeout=60,
)
print(r.status_code, r.json())
```

## Example (MCP)

```json
{
  "method": "tools/call",
  "params": {
    "name": "sessions_renew",
    "arguments": {
      "id": "<id>",
      "generation": 0,
      "holder_ref": "<holder_ref>"
    }
  }
}
```
