Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.mortemlabs.com/llms.txt

Use this file to discover all available pages before exploring further.

The live endpoint opens a persistent Server-Sent Events (SSE) connection that delivers trace and event updates for a specific agent as they arrive. When your agent is actively running, batches appear on the stream within a second of being written to storage. This is the same stream the Mortem dashboard uses to power the live trace view on the agent detail page.
GET https://ingest.mortem.dev/v1/agents/:id/live

Authentication

The live endpoint uses a Privy JWT, not an agent API key. This is because the stream is consumed by the dashboard running in the browser, not by the agent itself. The Privy JWT is the same token issued when you log in to the Mortem dashboard. Pass the token in the Authorization header:
Authorization: Bearer <PRIVY_JWT>
The endpoint checks that the authenticated user has owner, editor, or viewer access to the requested agent. If they do not, it returns 403 Forbidden.
If you are building a custom integration that needs to consume the live stream programmatically from server-side code, contact the Mortem team. The current authentication model is designed for browser-based dashboard consumption.

Path parameters

id
string
required
The agent ID whose live trace updates you want to stream. This is the same MORTEM_AGENT_ID value used when configuring the SDK.

Response

The endpoint responds with 200 OK and the following headers:
Content-Type: text/event-stream; charset=utf-8
Cache-Control: no-cache, no-transform
Connection: keep-alive
The connection stays open indefinitely. Each update arrives as a Server-Sent Event with the event name trace and a JSON-encoded body.

Event format

event: trace
data: <JSON-encoded BufferBatchItem>
Each data value is a JSON string representing a single BufferBatchItem — the same object shape sent in the items array of a batch request. It contains a trace object (full snapshot of the trace state at flush time) and an events array (new events added since the last flush).

Replay on connect

When you first connect, the endpoint replays up to the last 1,000 batches stored for the agent before switching to real-time delivery. This means you see recent history immediately without waiting for new agent activity. The replay events arrive in chronological order before any new live events.

Warning events

If the live stream is temporarily interrupted — for example due to a Redis connectivity issue — the endpoint emits a warning event:
event: warning
data: {"message":"live stream interrupted"}
The connection remains open after a warning. You can continue listening; new batches will resume when the underlying issue resolves.

Example

curl \
  -H "Authorization: Bearer $PRIVY_JWT" \
  -H "Accept: text/event-stream" \
  https://ingest.mortem.dev/v1/agents/$MORTEM_AGENT_ID/live
The 1,000-batch replay buffer is scoped per agent. Live replay is a convenience feature, not a durable event log. For the full trace record, use the dashboard trace detail view.