Update a segment. The request body must be a valid semantic patch, JSON patch, or JSON merge patch. To learn more the different formats, read Updates.
To make a semantic patch request, you must append domain-model=launchdarkly.semanticpatch
to your Content-Type
header. To learn more, read Updates using semantic patch.
The body of a semantic patch request for updating segments requires an environmentKey
in addition to instructions
and an optional comment
. The body of the request takes the following properties:
comment
(string): (Optional) A description of the update.environmentKey
(string): (Required) The key of the LaunchDarkly environment.instructions
(array): (Required) A list of actions the update should perform. Each action in the list must be an object with a kind
property that indicates the instruction. If the action requires parameters, you must include those parameters as additional fields in the object.Semantic patch requests support the following kind
instructions for updating segments.
Adds tags to the segment.
values
: A list of tags to add.Here’s an example:
Removes tags from the segment.
values
: A list of tags to remove.Here’s an example:
Updates the name of the segment.
value
: Name of the segment.Here’s an example:
Adds context keys to the individual context targets excluded from the segment for the specified contextKind
. Returns an error if this causes the same context key to be both included and excluded.
contextKind
: The context kind the targets should be added to.values
: List of keys.Here’s an example:
Adds user keys to the individual user targets excluded from the segment. Returns an error if this causes the same user key to be both included and excluded. If you are working with contexts, use addExcludedTargets
instead of this instruction.
values
: List of user keys.Here’s an example:
Adds context keys to the individual context targets included in the segment for the specified contextKind
. Returns an error if this causes the same context key to be both included and excluded.
contextKind
: The context kind the targets should be added to.values
: List of keys.Here’s an example:
Adds user keys to the individual user targets included in the segment. Returns an error if this causes the same user key to be both included and excluded. If you are working with contexts, use addIncludedTargets
instead of this instruction.
values
: List of user keys.Here’s an example:
Removes context keys from the individual context targets excluded from the segment for the specified contextKind
.
contextKind
: The context kind the targets should be removed from.values
: List of keys.Here’s an example:
Removes user keys from the individual user targets excluded from the segment. If you are working with contexts, use removeExcludedTargets
instead of this instruction.
values
: List of user keys.Here’s an example:
Removes context keys from the individual context targets included in the segment for the specified contextKind
.
contextKind
: The context kind the targets should be removed from.values
: List of keys.Here’s an example:
Removes user keys from the individual user targets included in the segment. If you are working with contexts, use removeIncludedTargets
instead of this instruction.
values
: List of user keys.Here’s an example:
Adds the given clauses to the rule indicated by ruleId
.
clauses
: Array of clause objects, with contextKind
(string), attribute
(string), op
(string), negate
(boolean), and values
(array of strings, numbers, or dates) properties. The contextKind
, if not provided, defaults to user
. The contextKind
, attribute
, and values
are case sensitive. The op
must be lower-case.ruleId
: ID of a rule in the segment.Here’s an example:
Adds a new targeting rule to the segment. The rule may contain clauses
.
clauses
: Array of clause objects, with contextKind
(string), attribute
(string), op
(string), negate
(boolean), and values
(array of strings, numbers, or dates) properties. The contextKind
, if not provided, defaults to user
. The contextKind
, attribute
, and values
are case sensitive. The op
must be lower-case.description
: A description of the rule.Here’s an example:
Adds values
to the values of the clause that ruleId
and clauseId
indicate. Does not update the context kind, attribute, or operator.
ruleId
: ID of a rule in the segment.clauseId
: ID of a clause in that rule.values
: Array of strings, case sensitive.Here’s an example:
Removes the clauses specified by clauseIds
from the rule indicated by ruleId
.
ruleId
: ID of a rule in the segment.clauseIds
: Array of IDs of clauses in the rule.Here’s an example:
Removes the targeting rule specified by ruleId
. Does nothing if the rule does not exist.
ruleId
: ID of a rule in the segment.Here’s an example:
Removes values
from the values of the clause indicated by ruleId
and clauseId
. Does not update the context kind, attribute, or operator.
ruleId
: ID of a rule in the segment.clauseId
: ID of a clause in that rule.values
: Array of strings, case sensitive.Here’s an example:
Rearranges the rules to match the order given in ruleIds
. Returns an error if ruleIds
does not match the current set of rules in the segment.
ruleIds
: Array of IDs of all targeting rules in the segment.Here’s an example:
Replaces the clause indicated by ruleId
and clauseId
with clause
.
ruleId
: ID of a rule in the segment.clauseId
: ID of a clause in that rule.clause
: New clause
object, with contextKind
(string), attribute
(string), op
(string), negate
(boolean), and values
(array of strings, numbers, or dates) properties. The contextKind
, if not provided, defaults to user
. The contextKind
, attribute
, and values
are case sensitive. The op
must be lower-case.Here’s an example:
Updates the description of the segment targeting rule.
description
: The new human-readable description for this rule.ruleId
: The ID of the rule. You can retrieve this by making a GET request for the segment.Here’s an example:
For a rule that includes a percentage of targets, updates the percentage and the context kind of the targets to include.
ruleId
: The ID of a targeting rule in the segment that includes a percentage of targets.weight
: The weight, in thousandths of a percent (0-100000).contextKind
: The context kind.Here’s an example:
A “big segment” is a segment that is either a synced segment, or a list-based segment with more than 15,000 entries that includes only one targeted context kind. LaunchDarkly uses different implementations for different types of segments so that all of your segments have good performance.
The following semantic patch instructions apply only to these larger list-based segments.
For use with larger list-based segments ONLY. Adds context keys to the context targets excluded from the segment. Returns an error if this causes the same context key to be both included and excluded.
values
: List of context keys.Here’s an example:
For use with larger list-based segments ONLY. Adds context keys to the context targets included in the segment. Returns an error if this causes the same context key to be both included and excluded.
values
: List of context keys.Here’s an example:
For use with larger list-based segments ONLY. Processes a segment import.
importId
: The ID of the import. The import ID is returned in the Location
header as part of the Create big segment import request.Here’s an example:
For use with larger list-based segments ONLY. Removes context keys from the context targets excluded from the segment.
values
: List of context keys.Here’s an example:
For use with larger list-based segments ONLY. Removes context keys from the context targets included in the segment.
values
: List of context keys.Here’s an example:
If you do not include the header described above, you can use a JSON patch or JSON merge patch representation of the desired changes.
For example, to update the description for a segment with a JSON patch, use the following request body:
To update fields in the segment that are arrays, set the path
to the name of the field and then append /<array index>
. Use /0
to add the new entry to the beginning of the array. Use /-
to add the new entry to the end of the array.
For example, to add a rule to a segment, use the following request body:
To add or remove targets from segments, we recommend using semantic patch. Semantic patch for segments includes specific instructions for adding and removing both included and excluded targets.
The project key
The environment key
The segment key
A JSON patch representation of the change to make
Optional comment
Segment response
A human-friendly name for the segment.
Timestamp of when the segment was created
Timestamp of when the segment was last modified
A unique key used to reference the segment
The location and content type of related resources
An array of the targeting rules for this segment.
Version of the segment
Whether the segment has been deleted
For big segments, how many times this segment has been created.
A description of the segment’s purpose. Defaults to null
and is omitted in the response if not provided.
An array of keys for included targets. Included individual targets are always segment members, regardless of segment rules. For list-based segments over 15,000 entries, also called big segments, this array is either empty or omitted.
An array of keys for excluded targets. Segment rules bypass individual excluded targets, so they will never be included based on rules. Excluded targets may still be included explicitly. This value is omitted for list-based segments over 15,000 entries, also called big segments.
A list of flags targeting this segment. Only included when getting a single segment, using the getSegment
endpoint.
Whether this is a standard segment (false
) or a big segment (true
). Standard segments include rule-based segments and smaller list-based segments. Big segments include larger list-based segments and synced segments. If omitted, the segment is a standard segment.
For big segments, the targeted context kind.
Details on the external data store backing this segment. Only applies to big segments.
The external data store backing this segment. Only applies to synced segments.
The URL for the external data store backing this segment. Only applies to synced segments.
Whether an import is currently in progress for the specified segment. Only applies to big segments.