OpenFeature and OFREP
Evaluate Toggld flags from any language with an OpenFeature OFREP provider.
OpenFeature is a vendor-neutral standard API for feature flags. Its Remote Evaluation Protocol (OFREP) defines an HTTP API for flag evaluation. Toggld's evaluation API implements OFREP, so OFREP clients from the OpenFeature project can read Toggld flags.
Toggld ships an SDK for Node.js only. For other languages, use an OFREP provider with the OpenFeature SDK for that language.
Toggld does not maintain these providers
The OpenFeature project and its contributors publish the OFREP providers. Toggld does not build, test, or support them. Check each provider's documentation for its options and behavior.
What you need
| Setting | Value |
|---|---|
| Base URL | https://api.toggld.io |
| Single evaluation | POST /ofrep/v1/evaluate/flags/{key} |
| Bulk evaluation | POST /ofrep/v1/evaluate/flags |
| Authentication | The header Authorization: Bearer <token> on every request |
| Server-side token | A server SDK key (ffk_) |
| Client-side token | A public token (ffp_) |
The token selects the workspace and the environment. You do not send the environment in the request. See API keys.
Toggld serves only these two OFREP endpoints.
Find a provider
The OpenFeature ecosystem page lists the available OFREP providers. Filter it by "OFREP". It lists providers for several languages, such as JavaScript, Go, Python, Java, and .NET.
Every provider needs two things from you:
- The base URL
https://api.toggld.io. The provider adds the/ofrep/v1/...paths. - The
Authorizationheader with the valueBearerfollowed by your token. Toggld rejects requests without it with HTTP 401.
Example: JavaScript
This example uses the OpenFeature project's server-side OFREP provider, @openfeature/ofrep-provider, with the OpenFeature Node.js SDK.
npm install @openfeature/server-sdk @openfeature/ofrep-providerimport { OpenFeature } from "@openfeature/server-sdk";
import { OFREPProvider } from "@openfeature/ofrep-provider";
await OpenFeature.setProviderAndWait(
new OFREPProvider({
baseUrl: "https://api.toggld.io",
headers: { Authorization: `Bearer ${process.env.TOGGLD_SDK_KEY}` },
}),
);
const client = OpenFeature.getClient();
const enabled = await client.getBooleanValue("new-checkout", false, { targetingKey: "user-123" });TOGGLD_SDK_KEY=ffk_YOUR_SECRET_KEYFor browsers, the OpenFeature project publishes @openfeature/ofrep-web-provider, which uses the OpenFeature Web SDK. Give it a public token, never a secret key:
import { OpenFeature } from "@openfeature/web-sdk";
import { OFREPWebProvider } from "@openfeature/ofrep-web-provider";
OpenFeature.setProvider(
new OFREPWebProvider({
baseUrl: "https://api.toggld.io",
headers: { Authorization: "Bearer ffp_YOUR_PUBLIC_TOKEN" },
}),
);Read the provider documentation for options such as polling and caching. These packages and their options belong to the OpenFeature project and can change.
What Toggld returns
Toggld's OFREP responses follow the OFREP specification:
- A successful single evaluation returns HTTP 200 with
key,value,reason, and, when present,variantandmetadata. - An unknown flag returns HTTP 404 with
{ "key", "errorCode": "FLAG_NOT_FOUND" }. - A failed evaluation returns HTTP 400 with
{ "key", "errorCode", "errorDetails" }. A request body that is not valid JSON getsPARSE_ERROR, and a body with the wrong shape getsINVALID_CONTEXT. For bulk evaluation, these two errors have nokey. - A bulk evaluation returns HTTP 200 with
{ "flags": [...] }. Each entry is a success or a per-flag failure.
Reasons and error codes use the OpenFeature types. See Errors and the API reference.
The Node.js SDK and OpenFeature
@toggld/node follows OpenFeature semantics: it returns evaluation details with the standard reasons and error codes, and it never throws on evaluation. It is a standalone client, not a provider for the OpenFeature SDK. To use the OpenFeature Node.js SDK instead, use an OFREP provider as shown above. That provider evaluates remotely. Local evaluation is available only through @toggld/node.