Feature flags quickstart
Mocco's feature flags work with OpenFeature, so your code calls the standard OpenFeature API and Mocco is the provider behind it. Your server downloads its environment's rules and evaluates every flag in memory: an evaluation never waits on the network, and the server keeps using the last rules it received if Mocco can't be reached.
1. Turn on feature flags
A workspace member turns on Feature flags on the workspace's Products page. The project then shows a Feature flags page.
Start fresh rollout assignments
Changing the grouping attribute can move people between variants. To reassign without changing percentages, click Prepare reassignment in the environment editor. People may receive a different variant. Use the preview with representative contexts, enter the required reason and save. A protected environment waits for approval. Preparing or cancelling alone changes nothing; the same prepared assignment is used in preview and approval. Ordinary edits preserve it.
Reassignment also works for flags managed by .mocco/flags.yml. Keep grouping in bucket_by beside the file’s rollout (or inside a rule’s serve); assignment seeds stay out of the file. When using MCP, prepare one fresh salt in a rerandomize_salt operation and reuse it for preview and confirmation with a nonblank reason.
2. Create environments and a flag
On the Feature flags page, create an environment for each place your code runs, for example staging and production. An environment is just a separate set of rules: its name means nothing special to Mocco.
Then create a flag, for example new-checkout. A flag is boolean by default; choose string, number or json to give it named variants instead, such as { "short": "Pay", "long": "Pay securely" }. A new flag is added to every environment switched off, so your code keeps using its own default until you switch the flag on. Each change applies at once and is recorded in the environment's history, with who changed what.

3. Target users
Open a flag to decide who gets which variant, per environment:
Rules are tried in order, and the first rule whose conditions all match serves its variant. A condition compares an attribute of the evaluation context your code passes (
plan is one of pro, enterprise,appVersion version ≥ 2.1.0,email ends with @acme.com) or checks membership of a segment.Segments are named groups for an environment, defined on the Feature flags page: targeting keys that are always in or never in, plus attribute conditions.
When no rule matches, the flag serves a variant or a percentage rollout. Rollouts group on the context’s
targetingKeyby default. Set Grouping attribute to a stable identifier such asorganization.idto keep everyone in an organization on the same variant. Keep this value and its type stable. A missing or null grouping value skips a rollout rule so later rules can match; a missing fallthrough grouping value serves the default variant. With unchanged grouping and assignments, raising a share from 10% to 20% only adds users.
Preview evaluates your unsaved changes for any context before you save, with the same evaluator the SDKs use.

4. Protect an environment
On the Feature flags page, pick an environment and choose Edit protection. Choose the role whose members approve changes, how many approvals are needed, and whether the person who proposed a change may approve it. A role is defined on the workspace's Access page.
Once an environment is protected, saving a change sends it for approval instead of applying it:
The change waits in the environment's history with its diff, the reason, and the protection it needs. People with the role get a notification if a workspace notification rule includes flag changes (the Mocco preset does).
An approver approves or rejects it right there. An approval is tied to the exact change on screen, so a change that was replaced in the meantime can't be approved by mistake.
When enough people approve, the change applies. If someone else changed the environment first, it is marked conflicted and nothing is applied; the person who proposed it can rebase it onto the current version, which sends it for approval again.
The proposer can withdraw a waiting change. A change nobody decides on within 7 days expires.
Changing or removing an environment's protection is itself approved under its current protection. A change that is already waiting keeps the protection it was proposed under.

5. Kill a flag in an emergency
If a flag causes trouble, open it, enter a reason in Kill switch and choose Kill. Everyone in that environment gets the flag's off variant at once, whatever its rules say. That includes SDKs and flagd clients that don't know about Mocco: the served rules themselves say "off".
A kill never waits for approval, even in a protected environment, and is always recorded with who did it and why. In a protected environment, the kill is then up for review by the environment's approvers, who mark it reviewed or flag a problem. The off variant is set on the flag's page; changing it, and restoring a killed flag, are normal changes, so they need approval in a protected environment. On the Feature flags page, Edit protection also sets which roles may kill flags in that environment (by default, any workspace member).

6. Create a server key for one environment
On the project's API keys page, create a Secret key with the flags:read scope and choose the environment it reads. A key reads exactly one environment, so create one key per environment and give each server the key for its own environment. Copy the key from the notice; it is shown only once.

Keep this key on the server. Mocco refuses secret keys sent from a browser, because the rules can hold user lists and other details your users shouldn't see.
7. Evaluate flags from Node
Install OpenFeature's server SDK and the Mocco provider:
npm install @openfeature/server-sdk @mocco/openfeature-serverRegister the provider once when your server starts, then ask for flags anywhere:
import { MoccoProvider } from '@mocco/openfeature-server';
import { OpenFeature } from '@openfeature/server-sdk';
await OpenFeature.setProviderAndWait(new MoccoProvider({ secretKey: process.env.MOCCO_FLAGS_KEY! }));
const flags = OpenFeature.getClient();
if (await flags.getBooleanValue('new-checkout', false, { targetingKey: user.id, plan: user.plan })) {
// the new checkout
}The provider listens to Mocco's change stream, so when you switch a flag in the console, servers pick it up within a second or two, and OpenFeature emits PROVIDER_CONFIGURATION_CHANGED with the flags that changed. It also checks every 30 seconds in case the stream drops (pollIntervalMs changes that); when nothing changed, Mocco answers with an empty 304 Not Modified.
If Mocco can't be reached, the provider keeps answering from the last rules it received and reports PROVIDER_STALE until it reconnects. To start even when Mocco is unreachable at boot, pass a saved copy of the rules as bootstrap.
A flag that is switched off returns your code's default with the reason DISABLED. A flag key Mocco doesn't know returns your default with the error FLAG_NOT_FOUND, so a typo never breaks a request.
See deploys next to flag changes
Each environment's History lists its changes. To see your deploys among them, pick the repository whose pipeline deploys what the environment serves in Show the runs of, next to the History heading. Its pipeline runs then appear between the flag changes, so you can tell whether a flag was turned on before or after the code that reads it shipped. Select a run's commit to open the run. Linking a pipeline only adds the runs to the History: it changes no rule, switch or approval.

