Public API
The Feato Public API allows backend services, workers, and automation systems to interact with feature flags without using a framework-specific SDK.
It provides a stable HTTP interface for retrieving feature flag state and integrating feature gating into server-side workflows.
Authentication
All API requests are authenticated using a project key.
The project key identifies both the project and the environment for which feature flags are evaluated.
Base URL
All Public API requests are made against the Feato hub service.
https://hub.feato.ioFetching feature flags
Use the /v1/feature-flag endpoint to retrieve the current feature flag state for a project and environment.
# v1/feature-flag
# Note: secret and environment depend on your Feato project.
curl -X GET \
'https://hub.feato.io/v1/feature-flag?secret=YOUR_PROJECT_KEY&environment=prod' \
-H 'Accept: application/json'The response contains the evaluated feature flags for the requested environment.
export interface GetFlagsResponseModel {
environment: 'prod' | 'stage' | 'dev' | 'qa' | 'preview';
flags: Record<string, boolean>;
}Example usage in TypeScript:
const API_URL = 'https://hub.feato.io';
export async function getFlags(
secret: string,
environment: string
): Promise<GetFlagsResponseModel> {
const url = new URL('/v1/feature-flag', API_URL);
url.searchParams.set('secret', secret);
url.searchParams.set('environment', environment);
const res = await fetch(url, {
method: 'GET',
headers: { Accept: 'application/json' },
});
if (!res.ok) {
throw new Error('getFlags failed: ' + res.status);
}
return (await res.json()) as GetFlagsResponseModel;
}Real-time event stream
In addition to HTTP requests, Feato exposes a Server-Sent Events (SSE) endpoint that streams feature flag updates as they occur.
This endpoint is intended for environments that can maintain a long-lived connection.
export interface FeatoSseEventModel {
key: string;
value: boolean;
updatedAt: Date;
}const API_URL = 'https://hub.feato.io';
export function connectToFeatoSse(
secret: string,
environment: string
) {
const url = new URL('/v1/hub', API_URL);
url.searchParams.set('secret', secret);
url.searchParams.set('environment', environment);
const es = new EventSource(url.toString());
es.onmessage = (event) => {
const message = JSON.parse(event.data) as FeatoSseEventModel;
console.log('SSE message:', message);
};
es.onerror = (err) => {
console.error('SSE error:', err);
};
return () => es.close();
}If no feature flags change, no events are sent. The stream delivers only updates, not periodic snapshots.
Error handling
The Public API uses standard HTTP status codes to indicate request outcomes.
- 4xx responses indicate client-side errors
- 5xx responses indicate server-side errors
- Unauthorized or malformed requests are rejected
Applications should handle API failures gracefully and avoid blocking critical paths on feature flag evaluation.
Common use cases
- Backend feature gating
- CI/CD automation
- Background workers and scheduled jobs
- Infrastructure-level checks