Overview
Unlike the/runs endpoints which are hierarchical (Run → Actions), the ledger provides a flat, chronological stream of all actions with advanced filtering and search capabilities.
Key Use Cases
- Compliance Audits: “Show me all high-risk actions in Q4 2024”
- Debugging: “Find all failed
database_queryactions” - Cost Analysis: “What are my most expensive actions?”
- Security: “Show all actions by
prod-agent-3that were blocked” - Organizational Memory: “What did our agents do last week?”
Endpoints
GET /api/v1/ledger
Query the activity ledger with filtering, sorting, and pagination.Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer | 0 | Page number (0-indexed) |
page_size | integer | 100 | Items per page (max 1000) |
outcome | string | null | Filter by outcome: success, error, blocked |
action_name | string | null | Filter by exact action name |
agent_id | string | null | Filter by agent identifier |
run_id | UUID | null | Filter by parent run |
min_cost | float | null | Minimum cost in USD |
max_cost | float | null | Maximum cost in USD |
start_date | ISO 8601 | null | Filter actions after this date |
end_date | ISO 8601 | null | Filter actions before this date |
search | string | null | Search across action names, agent IDs, outcomes |
sort_by | enum | timestamp | Sort field: timestamp, cost, duration, name |
sort_order | enum | desc | Sort direction: asc, desc |
Response
Example: Find Failed Actions
Example: Search Actions
Example: Date Range Query
GET /api/v1/ledger/stats
Get aggregate statistics for the activity ledger.Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
start_date | ISO 8601 | null | Start date for stats calculation |
end_date | ISO 8601 | null | End date for stats calculation |
agent_id | string | null | Calculate stats for specific agent |
Response
Example: Monthly Stats
GET /api/v1/ledger/export
Export ledger data for compliance audits and offline analysis.Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
format | enum | jsonl | Export format: jsonl, json, csv |
outcome | string | null | Filter by outcome |
action_name | string | null | Filter by action name |
agent_id | string | null | Filter by agent |
start_date | ISO 8601 | null | Date range start |
end_date | ISO 8601 | null | Date range end |
limit | integer | 10000 | Maximum records (max 100,000) |
Response
File download in requested format.Example: Export as JSONL
Example: Export Failed Actions as CSV
Response Schema
LedgerEntry
ComplianceMetadata (Enterprise Tier)
Common Patterns
1. Debugging Failed Actions
2. Cost Analysis by Agent
3. Compliance Audit Export
4. Real-Time Monitoring
Authentication
All ledger endpoints require authentication via:-
JWT Bearer Token
-
API Key (recommended for programmatic access)
Access Control
- Users can only see actions from their own runs
- Superusers can see all actions across all users
- Organization admins can see actions from their organization’s runs
Rate Limits
- Query Endpoints: 1000 requests/hour
- Export Endpoint: 100 requests/hour
- Stats Endpoint: 600 requests/hour
Differences from /runs Endpoints
| Feature | /runs | /ledger |
|---|---|---|
| Structure | Hierarchical (Run → Actions) | Flat (all actions) |
| Scope | Single run at a time | All runs combined |
| Filtering | By run properties | By action properties |
| Use Case | Inspect specific run | Audit trail, search |
| Sorting | Actions within run | Cross-run sorting |
/runs:
- Inspecting a specific run’s execution flow
- Debugging a single agent workflow
- Viewing run-level metadata
/ledger:
- Compliance audits across all activity
- Finding patterns across multiple runs
- Cost analysis by action type
- Security monitoring
Best Practices
1. Use Pagination for Large Results
2. Use Search for Flexible Queries
3. Filter by Date Range for Performance
4. Use Stats Endpoint for Aggregates
Troubleshooting
Empty Results
Problem: Query returns 0 results Solutions:- Check filters - they may be too restrictive
- Verify date range includes expected data
- Ensure authentication is correct (not seeing another user’s data)
- Check that agents have actually executed actions
Slow Queries
Problem: Queries take >5 seconds Solutions:- Reduce page size (100 instead of 1000)
- Add date range filters to limit data scanned
- Avoid search queries on large datasets
- Use stats endpoint for aggregates instead of fetching all data
Export Limits
Problem: “Export limit exceeded” error Solutions:- Reduce date range or add more filters
- Export in batches using pagination
- Contact support for bulk export access
Related Documentation
- Runs API - Hierarchical run/action queries
- Ingest API - How SDK sends action data
- Authentication - API keys and JWT tokens
- Compliance Guide - Enterprise compliance features
