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

# Configure production monitoring by agent platform

> List and configure project Monitoring setup for Retell polling and LiveKit Agents OTLP export.

A **Monitoring setup** tells Egma how to receive production evidence from one
agent platform. It is project configuration. It is not a simulation connection
and it does not require an Egma agent.

All routes on this page use the normal Egma authentication rules. Pass the
project id or name in the `project` query parameter. A project-scoped API key
can omit it when the key already names the project.

## List Monitoring setup

**`GET /api/monitoring`**

Returns the Retell and LiveKit Agents setup records in one project.

<ParamField query="project" type="string">
  Project id or name. Required when the credential does not already select one project.
</ParamField>

<ResponseField name="setups" type="array">
  Zero, one, or two setup objects. There can be one setup per supported agent platform in a project.
</ResponseField>

Each setup has these fields:

| Field              | Meaning                                                   |
| ------------------ | --------------------------------------------------------- |
| `id`               | Monitoring setup id.                                      |
| `project_id`       | Project that owns the setup.                              |
| `agent_platform`   | `retell` or `livekit_agents`.                             |
| `strategy`         | `retell_api_polling` or `livekit_otlp`.                   |
| `credentials_hint` | Last four characters of the sealed Retell key, or `null`. |
| `health`           | Setup-wide health and last-received times.                |
| `agents`           | Selected Retell voice agents. Empty for LiveKit Agents.   |

`health.state` is `healthy`, `invalid_credential`, `rate_limited`, or
`provider_unavailable`. A healthy setup with `last_received_at: null` is still
waiting for its first production conversation.

Each Retell agent has its platform id and name, an import state, scan progress,
last-success and last-conversation times, and any open exact-call import
failures. Its `state` is `importing`, `active`, or `degraded`.

```bash theme={null}
curl "https://your-egma-host/api/monitoring?project=prj_abc123" \
  -H "Authorization: Bearer egma_sk_..."
```

## Discover Retell voice agents

**`POST /api/monitoring/retell/discover`**

Checks one Retell API key and returns only voice agents. This request does not
save the key.

<ParamField body="api_key" type="string" required>
  Retell platform API key with Agent Read permission.
</ParamField>

<ResponseField name="agents" type="array">
  Voice-agent choices shaped as `{ id, name }`, sorted by name.
</ResponseField>

```bash theme={null}
curl -X POST \
  "https://your-egma-host/api/monitoring/retell/discover?project=prj_abc123" \
  -H "Authorization: Bearer egma_sk_..." \
  -H "Content-Type: application/json" \
  -d '{ "api_key": "key_live_..." }'
```

## Create or update Retell Monitoring

**`PUT /api/monitoring/retell`**

Checks Agent Read and call-history access, seals the key once, and saves the
selected Retell voice agents. The key needs Retell Monitor or History Read
permission in addition to Agent Read permission.

<ParamField body="api_key" type="string" required>
  Retell platform API key. Egma never returns it after this request.
</ParamField>

<ParamField body="agents" type="object[]" required>
  At least one choice shaped as `{ id, name }`. Egma checks each id against Retell and stores Retell's current name rather than trusting a client-supplied rename.
</ParamField>

<ResponseField name="setup" type="object">
  The saved setup in the same shape returned by `GET /api/monitoring`.
</ResponseField>

A new selected agent starts a fixed 30-day import. Changing the key keeps
existing progress. Removing an agent from the selection stops its polling and
keeps its imported production conversations. Polling checks for new terminal
conversations about every 30 seconds after the first import finishes.

```bash theme={null}
curl -X PUT \
  "https://your-egma-host/api/monitoring/retell?project=prj_abc123" \
  -H "Authorization: Bearer egma_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "key_live_...",
    "agents": [{ "id": "agent_abc123", "name": "Front desk" }]
  }'
```

## Record LiveKit Agents setup

**`PUT /api/monitoring/livekit-agents`**

Creates the project setup record used to show waiting and last-received state.
The request has no body and does not configure a LiveKit worker. Install the
Egma Python SDK, add `EGMA_URL` and a project-scoped `EGMA_API_KEY` to the
worker, and call `monitor_livekit(ctx)` before `AgentSession.start`.

<ResponseField name="setup" type="object">
  A `livekit_agents` setup with `strategy: "livekit_otlp"` and no selected-agent rows.
</ResponseField>

```bash theme={null}
curl -X PUT \
  "https://your-egma-host/api/monitoring/livekit-agents?project=prj_abc123" \
  -H "Authorization: Bearer egma_sk_..."
```

See [Egma Python SDK](/integrations/python-sdk) for the worker setup.

## Retry one Retell import

**`POST /api/monitoring/retell/failures/:failureId/replay`**

Retries the exact Retell call named by one open import failure. It reads the
call directly, so it still works after that call is outside the normal 30-day
list window. The production claim prevents a successful retry from creating a
second production conversation.

<ParamField path="failureId" type="string" required>
  Failure id from a selected agent's `failures` array.
</ParamField>

<ResponseField name="failure" type="object">
  `{ id, status: "resolved" }` after a successful retry.
</ResponseField>

<ResponseField name="trace" type="object">
  `{ id, write }`, where `write` is `written` or `already`.
</ResponseField>

A retry can return `409 conflict` when another retry owns the failure or Retell
still cannot supply a complete conversation. A rate limit returns `429`; a
temporary provider failure returns `503`.

## Remove Monitoring setup

**`DELETE /api/monitoring/:platform`**

Use `retell` or `livekit-agents` for `platform`. A successful delete returns
`204 No Content` and keeps production conversations already stored.

Deleting a Retell setup stops its polling. Deleting a LiveKit Agents setup
removes Egma's setup-status record; it does not change code or secrets in a
deployed worker. Remove `monitor_livekit` or its Egma credentials in that
deployment when you also want the worker to stop exporting.

```bash theme={null}
curl -X DELETE \
  "https://your-egma-host/api/monitoring/retell?project=prj_abc123" \
  -H "Authorization: Bearer egma_sk_..."
```
