Overview
Surfa provides two main APIs:- Ingest API - Track events from your MCP server
- MCP Query API - Query analytics with natural language
Ingest API
POST /api/v1/ingest/events
Track events from your MCP server or application. Endpoint:
Event Object:
Response (Success):
Example Requests
Track a Tool Call
Track Multiple Events
Track with Runtime Info
Event Types
Tool Events
Track MCP tool calls:Session Events
Track session lifecycle:Error Events
Track errors:Custom Events
Track anything:MCP Query API
Used by the Surfa MCP Server to query analytics. You typically don’t call these directly - use the MCP server instead.GET /api/v1/mcp/analytics/metrics
Get high-level analytics metrics. Headers:GET /api/v1/mcp/analytics/events
Query events with filters. Query Parameters:
Response:
GET /api/v1/mcp/analytics/sessions/:sessionId
Get all events for a specific session. Response:Rate Limits
Ingest API
The Ingest API has rate limiting to prevent abuse:- Limit: 1,000 events per minute per API key
- Window: 60 seconds (sliding window)
- Response:
429 Too Many Requestswhen exceeded
MCP Query API
The MCP Query API currently has no rate limits. Use responsibly.Error Handling
Authentication Errors (401, 403)
Validation Errors (422)
Rate Limit Errors (429)
Server Errors (500, 502, 503, 504)
SDK vs Direct API
Using the SDK (Recommended)
- ✅ Automatic retries
- ✅ Buffering and batching
- ✅ Session management
- ✅ Error handling
- ✅ Runtime metadata
Direct API Calls
Use direct API calls if:- You’re not using Python
- You need custom behavior
- You’re building your own SDK
Next Steps
Authentication
Get your API key and set up authentication
Quickstart
Start tracking events in 5 minutes
SDK Reference
Explore the Python SDK
Privacy & PII
Learn what data Surfa tracks