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

# Events

> Receive durable live events through the Agent Relay or fallback mailbox.

# Events

For live caller turns, use the outbound **Agent Relay**. It reconnects, retains
events until ACK, and works without a public inbound URL. Use the mailbox for
non-live fallback awareness when neither relay nor webhook is available.

See [Agent Relay](https://docs.agentline.cloud/guides/relay.md) for the two-command runtime setup.

JavaScript examples call `https://api.agentline.cloud` with `fetch` and a
Bearer `al_live_...` key. The Node package is not on npm.

## Poll (fallback, consume once)

`poll` returns pending events **and deletes them** — treat it as a
one-time read.

```python theme={null}
result = client.events.poll(event_type="call.completed", limit=50)
for e in result["events"]:
    print(e["event_type"], e["payload"])
```

```javascript theme={null}
const result = await fetch(
  "https://api.agentline.cloud/v1/events?event_type=call.completed&limit=50",
  { headers: { Authorization: "Bearer al_live_..." } },
).then((res) => res.json());
for (const e of result.events) console.log(e.event_type, e.payload);
```

Each event has `{ event_id, agent_id, event_type, payload, created_at }`.
The backend emits:

* `call.received` — inbound answer
* `call.utterance` — a live caller turn. Its `conversation` field uses `user` and `assistant`.
* `call.completed`
* `call.owner_task`
* `call.failed`
* `call.busy`
* `call.no-answer`
* `call.canceled`
* `sms.received`
* `webhook.test`

`GET /v1/calls/{id}/transcript` uses different role names: `human` and `agent`.

## Peek (non-destructive)

`peek` previews what's queued **without** consuming it — handy to check before
committing to retrieve.

```python theme={null}
client.events.peek(agent_id=agent.id)
```

```javascript theme={null}
await fetch(`https://api.agentline.cloud/v1/events/peek?agent_id=${agent.id}`, {
  headers: { Authorization: "Bearer al_live_..." },
});
```

> [!TIP]
>
> Prefer [Agent Relay](https://docs.agentline.cloud/guides/relay.md) for live calls, then [webhooks](https://docs.agentline.cloud/guides/webhooks.md)
> for a public inbound integration. Use the mailbox for fallback polling only.


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