Documentation Index
Fetch the complete documentation index at: https://omniflagsdoc.omniretail.app/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Setup
Register OmniFlags inProgram.cs. The SDK key is the only thing you configure locally. Polling intervals and CDN settings come down with the snapshot.
appsettings.json. Use environment-specific overrides (appsettings.Production.json) or secret management to keep production keys out of source control.
AddOmniFlags registers:
OmniFlagsClientas a singleton in the DI container- A hosted service that fetches the initial snapshot at startup, before the application begins accepting traffic
OmniFlagsClient is ready to evaluate.
Evaluating flags
InjectOmniFlagsClient into services, controllers, or minimal API endpoints. The client is thread-safe and designed to be shared as a singleton.
In a service class
In a minimal API endpoint
Client API
IsEnabled — boolean flags
bool. The defaultValue is returned if the flag is not found, is disabled, or the client is not yet ready.
GetString — string flags
GetNumber — number flags
Detail variants
Every typed method has a*Detail variant that returns the full EvaluationResult<T>. Use it when you need to inspect why a value was returned; useful for logging, analytics, or debugging evaluation logic.
| Field | Type | Description |
|---|---|---|
Value | T | The resolved flag value |
Variant | string? | The matched variant key, or null for boolean rollouts |
Reason | EvaluationReason | Why this value was returned; see reason codes |
RuleId | string? | The ID of the targeting rule that matched, if any |
ErrorCode | ErrorCode? | Set when Reason is Error |
Evaluation context
Construct anEvaluationContext with the user and session attributes available at the call site. All properties are optional. Include only what’s relevant to your targeting rules.
| Property | Type | Notes |
|---|---|---|
CustomerId | long? | Primary bucketing key for rollout and traffic splits |
AgentId | long? | Secondary bucketing key; used when CustomerId is absent |
BusinessId | long? | Tertiary bucketing key |
BusinessBranchId | long? | |
Country | string? | Full country name (e.g. "Nigeria", "Ghana") |
City | string? | |
Platform | string? | web, ios, android, api, etc. |
AppVersion | string? | Semver string |
ctx["user.plan"] = "enterprise").
Startup behaviour
AddOmniFlags registers a hosted service that fetches the initial snapshot during IHostedService.StartAsync, before the application begins serving traffic. This means:
- Flags are always ready on the first request. No warm-up period, no stale defaults on startup.
- Startup failure does not block the application. If the CDN is unreachable at startup, the hosted service logs the error and the client falls back to an empty snapshot. The application starts, and evaluation returns caller-supplied defaults until the next successful poll.
Shutdown
OmniFlagsClient implements IAsyncDisposable. The DI container disposes the singleton as part of the host shutdown sequence. No manual teardown is required.