Skip to main content

Overview

Surfa provides two main APIs:
  1. Ingest API - Track events from your MCP server
  2. MCP Query API - Query analytics with natural language
Both APIs use API key authentication with Bearer tokens.

Ingest API

POST /api/v1/ingest/events

Track events from your MCP server or application. Endpoint:
Headers:
Request Body:
Field Descriptions: Event Object: Response (Success):
Response (Error):
Status Codes:

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:
Response:

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 Requests when exceeded
Rate Limit Response:
The SDK automatically retries with exponential backoff when rate limited.

MCP Query API

The MCP Query API currently has no rate limits. Use responsibly.

Error Handling

Authentication Errors (401, 403)

Don’t retry - fix your API key.

Validation Errors (422)

Don’t retry - fix your payload.

Rate Limit Errors (429)

Retry with exponential backoff.

Server Errors (500, 502, 503, 504)

Retry with exponential backoff (max 3 attempts).

SDK vs Direct API

Benefits:
  • ✅ 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
Example (JavaScript):

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