Flag Consumer API Reference
Complete REST API documentation for Savvagent flag consumers. Includes evaluation, telemetry, analytics, and audit endpoints.
Base URLs
π Complete Documentation
For the complete, detailed API reference with all request/response examples, see the Flag Consumer API Documentation on GitHub.
Authentication
Savvagent uses two authentication methods depending on the endpoint type:
SDK API Keys
For evaluation and telemetry endpoints
Scoped to an application
JWT Tokens
For dashboard and analytics endpoints
Obtained via TOTP authentication
Core Flag Evaluation
/api/flags/:key/evaluateThe core feature flag evaluation endpoint. Evaluates a flag for a specific user context with advanced targeting, geolocation, scheduling, and rollout capabilities.
Request Body
{
"context": {
"user_id": "user-123",
"anonymous_id": "session-456",
"organization_id": "org-uuid",
"application_id": "app-uuid",
"environment": "production",
"language": "en-US",
"attributes": {
"plan": "premium",
"country": "US",
"beta_tester": true
},
"geolocation": {
"country": "US",
"city": "San Francisco",
"continent": "NA",
"timezone": "America/Los_Angeles",
"latitude": 37.7749,
"longitude": -122.4194
}
}
}Response (200 OK)
{
"key": "my-feature-flag",
"enabled": true,
"scope": "application",
"configuration": {
"theme": "dark",
"maxItems": 100
},
"variation": "treatment-a",
"timestamp": 1700000000,
"context": {
"user_id": "user-123"
}
}Evaluation Features:
- Hierarchical flag lookup (application β enterprise)
- Schedule-based activation/deactivation
- Geolocation targeting (country, city, timezone, lat/long)
- Language targeting
- Attribute-based rules evaluation
- Segment targeting
- Rollout percentage with consistent hashing
- Multi-variant support (A/B testing)
- Redis caching (<1ms target latency)
Telemetry & Event Tracking
/api/telemetry/evaluationsBatch log flag evaluation events from SDKs for analytics.
Request Body
{
"events": [
{
"flag_key": "my-feature-flag",
"result": true,
"context": { "user_id": "user-123" },
"duration_ms": 0.8,
"trace_id": "trace-abc-123",
"timestamp": "2025-01-18T12:34:56.789Z"
}
]
}/api/telemetry/errorsBatch log errors that occurred during flag evaluation or in flag-gated code.
Request Body
{
"events": [
{
"flag_key": "checkout-redesign",
"flag_enabled": true,
"error_type": "TypeError",
"error_message": "Cannot read property 'price' of undefined",
"stack_trace": "at processCheckout (checkout.js:45:12)...",
"context": { "user_id": "user-789" },
"trace_id": "trace-def-456",
"timestamp": "2025-01-18T12:40:00.000Z"
}
]
}/api/telemetry/flags/:flag_id/errorsRetrieve errors associated with a specific flag.
Query Parameters
time_range: "1h" | "24h" | "7d" (default) | "30d" | "90d"limit: Integer (default: 50)
Analytics & Reporting
/api/analytics/flagsGet aggregated analytics for all flags in the organization.
Response
[
{
"flag_id": "flag-uuid-1",
"flag_key": "new-checkout",
"flag_name": "New Checkout Flow",
"total_unique_users": 1523,
"enabled_users": 761,
"disabled_users": 762,
"actual_enabled_percentage": 49.97,
"total_evaluations": 45230,
"first_evaluation": "2025-01-10T08:00:00Z",
"last_evaluation": "2025-01-18T14:30:00Z"
}
]/api/analytics/healthCheck if flag rollout distributions match target percentages.
Returns distribution health metrics including target vs actual percentages and skew detection.
/api/analytics/geoGet geographic distribution analytics for flag evaluations.
Query Parameters
time_range: "1h" | "24h" | "7d" (default) | "30d" | "90d"
/api/analytics/languagesGet language distribution analytics for flag evaluations.
Query Parameters
time_range: "1h" | "24h" | "7d" (default) | "30d" | "90d"
Application Analytics
/api/organizations/:org_id/applications/:app_id/analyticsGet analytics for a specific application including daily trends and top flags.
Query Parameters
days: Integer (default: 7, lookback period)
/api/organizations/:org_id/applications/analyticsGet analytics summary for all applications in the organization.
Audit & History
/api/flags/:id/audit-logGet audit log for a specific flag with change history and user actions.
Query Parameters
action: Filter by action type (created, updated, deleted, etc.)start_date,end_date: Date range filterlimit: Max results (default: 100, max: 1000)offset: Pagination offset
/api/audit-logGet organization-wide audit log across all flags.
Required Query Parameters
organization_id: UUID (required)
/api/users/:id/activityGet activity summary for a specific user including action counts.
SDK Endpoints
Endpoints designed for SDK consumption with bulk flag retrieval and local override support.
/api/sdk/flagsGet all flags for the authenticated application. Returns application-scoped and enterprise-scoped flags.
Query Parameters
environment: Filter by environment (e.g., "production", "development")
Response
{
"flags": [
{
"key": "new-checkout",
"enabled": true,
"scope": "application",
"environments": {...},
"variations": [...],
"configuration": {"theme": "dark"},
"version": 5
}
],
"count": 15,
"organization_id": "org-uuid",
"application_id": "app-uuid"
}/api/sdk/enterprise-flagsGet only enterprise-scoped flags that apply across all applications in the organization.
Query Parameters
environment: Filter by environment (default: "development")
Real-Time Streaming (SSE)
Server-Sent Events endpoint for receiving real-time flag updates without polling.
/api/flags/streamSubscribe to real-time flag change notifications via Server-Sent Events.
Event Types
connected- Initial connection confirmation with contextflag_created- New flag createdflag_updated- Flag configuration changedflag_deleted- Flag removedheartbeat- Keep-alive ping (every 30s)
Event Payload
{
"type": "flag_updated",
"key": "new-checkout",
"organization_id": "org-uuid",
"application_id": "app-uuid",
"environments": {"production": true},
"version": 6
}Tenant Isolation: SDK key auth receives only notifications for the specific application. JWT auth (admin UI) receives all notifications for the organization.
Segments (Audience Targeting)
Create and manage reusable audience segments for advanced flag targeting.
/api/segmentsCreate a new user segment with attribute-based rules.
Request Body
{
"key": "premium-users",
"name": "Premium Users",
"description": "Users with premium or enterprise plans",
"rules": {
"operator": "or",
"rules": [
{
"attribute": "plan",
"operator": "in",
"values": ["premium", "enterprise"]
}
]
}
}/api/segments List all segments/api/segments/:id Get segment details/api/segments/:id Update segment/api/segments/:id Delete segment/api/segments/:id/evaluateEvaluate if a user context matches a segment's rules.
Request Body
{
"user_id": "user-123",
"attributes": {
"plan": "premium",
"country": "US"
}
}Response
{
"matches": true,
"segment_key": "premium-users"
}AI-Powered Features
AI-powered endpoints for error correlation analysis and intelligent insights.
/api/ai/healthCheck AI service availability and status.
/api/ai/flags/:org_id/:flag_id/correlationAnalyze error correlation for a specific flag using AI to detect patterns.
Request Body
{
"flag_id": "flag-uuid",
"time_window_hours": 24
}Response
{
"flag_id": "flag-uuid",
"flag_key": "new-checkout",
"analysis": {
"correlation_score": 0.85,
"error_types": ["TypeError", "NetworkError"],
"recommendation": "High correlation detected...",
"confidence": "high"
},
"timestamp": "2025-01-18T12:00:00Z"
}/api/ai/flags/:org_id/:flag_id/insightsGet AI-generated insights and recommendations for a flag.
Support Chat
AI-powered support chat for instant assistance with flag management and platform questions.
/api/support/conversationsStart a new support conversation with AI assistance.
Request Body
{
"initial_message": "How do I set up percentage rollouts?"
}/api/support/conversations/:conversation_id/messagesSend a message in an existing conversation.
Request Body
{
"content": "Can you show me an example?"
}/api/support/conversations List user's conversations/api/support/conversations/:id Get conversation with messages/api/support/tickets Create support ticket/api/support/tickets List support ticketsError Codes & Rate Limiting
HTTP Status Codes
| Code | Description |
|---|---|
200 | OK - Request successful |
201 | Created - Resource created successfully |
400 | Bad Request - Invalid parameters |
401 | Unauthorized - Missing or invalid authentication |
403 | Forbidden - Insufficient permissions |
404 | Not Found - Resource doesn't exist |
409 | Conflict - Resource conflict (e.g., duplicate key) |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error - Something went wrong |
Rate Limits
API requests are rate-limited to ensure fair usage:
- Evaluation endpoint: 10,000 requests/minute per SDK key
- Telemetry endpoints: 1,000 requests/minute per organization
- Analytics endpoints: 100 requests/minute per user
Need More Details?
For complete request/response examples, evaluation logic details, and SDK integration guides, see the complete Flag Consumer API documentation.