grantiva.flags.
Flag endpoints require authentication: run
validateAttestation() once before reading flags (the SDK then attaches the attestation JWT automatically). In the Simulator, initialize the SDK with an API key — see Simulator Setup. Requests without either receive a 401.Get all flags
Typed accessors
Get a single flag
Environments
Flags can be scoped to different environments:.production.
Cache control
Flags are cached for 5 minutes by default. Adjust the TTL at any point after initialization:grantiva.identify().
Live updates (SSE)
The SDK can hold a Server-Sent Events stream open againstGET /api/v1/flags/stream so flag changes propagate to devices in seconds instead of waiting for the cache TTL.
A few behaviors worth knowing (SDK 2.0.6+):
- The server emits a
: keepalivecomment every 20 seconds; the SDK’s idle timeout is 75 seconds (~3 missed keepalives), so dead connections are detected and reconnected without churning on healthy quiet streams. - Reconnect backoff resets after a healthy connection (60s+ uptime) drops, so devices on flaky networks don’t accumulate permanent delays.
- The stream is scoped to the current
environment.