Skip to main content
Feature flags let you control feature rollout from the Grantiva dashboard without app updates. Access them via 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

Flags are cached in memory for 5 minutes by default. See Cache control to configure the TTL.

Typed accessors

Default values are returned when the flag doesn’t exist or can’t be parsed to the requested type.

Get a single flag

Environments

Flags can be scoped to different environments:
Default is .production.

Cache control

Flags are cached for 5 minutes by default. Adjust the TTL at any point after initialization:
The cache is automatically cleared when user identity changes via grantiva.identify().

Live updates (SSE)

The SDK can hold a Server-Sent Events stream open against GET /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 : keepalive comment 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.

Tier limits