Skip to content

API Reference

AgentLens exposes a REST API built with Hono. The server runs on port 3400 by default.

Base URL

http://localhost:3400/api

Authentication

All endpoints (except /api/health) require an API key passed via the Authorization header:

Authorization: Bearer als_your_api_key_here

API keys are created via POST /api/keys. The raw key is shown only once — the server stores a SHA-256 hash.

When AUTH_DISABLED=true is set (development mode), authentication is skipped.

Common Patterns

Pagination

List endpoints support offset-based pagination:

ParameterTypeDefaultMaxDescription
limitnumber50500Results per page
offsetnumber0Number of results to skip

Responses include:

json
{
  "total": 1234,
  "hasMore": true
}

Filtering

Most list endpoints support filtering via query parameters. Multiple values can be comma-separated:

GET /api/events?eventType=tool_call,tool_error&severity=error,critical

Date Ranges

Time-based filters use ISO 8601 strings:

GET /api/events?from=2026-02-01T00:00:00Z&to=2026-02-08T23:59:59Z

Error Responses

All errors follow this format:

json
{
  "error": "Human-readable error message",
  "status": 400,
  "details": [
    { "path": "payload.toolName", "message": "Required" }
  ]
}

Endpoint Overview

MethodPathDescription
GET/api/healthHealth check (no auth)
POST/api/eventsIngest events (batch)
GET/api/eventsQuery events
GET/api/events/:idGet single event
GET/api/sessionsList sessions
GET/api/sessions/:idGet session detail
GET/api/sessions/:id/timelineGet session timeline with chain verification
GET/api/analyticsBucketed metrics over time
GET/api/analytics/costsCost breakdown
GET/api/analytics/agentsPer-agent metrics
GET/api/analytics/toolsTool usage statistics
POST/api/alerts/rulesCreate alert rule
GET/api/alerts/rulesList alert rules
GET/api/alerts/rules/:idGet alert rule
PUT/api/alerts/rules/:idUpdate alert rule
DELETE/api/alerts/rules/:idDelete alert rule
GET/api/alerts/historyList alert history
POST/api/events/ingestWebhook ingestion (AgentGate/FormBridge/generic)
POST/api/keysCreate API key
GET/api/keysList API keys
DELETE/api/keys/:idRevoke API key
GET/api/agentsList agents
GET/api/agents/:idGet agent detail
GET/api/statsStorage statistics
GET/api/recallSemantic search over agent memory
POST/api/lessonsCreate a lesson
GET/api/lessonsList lessons
GET/api/lessons/:idGet single lesson
PUT/api/lessons/:idUpdate a lesson
DELETE/api/lessons/:idDelete (archive) a lesson
GET/api/reflectPattern analysis (errors, costs, tools, performance)
GET/api/contextCross-session context retrieval
GET/api/agents/:id/healthAgent health score with dimensions
GET/api/health/overviewHealth overview for all agents
GET/api/health/historyHistorical health snapshots
GET/api/config/health-weightsCurrent health scoring weights
PUT/api/config/health-weightsUpdate health weights (501 placeholder)
GET/api/optimize/recommendationsCost optimization recommendations
GET/api/sessions/:id/replaySession replay with context reconstruction
POST/api/benchmarksCreate a benchmark
GET/api/benchmarksList benchmarks
GET/api/benchmarks/:idGet benchmark detail
PUT/api/benchmarks/:id/statusTransition benchmark status
GET/api/benchmarks/:id/resultsGet benchmark comparison results
DELETE/api/benchmarks/:idDelete a benchmark
POST/api/guardrailsCreate guardrail rule
GET/api/guardrailsList guardrail rules
GET/api/guardrails/:idGet guardrail rule
PUT/api/guardrails/:idUpdate guardrail rule
DELETE/api/guardrails/:idDelete guardrail rule
GET/api/guardrails/:id/statusGet rule status + recent triggers
GET/api/guardrails/historyList trigger history
GET/api/configGet configuration
PUT/api/configUpdate configuration

Detailed documentation for each group: Events · Sessions · Analytics · Recall · Lessons · Reflect · Context · Alerts · Health · Optimize · Replay · Benchmarks · Guardrails · Integrations · API Keys

Released under the MIT License.