Remote config
Contents
Boolean and multivariate flags are helpful for dynamic values that differ from user to user, but sometimes you need a simple way to pass configuration related to your application without having to make code changes or redeploy your app.
Remote config flags enable you to configure a simple flag that always returns the same payload wherever it is called. Remote config flags can also be stored as encrypted values and decrypted on the server side when requested. Encryption/decryption is handled automatically.
You can think of remote config flags as multivariate flags with a single variant which is served for all flag requests. By default, enabled remote config flags roll out to 100% of all users.
Using remote config in client-side apps
Non-encrypted remote config flags are served through the /flags endpoint like any other feature flag, using your project API key (the one starting with phc_), which is safe to expose publicly. Read the payload with your SDK's flag payload function. For example, in posthog-js:
This also works for CLIs, scripts, or anything else that can call /flags with your project API key.
Note: Flags with encrypted payloads are excluded from
/flagsentirely, so they can't be read client-side and require a server.
Using remote config on the server
Server-side SDKs fetch remote config payloads using your feature flags secure API key. This key is only required for local evaluation and encrypted payloads – not for remote config in general. Unlike your project API key, it must never be exposed publicly.
There are 3 steps to use remote config flags on the server:
Step 1: Find your feature flags secure API key
The feature flags secure API key is a secret project specific token listed in the Feature Flags tab of your project settings in the "Feature Flags Secure API Key" section. It provides the SDKs with access to the feature flag definitions for your project so they can evaluate flags locally.
This key needs to be kept secret, and should not be used in the frontend or exposed to users.
Note: Existing personal API keys will continue to work for local evaluation, but we recommend switching to the feature flags secure API key for local evaluation moving forward. We will be deprecating personal API keys for local evaluation in the future.
How to obtain a feature flags secure API key
The key should be displayed in the "Feature Flags Secure API Key" section.
Copy the key and use it to initialize the PostHog client.
Step 2: Initialize PostHog with your feature flags secure API key in options
Note: By default, initializing PostHog with your feature flags secure API key enables local evaluation, but this can be disabled in
posthog-nodeby settingenableLocalEvaluation: falsein your config.
Step 3: Use remote config flags
Note: Remote config flags are meant to always serve payloads and be called with the flag payload function in each SDK. If
getFeatureFlagis called instead, the SDK simply returnstrue
Encrypted payloads
Encrypted payloads are only available server-side, through the authenticated remote config API. Authenticate with a personal API key to receive the decrypted payload – the feature flags secure API key returns encrypted payloads redacted.