Traces API
API Reference
Traces API
Audit trail and debugging for all agent operations
GET
Traces API
Traces API
Traces provide a complete audit trail of every operation in StateBase. Use traces for debugging, compliance, analytics, and understanding agent behavior.What Gets Traced?
Every API operation creates a trace:List Traces
GET /v1/traces
Lists all traces with optional filtering.
Query Parameters
Response
Trace Object
Example
Get Trace
GET /v1/traces/{trace_id}
Retrieves a specific trace by ID.
Path Parameters
Example
Trace Actions Reference
Session Actions
State Actions
Turn Actions
Memory Actions
Common Use Cases
1. Debugging Production Issues
2. Audit Trail for Compliance
3. Performance Monitoring
4. Root Cause Analysis
5. Rollback Frequency Analysis
Filtering by Time Range
Get traces within a specific time window:Exporting Traces
Export traces for external analysis:Best Practices
✅ Do This
- Use traces for debugging (not just logging)
- Set up alerts on critical actions (rollbacks, errors)
- Export traces for long-term storage (compliance)
- Filter by time range (don’t fetch everything)
- Include reasoning in all operations (shows up in traces)
❌ Avoid This
- Don’t ignore rollback patterns (they indicate issues)
- Don’t fetch traces without filters (use pagination)
- Don’t store sensitive data in trace details
- Don’t delete traces (they’re your audit trail)
Retention Policy
Recommendation: Export critical traces for long-term storage.
Webhooks
Subscribe to trace events in real-time:
Configure in Dashboard → Webhooks.
Error Responses
Next Steps
- Sessions API: Manage sessions
- Turns API: Log conversations
- Replay & Audit: Debugging strategies
Key Takeaway: Traces are your black box recorder. When things go wrong, traces tell you exactly what happened and why.