Frontend API overview

View as Markdown

The Frontend API is designed for frontend SDKs running in browsers, mobile apps, and other client-side environments. Unlike the Client API, it only returns enabled feature flags for a specific Unleash Context, providing security and performance benefits.

Base path: <your-unleash-url>/api/frontend

Primary use: Fetch enabled flags for a specific user context without exposing your entire flag configuration. Frontend SDKs handle registration, polling, and metrics automatically.

Key differences from Client API

AspectClient APIFrontend API
PayloadAll feature flags and strategies.Only enabled feature flags for the provided context.
EvaluationServer-side by SDK.Evaluated by the Unleash server or Unleash Enterprise Edge.
Token typeBackend tokens.Frontend tokens.

Authentication

Use frontend tokens for authentication. These tokens can be scoped to specific projects and environments and are safe to embed in client-side code.

To create a frontend token, go to Admin settings > Access control > API access > New API token.

Available endpoints

EndpointMethodDescription
/api/frontendGETFetch enabled feature flags (using query params).
/api/frontendPOSTFetch enabled feature flags (using request body).
/api/frontend/client/metricsPOSTReport usage metrics.
/api/frontend/client/registerPOSTRegister SDK instance.

Unleash Context

Each request requires an Unleash Context to evaluate flags. For example, include fields like userId, sessionId, and custom properties for targeting:

1{
2 "userId": "user-123",
3 "properties": {
4 "region": "us-east",
5 "plan": "premium"
6 }
7}

Learn more about context fields and constraints.

Using with Unleash Edge

For production applications, use Unleash Edge to improve performance, privacy, and reduce latency. Edge caches evaluations closer to your users and provides built-in fallback mechanisms.

Point your SDK to your Edge instance instead of directly to Unleash:

1const config = {
2 url: 'https://your-edge-instance.com/api/frontend',
3 clientKey: 'YOUR_FRONTEND_TOKEN',
4};