Flags guides
13 · Approvals: agents propose, people approve

Let agents propose. People approve.

Give AI agents and scripts real access to your flags, and still have a person check every change to Production before it goes live.


1

Choose who must ask first

In Flags › Settings, give each environment an approval policy. With No approval, changes go live at once. With Agents and API keys propose, people signed in to the console still change flags directly, but an API key, or an AI agent using someone's access through MCP, can only propose. With Everyone proposes, every change waits for review. Pick 1, 2 or 3 approvals per change.

Only a person signed in to the console can change the policy, so an agent cannot switch off the check that applies to it.


2

Propose a change

Where approval applies, a direct change answers 409 APPROVAL_REQUIRED. Send the same change as a change request instead: a patch (the toggle, removing rules, adding a tester), a replace (the whole targeting) or a ramp. Flags checks it exactly as it would check the change itself, and stores the proposal, its diff, who proposed it (and for whom, when an agent did) and your note. In MCP the tool is flags_propose_change; the console does this for you.

propose.ts
import { Flags } from "@productcraft/flags";
const flags = new Flags(); // an API key: production needs approval for it

declare const settingId: string;
declare const productionId: string;

const current = await flags.settings.values.retrieve(settingId, productionId);
const request = await flags.settings.values.changeRequests.create(settingId, productionId, {
  operation: "patch",
  version: current.version,
  value: true,
  note: "Launch the new checkout (FLAG-142)",
});
console.log(request.status, request.summary); // "pending" [ "value false → true" ]

3

Review

Owners and admins get an email, and your webhooks get change_request.created. In Flags › Change requests, a reviewer reads the diff and approves or rejects it. The author, and the person an agent proposed it for, cannot approve it. API keys and agents can never approve anything. With enough approvals, Approve and apply puts it live at once.


4

Apply, schedule or rebase

Anyone allowed to make the change, including the agent that proposed it, can apply an approved request or schedule it for later. Applying only works if the flag has not changed since the proposal. If it has, the request is out of date (409 CHANGE_REQUEST_STALE): rebase it to diff the same proposal against the flag as it is now, and it goes back for review.

Every step is in the history and the workspace audit log, and is sent to your webhooks as change_request.approved, rejected, applied or cancelled.

apply.ts
import { Flags } from "@productcraft/flags";
const flags = new Flags();

declare const changeRequestId: string;

const request = await flags.changeRequests.retrieve(changeRequestId);
if (request.status === "approved") {
  await flags.changeRequests.apply(changeRequestId);
} else if (request.stale) {
  // The flag changed since it was proposed: re-diff it and ask again.
  await flags.changeRequests.rebase(changeRequestId);
}