Reference · 01

Monitoring & analytics.

See how a live agent is doing from your own code: daily totals of conversations or runs from the stats endpoint, the individual sessions and runs behind them, and a review by Alchemist that finds what is going wrong.

You wantUse
Volume, failures, handoffs and cost per dayGET /api/agents/{agent_id}/stats
The conversations behind the numbersSession management
The runs behind the numbers, e.g. every failed runRun management (GET .../runs?status=failed)
What is going wrong and how to fix itAsk Alchemist for a review

Agent stats

GET /api/agents/{agent_id}/stats

Returns a live agent's totals for the last 1, 7 or 30 days, and one row per day. Chat agents and jobs each get their own fields. Only live traffic is counted; test conversations and test runs are left out. Authenticate with the same Access Key as triggers.

Query parameters

NameTypeDefaultDescription
daysinteger7 The window: 1, 7 or 30. Days are UTC calendar days ending today, so days=1 is today so far.

Any other query parameters are ignored.

Agent stats · cURLshell
curl "https://webhook.olbrain.com/api/agents/agt_01HAKZ.../stats?days=7" \
  -H "Authorization: Bearer ak_<your-access-key>"

Chat agent

Response shape · chat agentJSON
{
  "agent_id": "agt_01HAKZ...",
  "kind": "chat",
  "window_days": 7,
  "since": "2026-11-05T00:00:00Z",
  "totals": {
    "conversations": 5,
    "resolved": 2,
    "handed_off": 1,
    "messages": 23,
    "failed_replies": 1,
    "tokens": 9000,
    "cost_inr": 1.43
  },
  "days": [
    {
      "day": "2026-11-05",
      "conversations": 4,
      "resolved": 2,
      "handed_off": 1,
      "messages": 20,
      "failed_replies": 1,
      "tokens": 9000,
      "cost_inr": 1.23
    }
  ]
}
FieldMeaning
conversationsConversations that started that day.
resolvedOf those, conversations that ended well: a real exchange that went quiet for 24 hours on a positive note. A conversation is judged only after it has been quiet for 24 hours, so the last day or two keep rising.
handed_offOf those, conversations the agent handed to a person.
messagesMessages the agent answered.
failed_repliesMessages the agent failed to answer (the reply's status is error).
tokensModel tokens used.
cost_inrUsage at Olbrain's rates, in rupees, rounded to the paisa.

Job

Response shape · jobJSON
{
  "agent_id": "agt_01HB2Q...",
  "kind": "job",
  "window_days": 1,
  "since": "2026-11-11T00:00:00Z",
  "totals": {
    "runs_finished": 5,
    "runs_succeeded": 4,
    "runs_failed_or_cancelled": 1,
    "items_processed": 40,
    "items_failed": 2,
    "tokens": 1200,
    "cost_inr": 3
  },
  "days": [
    {
      "day": "2026-11-11",
      "runs_finished": 5,
      "runs_succeeded": 4,
      "runs_failed_or_cancelled": 1,
      "items_processed": 40,
      "items_failed": 2,
      "tokens": 1200,
      "cost_inr": 3
    }
  ]
}
FieldMeaning
runs_finishedRuns that finished that day, whatever the result. A run counts on the day it finishes.
runs_succeededOf those, runs that completed.
runs_failed_or_cancelledOf those, runs that failed or were cancelled. Find them with GET .../runs?status=failed.
items_processedItems that went through every step.
items_failedItems that failed at a step. Fetch the run to see which step and why.
tokensModel tokens used.
cost_inrUsage at Olbrain's rates, in rupees, rounded to the paisa.

days always holds one row per day in the window, oldest first, with zeros on days without activity. Runs still going or waiting for an approval aren't counted until they finish; list them with GET .../runs?status=running or ?status=needs_review.

No push notifications yet

Olbrain doesn't call your server when a run fails. To be alerted, poll /stats or GET .../runs?status=failed on a schedule. For chat agents, Alchemist can set who is told when a conversation is handed to a person: an email address, a Slack channel or your helpdesk.

Errors

StatusCodeWhen
400 invalid_days days is not 1, 7 or 30.
400 runtime_not_applicable The agent is a research agent. Stats cover chat agents and jobs.
401 unauthorized Missing or invalid Access Key.
404 agent_not_found The agent doesn't exist or belongs to another organization.
500 internal_error The stats couldn't be read. Retry with backoff.

For the full error reference, see Errors.

Ask Alchemist for a review

In Claude Code, Codex or any client with Alchemist, ask it to review a live agent, for example “How has the support agent done this week?” Alchemist reads the last 1, 7 or 30 days of live traffic, with customer details hidden:

For a chat agent it can then turn a failure into a test, fix the agent and show the test passing before the fix goes live. It reviews only when you ask.