With a pipeline linked, Mocco also checks a flag before you turn it on. It looks at the code of the pipeline's last successful run, and if no file quotes the flag's key (as in getBooleanValue('checkout', …)), the editor warns you before you save. Turning the flag on then would serve a value no deployed code reads yet. The warning never stops you.

Use flagd instead
Mocco serves standard flagd flag definitions, so a flagd instance can sync from Mocco and serve flags to any OpenFeature flagd provider, in any language. Point flagd's HTTP sync at Mocco with the server key:
flagd start --sources='[{"uri":"https://api.mocco.club/v1/flags/ruleset","provider":"http","authHeader":"Bearer mk_sec_…","interval":30}]'flagd sends the last ETag with each poll, so unchanged rules cost one small request.
Use flagd v0.15.0 to v0.17.1. flagd v0.18.0 changed how percentage rollouts pick a bucket, so newer versions put many users in a different bucket than Mocco's SDKs, the console preview and browsers do, even though the flags, rules and kills are the same. The same goes for flagd providers that evaluate in-process: in JavaScript, @openfeature/flagd-provider 0.15.0 to 0.16.1 match Mocco, and 0.17.0 and later don't; in other languages, use the provider release that shipped with flagd v0.15 to v0.17. Rollouts without percentages are unaffected.
Missing or null attributes do not match string or version-comparison rules, so evaluation continues to the next rule or the default variant. For environments last published before this fix, the guards arrive with the next genuine configuration change through the normal approval flow. Existing snapshots are not rewritten automatically, and resubmitting an unchanged configuration is rejected. Until the next publication, keep passing the attributes your rules use.
Browsers and apps
For web pages, React and React Native apps, see Feature flags in browsers and apps: devices get only the answers, never the rules.
Experiments and analytics
To compare variants in PostHog, Amplitude, Mixpanel, GA4, Segment or your own warehouse, pass the providers an onExposure function. See Send flag exposures to your analytics tool.
Clean up stale flags
Mocco points out flags that look ready to come out of your code: never evaluated, not evaluated lately, or serving one value to everyone. See Clean up stale flags.
To keep flags in your repository and change them through pull requests, see Flags as code.
Schedule a future change
In the flag editor, prepare your changes and select Schedule for later. Enter a future date and time in your time zone. Check the UTC instant shown beside it, especially when clocks change. A protected environment still needs approval; approving early queues the change without publishing it early. Approval must arrive before the scheduled time and within the normal seven-day approval window. If the policy requires a reason, the approver enters it with their vote.
Execution follows the first available job tick after the time you chose, so it may be later. Another publication to the same environment suspends the schedule. The environment's Scheduled changes list shows upcoming and suspended changes, with the reason and conflicting changeset. Inspect current state before proposing again; old votes do not transfer.
To stop your schedule, choose Cancel schedule and confirm. Cancellation withdraws it and never applies it immediately. To change its time, cancel and create a new schedule. A scheduled change cannot use the kill switch.
Run an approved release plan
Open a flag, choose its environment, and select New release plan under Release plans. Give it a name, choose manual or timed progression, and add its changes in order. Each step has a minimum hold in seconds: after that step runs, the next one waits for the hold to finish. Use the move buttons to reorder steps before reviewing the sequence.
Select Review sequence and check every change, hold and approval policy. Save this reviewed plan records the sequence without running a step. In a protected environment, an eligible colleague approves the whole remaining sequence once. The policy can prevent every contributor from approving their own work and require a reason with each vote. Changing remaining steps makes a new revision and requires a fresh approval; already applied steps stay unchanged.
A manual plan advances one step when a person selects Advance one step and confirms the reviewed change. Protected plans require a current role in their policy; workspace ownership alone does not grant that role. A timed plan runs at most one eligible step per worker tick, normally once a minute, so it can run later than the earliest time shown. The timeline identifies each applied plan revision and step.
Use Pause plan or Cancel plan to stop future steps. Neither undoes changes already applied. A kill or a change to the target outside the plan pauses it too; restoring the flag does not resume the plan. Read the displayed reason, fix the remaining steps if needed, and select Review and resume. Resuming against changed state creates a new revision and, when protected, another approval request. It does not immediately run a step.
You can start from a project template or save your remaining steps as one. Templates do not carry a flag key and using one leaves existing plans unchanged. Segment definitions can change only when another flag does not use them; copy a shared segment before including its changes. Repository-managed flags still change through their repository.