Skip to main content
A feature flag is a named, typed value. You read it and decide what to do with it.

How reads work

Reading a flag serves the configuration from memory when it was fetched within the cache window, and goes to the API otherwise — so a read is usually free, and never more than one request per window no matter how often you call it.
The SDK does not poll in the background. The refresh happens on the read that finds the cache stale, and concurrent reads on a cold cache collapse onto a single request.
Configure the window when you construct the client:
If a refresh fails while a previous configuration is held, that configuration is returned rather than throwing — an API blip must never change the values a running server reads. The cache window restarts in that case too, so an outage costs one request per window instead of one per read.

Reading values

Typed readers

Each reader checks the flag’s declared type as well as its value, so asking for a number and getting a string is impossible.
Without a fallback the return type is T | undefined; with one it is T.
A flag that does not exist — or that holds a different type than you asked for, or that this runtime may not read — reads as the fallback, or undefined when you did not pass one. Archiving or deleting a flag in the dashboard can never throw on a running server.

isEnabled

The shorthand for boolean flags. Defaults to false rather than undefined.

Raw and bulk reads

Runtimes

Reads are made on behalf of a runtime, and default to shared. A server flag is invisible to a shared read — it behaves exactly like a flag that does not exist — so a value you are about to send to a player can never be a server-only one by accident.
The runtime goes in the options object, which is always the last argument — after the fallback. Pass undefined as the fallback when you want a runtime but no fallback.

Configuration control

Returns the flag configuration, from memory when it is still within the cache window and from the API otherwise. This is what every read calls under the hood.
Returns
  • Promise<FlagConfigPayload>
Throws
  • NoCloudAPIError — only if the request fails and no configuration is held yet. When one is held, it is returned instead.
Fetches the configuration from the API, ignoring the cache window. Unlike getConfig this always surfaces a failure, so it is the right call when you want to know whether the API is reachable.
Returns
  • Promise<FlagConfigPayload>
Throws
  • NoCloudAPIError — if the API request fails.
Returns the configuration currently held in memory without contacting the API. Synchronous.
Returns
  • FlagConfigPayload | null
Discards the cached configuration so the next read goes back to the API.
The management methods (create, update, delete) call this for you, so a read straight after a write never serves the value you just replaced.

Driving your own refresh loop

pollIntervalSeconds on the payload is what the API advises. The SDK does not act on it, so use it if you want a loop of your own:

Managing flags

These methods hit the management endpoints directly and require FLAGS_WRITE (except list, get, getQuota and getAuditLog, which need only FLAGS_READ).
Lists the organization’s flags.
Parameters
  • options: ListFlagsOptionspage, limit, search, includeArchived (all optional)
Returns
  • Promise<FeatureFlagListResponse> — a page of flags plus your flag allowance
Creates a flag. The type and value are paired in TypeScript, so the compiler rejects a number flag holding a string.
Returns
  • Promise<FeatureFlag>
Throws
  • NoCloudAPIError — including when the organization is at its flag allowance, or the key is already taken.
Fetches a single flag by its ID.
To read a flag’s value by key, use getValue and the typed readers — they serve from the cached configuration instead of making a request per flag.
Returns
  • Promise<FeatureFlag>
Renames, archives, or sets a flag’s value.
Changing the value means passing its type alongside it. Keys are immutable and cannot be updated.
Returns
  • Promise<FeatureFlag>
Throws
  • NoCloudAPIError — including when the flag is locked by the organization’s allowance.
Permanently deletes a flag.
Returns
  • Promise<void>
Fetches the organization’s flag allowance.
Returns
  • Promise<FeatureFlagQuota>max, used, subscribed, locked
Fetches the flag audit log — who changed what, and when.
Returns
  • Promise<PaginatedResult<FeatureFlagAuditEntry>> — newest first

Types

Next Steps

Feature Flags

Types, runtimes, limits and the audit log

Error Handling

Handle NoCloudAPIError gracefully

API Reference

The REST endpoints behind this module