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

# Watch page events

> Follow page, console, and network events as they happen

Follow page, console, network, and dialog events as they happen. Each event has a `seq` you can resume from, so a reconnect does not skip or repeat events.

## Follow events as they happen

`events` yields frames until the current long-poll page ends. `wait_ms`
bounds a page — the server default is 25 s, the cap 30 s — and an idle page
ends after one keep-alive, so readers always return promptly rather than
hanging on a quiet browser.

```python Python theme={null}
from gravixlayer import GravixLayer

client = GravixLayer()
sandbox = client.runtime.create(template="browser-small")
browser = sandbox.browser.open()
bid = browser["browser_id"]

sandbox.browser.navigate(bid, "https://example.com")

last_seq = 0
for frame in sandbox.browser.events(bid, wait_ms=10_000):
    if frame["kind"] == "error":
        break  # the stream ended with an error
    entry = frame["data"]          # {seq, kind, target_id, usec, detail}
    print(entry["kind"], entry["target_id"], entry["detail"])
    last_seq = frame["seq"]
```

```typescript TypeScript theme={null}
import { GravixLayer } from 'gravixlayer';

const client = new GravixLayer();
const sandbox = await client.runtime.create({ template: 'browser-small' });
const browser = await sandbox.browser.open();

await sandbox.browser.navigate(browser.browserId, 'https://example.com');

for await (const event of sandbox.browser.events(browser.browserId, { waitMs: 10_000 })) {
  console.log(event.kind, event.targetId, event.detail);
}
```

```bash CLI theme={null}
gravixlayer runtime browser navigate "$RT" --browser b1 https://example.com

# One page of events — JSON frames, one per event
gravixlayer runtime browser events "$RT" --browser b1 --wait-ms 10000
```

```bash cURL theme={null}
API="https://api.gravixlayer.ai/v1"

curl -sS -X POST "$API/agents/runtime/$RT/browser/b1/navigate" \
  -H "Authorization: Bearer $GRAVIXLAYER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com"}'

# SSE stream — id: is the seq, event: the kind, data: the event entry
curl -sS -N "$API/agents/runtime/$RT/browser/b1/events?wait_ms=10000" \
  -H "Authorization: Bearer $GRAVIXLAYER_API_KEY" \
  -H "Accept: text/event-stream"
```

## Resume after a disconnect

`since` resumes strictly after a sequence number — pass the last `seq` you
processed to chain pages without replaying or dropping events. The same
value goes on the wire as the `Last-Event-ID` header, so a reconnection can
pick up mid-stream the same way.

```python Python theme={null}
# Next page starts strictly after the last frame we handled
for frame in sandbox.browser.events(bid, since=last_seq, wait_ms=10_000):
    handle(frame)
    last_seq = frame["seq"]
```

```typescript TypeScript theme={null}
// Next page starts strictly after the last event we handled
for await (const event of sandbox.browser.events(browser.browserId, {
  since: lastSeq,
  waitMs: 10_000,
})) {
  handle(event);
  lastSeq = event.seq;
}
```

```bash CLI theme={null}
# Resume strictly after the last seq processed
gravixlayer runtime browser events "$RT" --browser b1 --since "$LAST_SEQ" --wait-ms 10000
```

```bash cURL theme={null}
API="https://api.gravixlayer.ai/v1"

# Resume mid-stream — since and Last-Event-ID are interchangeable
curl -sS -N "$API/agents/runtime/$RT/browser/b1/events?wait_ms=10000" \
  -H "Authorization: Bearer $GRAVIXLAYER_API_KEY" \
  -H "Accept: text/event-stream" \
  -H "Last-Event-ID: $LAST_SEQ"
```

Event sequence numbers are per-browser and survive for the browser's
lifetime — a forked runtime keeps its own independent log.

## Endpoint

| Method | Path | Description |
| - | - | - |
| GET | `/v1/agents/runtime/{runtime_id}/browser/{browser_id}/events` | Event stream (SSE) |


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