Update a flag's environment
Code Mode: praxis.devops.flags.environments.update
HTTP: PATCH /devops/v1/flags/{id}/environments/{environment}
Turn a flag on in one environment, and change what that environment serves. Send version — the configuration version you read with flags.get — and comment; send config as the whole configuration, because this call replaces it rather than merging. config carries on (whether the flag evaluates here at all), prerequisites ([[{flagKey, variation}] the flags this one depends on), targets ([[{kind, variation, keys}] callers served a named variation regardless of the rules), rules ([[{id, clauses, serve}] in evaluation order, each a list of {attribute, op, values} clauses that must all match), and fallthrough (what a caller matching no rule gets while the flag is on). Off is not a config: to serve one variation to everyone, set fallthrough to {variation: <id>}; to split callers, set fallthrough to {rollout: {bucketBy: targetingKey, seed: <n>, weights: {<id>: <n out of 100000>}}} — the weights must total exactly 100000. A stale version is refused with FLAG_VERSION_CONFLICT instead of silently overwriting someone else’s edit. Targets whose keys are not deployed yet are refused with FLAG_CODE_NOT_DEPLOYED, because serving a variation the running code cannot name would fail at evaluation time. The current version comes from praxis api devops flag get <id>: it is the version of that environment in the flag’s environments map. Fully open means on true with no rules and fallthrough {variation: <the on variation>} (see the everyone example); opening a flag is this configuration change, nothing else. To open it to one organization, add a rule whose clause is {attribute: tenantId, op: in, values: [<organization id>]} served the on variation: flagsFor evaluates with tenantId set to the caller’s organization id (targetingKey carries the same value), so that clause matches exactly that organization. Do not use a segment of kind organization: flagsFor passes no context kind, so the evaluator treats it as a user context and a segment of kind organization never matches.
签名
praxis.devops.flags.environments.update(args:{path:{/** e.g. "flg_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ id:string;/** e.g. "dve_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ environment:string};body:{/** The configuration version you read before making this change; when the environment has moved past it the write is refused with FLAG_VERSION_CONFLICT rather than e.g. 3 */ version:number;/** Why the configuration is changing, stored with the change so the history reads as decisions rather than as diffs. e.g. "raising the rollout to 25% after a clean day." */ comment:string;config:{/** Whether the flag is evaluated in this environment; false serves the off variation to everyone, whatever the rules say. e.g. true */ on:boolean;/** The flags this one depends on and the variation each must serve; send an empty list to remove every prerequisite. */ prerequisites:Array<{/** The key of the prerequisite flag, which is how code and the evaluator name it. e.g. "sandbox-ephemeral-default" */ flagKey:string;/** The variation the prerequisite must serve; when it serves anything else this flag is not evaluated and its off variation is served. e.g. "on" */ variation:string}>;/** The individually named callers and the variation each group is served; send an empty list to remove all of them. */ targets:Array<{/** The context kind these keys belong to, such as user or organization; the same key string can name different things in different kinds. e.g. "user" */ kind:string;/** The variation every caller in this group is served, whatever the rules would have decided. e.g. "on" */ variation:string;/** The targeting keys in this group; a caller whose targetingKey is listed here is served this variation. */ keys:Array<string>}>;/** The targeting rules in evaluation order; send an empty list to make every caller fall through to the fallthrough. */ rules:Array<{/** Rule identifier, used when a rule is updated or removed by a configuration write. e.g. "rule-1" */ id:string;/** What this rule is for, in the author's words; absent when none was given, which makes a rule hard to judge later. e.g. "Internal users get the new path first." */ description?:string;/** The conditions this rule tests, all of which must match; an empty list matches every caller. */ clauses:Array<{/** The context kind the attribute belongs to, absent when the attribute is read from the caller's own context. e.g. "organization" */ kind?:string;/** Which context attribute is tested; it must be one of the project's declared attributes for that kind, or the configuration is refused. e.g. "region" */ attribute:string;/** How the attribute is compared; the operators that need one value, such as startsWith, use the first entry of values. e.g. "in" */ op:"in"|"notIn"|"startsWith"|"endsWith"|"contains"|"matches"|"lessThan"|"greaterThan"|"semVerLessThan"|"semVerGreaterThan"|"before"|"after"|"inSegment";/** The values this comparison uses; their type must match the attribute's declared type, and a mismatch is refused rather than evaluated as false. e.g. ["apac","eu"] */ values:Array<unknown>;/** Whether the result of the comparison is inverted; true serves the rule's variation when the comparison does not match. e.g. false */ negate?:boolean}>;serve:{/** The variation to serve; it must name one of the flag's variations. e.g. "on" */ variation:string}|{rollout:{/** Which context attribute is bucketed, such as targetingKey; bucketing by a stable attribute is what keeps one caller on one side. e.g. "targetingKey" */ bucketBy:string;/** The number that salts the bucketing; two splits with different seeds place the same caller differently, which is how a split is reset. e.g. 428173911 */ seed:number;/** Variation id to weight, out of 100000; the weights must total exactly 100000 or the write is refused with ROLLOUT_WEIGHTS_INVALID. e.g. {"on":50000,"off":50000} */ weights:{[key:string]:number}}};/** Whether the rule is skipped; true keeps the rule in place without letting it decide anything. e.g. false */ disabled?:boolean}>;fallthrough:{/** The variation to serve; it must name one of the flag's variations. e.g. "on" */ variation:string}|{rollout:{/** Which context attribute is bucketed, such as targetingKey; bucketing by a stable attribute is what keeps one caller on one side. e.g. "targetingKey" */ bucketBy:string;/** The number that salts the bucketing; two splits with different seeds place the same caller differently, which is how a split is reset. e.g. 428173911 */ seed:number;/** Variation id to weight, out of 100000; the weights must total exactly 100000 or the write is refused with ROLLOUT_WEIGHTS_INVALID. e.g. {"on":50000,"off":50000} */ weights:{[key:string]:number}}}}}}):Promise<{/** Flag identifier used by every later read and write of this flag; code names the flag by key, while this API addresses it by id. e.g. "flg_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ id:string;/** The resource type of this answer, always flag. */ object:"flag";/** RFC 3339 UTC time the flag was created; the flag list is ordered by it, newest first. e.g. "2026-10-27T02:00:00Z" */ createTime:string;/** RFC 3339 UTC time the flag's own fields last changed; a change to one environment's configuration does not move this. e.g. "2026-11-02T08:12:00Z" */ updateTime:string;/** Canonical Console link for the project this flag belongs to. e.g. "https://console.deepraxis.com/devops/projects/dvp_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ viewerUrl:string;/** The project this flag belongs to, from the project list. e.g. "dvp_01m6j8swzteapw2j5sh4" */ project:string;/** The name code calls this flag by, unique inside the project including archived flags; it is what a ruleset and a client library look up. e.g. "sandbox-ephemeral-default" */ key:string;/** Display name of the flag, shown wherever it is listed; it may change freely and nothing depends on it. e.g. "Sandbox defaults to an ephemeral instance" */ name:string;/** What this flag does to the product, absent when none was given; it is where the reason for the flag belongs. e.g. "New sandboxes start ephemeral unless the caller asks for a persistent one." */ description?:string;/** What sort of flag this is, which decides how long it may live and what its removal means. e.g. "release" */ kind:"release"|"experiment"|"ops"|"permission";/** The type every variation of this flag has; a value of another type cannot be served, and clients request the flag in this type. e.g. "boolean" */ valueType:"boolean"|"string"|"number"|"object";/** The values this flag can serve, each with the id that rules and defaults refer to. */ variations:Array<{/** Variation id, which is what a default, a rule and a rollout name; it is a name, not the value itself. e.g. "on" */ id:string;/** The value served when this variation is selected; its type is the flag's valueType. e.g. true */ value:unknown;/** Human-readable name for this variation, absent when only an id was given. e.g. "On" */ name?:string}>;defaults:{/** Variation served to a caller that matches no rule while the flag is on; it must name one of the flag's variations. e.g. "on" */ onVariation:string;/** Variation served while the flag is off, whatever the rules say; this is the value an incident falls back to. e.g. "off" */ offVariation:string};/** Who owns this flag and is expected to conclude it when its observation deadline arrives; null when the flag was created without one. */ owner:null|{/** What sort of actor this is, which decides how the id should be read. e.g. "user" */ kind:"user"|"agent"|"system";/** Identifier of the actor within its kind, such as a user id for a person. e.g. "usr_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ id:string;/** Display name for the actor at the time, so a record reads the way it did when it was written; absent when none was known. e.g. "Sean" */ label?:string};/** RFC 3339 UTC time this flag must be decided by, required for a release or experiment flag; absent for a flag that has no deadline. e.g. "2026-12-15T23:59:59Z" */ observeUntil?:string;/** The ticket that removes the flag and its code once the rollout is complete, absent when none was recorded. e.g. "#279" */ removalTicket?:string;origin:{/** Which path created the flag; exposure means a change declared it and carried it here, manual means someone created it directly. e.g. "manual" */ declaredBy:"exposure"|"manual";/** The pull request that declared this flag, present only when declaredBy is exposure; it is what ties the flag to the change that introduced it. e.g. "pr_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ pullRequest?:string};/** Where the flag is in its own life; launched means the behaviour is permanent and only the code and the flag row remain to be removed. e.g. "active" */ lifecycle:"new"|"active"|"launched"|"inactive"|"archived";/** Whether the flag looks abandoned: its deadline has passed or no environment has used it. e.g. false */ stale:boolean;/** What each environment of the project serves for this flag, keyed by environment id; every environment has an entry from the moment the flag is created. e.g. {"dve_01JQ8Z3M9K4V7B2N6C5X0YTRHW":{"on":true,"version":3}} */ environments:{[key:string]:{/** Whether the flag is evaluated at all here; false serves the off variation to everyone and makes the rules and the rollout below irrelevant. e.g. true */ on:boolean;/** Other flags this one depends on: it is evaluated only when each of them serves the variation named here. */ prerequisites:Array<{/** The key of the prerequisite flag, which is how code and the evaluator name it. e.g. "sandbox-ephemeral-default" */ flagKey:string;/** The variation the prerequisite must serve; when it serves anything else this flag is not evaluated and its off variation is served. e.g. "on" */ variation:string}>;/** Callers named individually, grouped by context kind, and the variation each group gets; a named caller is served before any rule is evaluated. */ targets:Array<{/** The context kind these keys belong to, such as user or organization; the same key string can name different things in different kinds. e.g. "user" */ kind:string;/** The variation every caller in this group is served, whatever the rules would have decided. e.g. "on" */ variation:string;/** The targeting keys in this group; a caller whose targetingKey is listed here is served this variation. */ keys:Array<string>}>;/** The targeting rules, evaluated in order; the first rule whose clauses all match decides the variation, and an empty list means every caller falls through. */ rules:Array<{/** Rule identifier, used when a rule is updated or removed by a configuration write. e.g. "rule-1" */ id:string;/** What this rule is for, in the author's words; absent when none was given, which makes a rule hard to judge later. e.g. "Internal users get the new path first." */ description?:string;/** The conditions this rule tests, all of which must match; an empty list matches every caller. */ clauses:Array<{/** The context kind the attribute belongs to, absent when the attribute is read from the caller's own context. e.g. "organization" */ kind?:string;/** Which context attribute is tested; it must be one of the project's declared attributes for that kind, or the configuration is refused. e.g. "region" */ attribute:string;/** How the attribute is compared; the operators that need one value, such as startsWith, use the first entry of values. e.g. "in" */ op:"in"|"notIn"|"startsWith"|"endsWith"|"contains"|"matches"|"lessThan"|"greaterThan"|"semVerLessThan"|"semVerGreaterThan"|"before"|"after"|"inSegment";/** The values this comparison uses; their type must match the attribute's declared type, and a mismatch is refused rather than evaluated as false. e.g. ["apac","eu"] */ values:Array<unknown>;/** Whether the result of the comparison is inverted; true serves the rule's variation when the comparison does not match. e.g. false */ negate?:boolean}>;serve:{/** The variation to serve; it must name one of the flag's variations. e.g. "on" */ variation:string}|{rollout:{/** Which context attribute is bucketed, such as targetingKey; bucketing by a stable attribute is what keeps one caller on one side. e.g. "targetingKey" */ bucketBy:string;/** The number that salts the bucketing; two splits with different seeds place the same caller differently, which is how a split is reset. e.g. 428173911 */ seed:number;/** Variation id to weight, out of 100000; the weights must total exactly 100000 or the write is refused with ROLLOUT_WEIGHTS_INVALID. e.g. {"on":50000,"off":50000} */ weights:{[key:string]:number}}};/** Whether the rule is skipped; true keeps the rule in place without letting it decide anything. e.g. false */ disabled?:boolean}>;fallthrough:{/** The variation to serve; it must name one of the flag's variations. e.g. "on" */ variation:string}|{rollout:{/** Which context attribute is bucketed, such as targetingKey; bucketing by a stable attribute is what keeps one caller on one side. e.g. "targetingKey" */ bucketBy:string;/** The number that salts the bucketing; two splits with different seeds place the same caller differently, which is how a split is reset. e.g. 428173911 */ seed:number;/** Variation id to weight, out of 100000; the weights must total exactly 100000 or the write is refused with ROLLOUT_WEIGHTS_INVALID. e.g. {"on":50000,"off":50000} */ weights:{[key:string]:number}}};/** The progressive rollout currently ramping this environment, absent when the environment serves its fallthrough directly. e.g. "prr_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ progressiveRollout?:string;/** The configuration version, incremented by each accepted write; send the version you read so a concurrent edit is refused rather than overwritten. e.g. 3 */ version:number;/** RFC 3339 UTC time this environment's configuration last changed. e.g. "2026-11-02T08:12:00Z" */ updateTime:string;updatedBy:{/** What sort of actor this is, which decides how the id should be read. e.g. "user" */ kind:"user"|"agent"|"system";/** Identifier of the actor within its kind, such as a user id for a person. e.g. "usr_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ id:string;/** Display name for the actor at the time, so a record reads the way it did when it was written; absent when none was known. e.g. "Sean" */ label?:string}}};codeRefs:{/** How many places the scan found the flag key read at the scanned commit; zero means no code reads it. e.g. 4 */ count:number;/** The commit the scan read; an old commit means the count describes the code as it was then, not as it is now. e.g. "4f2a9c1d8e7b6a5c4d3e2f1a0b9c8d7e6f5a4b3c" */ scannedCommit:string};/** Labels on the flag for grouping and searching; empty when none were set. */ tags:Array<string>;/** Which evaluator serves this flag at runtime; it decides whether a ruleset or the local flag binding answers an evaluation. e.g. "ruleset" */ evaluator:"flagship"|"ruleset"}>;参数
| 名称 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
| id | path | string | 是 | The flag identifier from a flag list or create answer; code names a flag by its key, while this API addresses it by id. |
| environment | path | string | 是 | The environment whose configuration you are changing, from the flag’s own environments map or the project’s environment list. |
请求体
| 必填 | 内容类型 | 说明 |
|---|---|---|
| 是 | application/json |
响应
| 状态码 | 内容类型 | 说明 |
|---|---|---|
| 200 | application/json | The flag after the environment change, with the environment’s new version. |
| 400 | application/json | INVALID_PARAMS or INVALID_ARGUMENT means a field, query value or identifier violates the documented format or range — an unknown enum value, a pageSize outside 1..100, an unsupported filter or orderBy field, or an id with the wrong prefix. Correct the named input; nothing was read or written. |
| 401 | application/json | The API key is missing or invalid; send a valid Praxis API key in the Authorization header before retrying. |
| 403 | application/json | The credential carries no organization, or that organization cannot reach this project; use a key belonging to the project’s organization. No cross-organization read is possible. |
| 404 | application/json | FLAG_NOT_FOUND means no flag with that id exists in this organization; list the project’s flags and use an id from that answer. An archived flag is still readable by id — it is the list that hides it. |
| 409 | application/json | FLAG_VERSION_CONFLICT means the version you sent is not the environment’s current one, so someone else changed it first; read the flag again, reapply your change to the new configuration and send the new version. ROLLOUT_WEIGHTS_INVALID means the rollout weights do not sum to 100000, which is the only accepted total. |
| 500 | application/json | INTERNAL means the service could not complete the request; retry once, and if it repeats report the request id. A read is safe to repeat; a write that failed this way should be re-read before it is sent again. |