Skip to content
中文

Create a segment

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

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

Create a segment in one environment: a key that flag rules refer to it by, the recipients named directly (included), the ones always held out (excluded), and rules that add recipients by a context attribute. The key must match ^[a-z][a-z0-9-]{0,63}$ and is unique inside the environment, because a rule that targets the segment matches that string; name is only the display label, and kind says what the listed recipients are, user by default. Creating a segment changes no evaluation until a flag rule names it.

Signature

praxis.devops.projects.segments.create(args:{path:{/** e.g. "dvp_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ project:string};body:{/** The environment the segment belongs to, from the project's environment list; a segment created here is invisible in the project's other environments. e.g. "dve_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ environment:string;/** The name flag rules will match this segment by; unique inside the environment and refused with INVALID_ARGUMENT when already used, because it can never be renam pattern: ^[a-z][a-z0-9-]{0,63}$ e.g. "beta-testers" */ key:string;/** Display name for the segment; omitted uses the key itself. e.g. "Beta testers" */ name?:string;/** The context kind the listed recipients belong to, which is a free string naming any context kind the project declares — user and organization are the usual ones e.g. "user" */ kind?:string;/** Recipients to put in the segment from the start; omitted is an empty list. */ included?:Array<string>;/** Recipients to hold out from the start, even when a rule would select them; omitted is an empty list. */ excluded?:Array<string>;/** Rules that add recipients by attribute; omitted is an empty list, which leaves membership to the two lists above. */ rules?:Array<{/** 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}>;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<{/** Segment identifier used by updates; rules target a segment by its key, not by this id. e.g. "seg_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ id:string;/** The resource type of this answer, always segment. */ object:"segment";/** RFC 3339 UTC time the segment was created; it is the default order of the segment list. e.g. "2026-11-03T09:10:00Z" */ createTime:string;/** RFC 3339 UTC time the segment's membership or name last changed. e.g. "2026-11-03T09:14:00Z" */ updateTime:string;/** Canonical Console link for the project this segment belongs to. e.g. "https://console.deepraxis.com/devops/projects/dvp_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ viewerUrl:string;/** The project this segment belongs to, from the project list. e.g. "dvp_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ project:string;/** The environment this segment belongs to; a segment never crosses environments, so the same audience is created once per environment it is needed in. e.g. "dve_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ environment:string;/** The name flag rules match this segment by; unique inside the environment, unchanged after creation, and what an inSegment clause carries. pattern: ^[a-z][a-z0-9-]{0,63}$ e.g. "beta-testers" */ key:string;/** Display name of the segment, shown wherever it is listed; it defaults to the key. e.g. "Beta testers" */ name:string;/** What the listed recipients are, such as a user or an organization; it says which context attribute the entries are compared against. e.g. "user" */ kind:string;/** Recipients always in the segment, whatever their context says; an empty list adds nobody by name. */ included:Array<string>;/** Recipients always out of the segment, even when a rule would select them; exclusion wins over inclusion. */ excluded:Array<string>;/** Rules that add recipients by a context attribute, such as everyone in a region; an empty list means membership is only the lists above. */ rules:Array<{/** 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}>;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}}}>}>;

Parameters

NameInTypeRequiredDescription
projectpathstringyesIdentifies the project whose data you are reading, from the project list or create answer.

Request body

RequiredContent typesDescription
yesapplication/json

Responses

StatusContent typesDescription
200application/jsonThe segment as created, with its id, key and membership.
400application/jsonINVALID_ARGUMENT means the key does not match the required shape, or the key is already used in that environment — a segment key is never reused, so pick another or update the existing segment. Nothing was 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/jsonENVIRONMENT_NOT_FOUND means no environment with that id exists in this organization, or it belongs to another project; list the project’s environments and use an id from that answer.
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.