跳转到内容
EN

Create a flag

Code Mode: praxis.devops.projects.flags.create

HTTP: POST /devops/v1/projects/{project}/flags

Create a feature flag in a project: its key, what kind of flag it is, the values it can serve, and which variation is served when it is off. The key is what code names, so it is unique per project and a key already in use is refused with FLAG_KEY_TAKEN rather than reused — an archived flag keeps its key. owner, observeUntil and removalTicket carry the flag’s lifecycle: a release or experiment flag expects an observation deadline and the ticket that removes it, and a flag missing them is refused with FLAG_LIFECYCLE_INCOMPLETE. A new flag starts with every environment off, so creating one changes no runtime behaviour; turn an environment on with the environment update.

签名

praxis.devops.projects.flags.create(args:{path:{/** e.g. "dvp_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ project:string};body:{/** The name code will call this flag by; unique inside the project, and a key already in use is refused with FLAG_KEY_TAKEN rather than reused. pattern: ^[a-z][a-z0-9-]{0,63}$ e.g. "sandbox-ephemeral-default" */ key:string;/** Display name of the flag, shown wherever it is listed. e.g. "Sandbox defaults to an ephemeral instance" */ name:string;/** What this flag does to the product, so a later reader does not have to trace the code to find out. e.g. "New sandboxes start ephemeral unless the caller asks for a persistent one." */ description?:string;/** What sort of flag this is; it decides the expected lifetime, and a release or experiment flag must carry an observation deadline. e.g. "release" */ kind:"release"|"experiment"|"ops"|"permission";/** The type every variation must have; a variation of another type is refused. e.g. "boolean" */ valueType:"boolean"|"string"|"number"|"object";/** The values the flag can serve, at least two for a flag that decides anything; their ids are what defaults and rules name. */ 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};owner?:{/** 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 and refused with INVALID_ARGUMENT when it is missing. e.g. "2026-12-15T23:59:59Z" */ observeUntil?:string;/** The ticket that will remove the flag and its code; giving it here is what makes the removal traceable from the flag itself. e.g. "#279" */ removalTicket?:string;/** The pull request that declared this flag, when the flag comes from a code change rather than being created by hand. e.g. "pr_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ pullRequest?:string;/** Caller-chosen key that makes this create idempotent: repeating it answers the flag the first call created instead of refusing the key as taken. e.g. "flag-sandbox-ephemeral-default" */ requestId?:string}}):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"}>;

参数

名称位置类型必填说明
projectpathstring是Identifies the project whose data you are reading, from the project list or create answer.

请求体

必填内容类型说明
是application/json

响应

状态码内容类型说明
200application/jsonThe created flag, with its variations, defaults and per-environment configuration.
400application/jsonINVALID_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.
401application/jsonThe API key is missing or invalid; send a valid Praxis API key in the Authorization header before retrying.
403application/jsonThe 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.
404application/jsonPROJECT_NOT_FOUND means no project with that id is visible to this organization; list the projects and use an id from that answer.
409application/jsonFLAG_KEY_TAKEN means the project already has a flag with that key, including an archived one; read the existing flag and change it, or choose a different key. Nothing was created.
500application/jsonINTERNAL 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.