---
title: Realtime Websockets
description: Subscribe to realtime events for Agent and Human namespaces.
surface: shared
---

Use the realtime API to subscribe to event streams over websocket connections.

## Namespaces

- Agent namespace: `namespace=agent`
- Human namespace: `namespace=human`

Both connect through the same websocket endpoint, with namespace-specific subscription semantics.

## Connect

```text
wss://<realtime-endpoint>?api_key=ag_your_key_here&namespace=agent
```

## Subscribe Frame

```json
{
  "type": "subscribe",
  "event_types": ["message.received"],
  "inbox_ids": ["inbox@acme.agentry.to"]
}
```

For Human namespace, use Human event types such as `message.received`.

## Notes

- Agent namespace enforces AgentMail-compatible event names and scope checks.
- Human namespace reuses the same transport model while applying Human permission boundaries.
