Update AI Config targeting
Perform a partial update to an AI Config’s targeting. The request body must be a valid semantic patch.
Using semantic patches on an AI Config
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 an AI Config’s targeting takes the following properties:
comment
(string): (Optional) A description of the update.environmentKey
(string): 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 akind
property that indicates the instruction. If the action requires parameters, you must include those parameters as additional fields in the object. The body of a single semantic patch can contain many different instructions.
Instructions
Semantic patch requests support the following kind
instructions for updating AI Configs.
Click to expand instructions for working with targeting and variations for AI Configs
addClauses
Adds the given clauses to the rule indicated by ruleId
.
Parameters
ruleId
: ID of a rule in the AI Config.clauses
: Array of clause objects, withcontextKind
(string),attribute
(string),op
(string),negate
(boolean), andvalues
(array of strings, numbers, or dates) properties. ThecontextKind
,attribute
, andvalues
are case sensitive. Theop
must be lower-case.
Here’s an example:
addRule
Adds a new targeting rule to the AI Config. The rule may contain clauses
and serve the variation that variationId
indicates, or serve a percentage rollout that rolloutWeights
, rolloutBucketBy
, and rolloutContextKind
indicate.
If you set beforeRuleId
, this adds the new rule before the indicated rule. Otherwise, adds the new rule to the end of the list.
Parameters
clauses
: Array of clause objects, withcontextKind
(string),attribute
(string),op
(string),negate
(boolean), andvalues
(array of strings, numbers, or dates) properties. ThecontextKind
,attribute
, andvalues
are case sensitive. Theop
must be lower-case.beforeRuleId
: (Optional) ID of a rule.- Either
variationId
: ID of a variation.
or
rolloutWeights
: (Optional) Map ofvariationId
to weight, in thousandths of a percent (0-100000).rolloutBucketBy
: (Optional) Context attribute available in the specifiedrolloutContextKind
.rolloutContextKind
: (Optional) Context kind, defaults touser
Here’s an example that uses a variationId
:
Here’s an example that uses a percentage rollout:
addTargets
Adds context keys to the individual context targets for the context kind that contextKind
specifies and the variation that variationId
specifies. Returns an error if this causes the AI Config to target the same context key in multiple variations.
Parameters
values
: List of context keys.contextKind
: (Optional) Context kind to target, defaults touser
variationId
: ID of a variation.
Here’s an example:
addValuesToClause
Adds values
to the values of the clause that ruleId
and clauseId
indicate. Does not update the context kind, attribute, or operator.
Parameters
ruleId
: ID of a rule in the AI Config.clauseId
: ID of a clause in that rule.values
: Array of strings, case sensitive.
Here’s an example:
clearTargets
Removes all individual targets from the variation that variationId
specifies. This includes both user and non-user targets.
Parameters
variationId
: ID of a variation.
Here’s an example:
removeClauses
Removes the clauses specified by clauseIds
from the rule indicated by ruleId
.
Parameters
ruleId
: ID of a rule.clauseIds
: Array of IDs of clauses in the rule.
Here’s an example:
removeRule
Removes the targeting rule specified by ruleId
. Does nothing if the rule does not exist.
Parameters
ruleId
: ID of a rule.
Here’s an example:
removeTargets
Removes context keys from the individual context targets for the context kind that contextKind
specifies and the variation that variationId
specifies. Does nothing if the flag does not target the context keys.
Parameters
values
: List of context keys.contextKind
: (Optional) Context kind to target, defaults touser
variationId
: ID of a variation.
Here’s an example:
removeValuesFromClause
Removes values
from the values of the clause indicated by ruleId
and clauseId
. Does not update the context kind, attribute, or operator.
Parameters
ruleId
: ID of a rule.clauseId
: ID of a clause in that rule.values
: Array of strings, case sensitive.
Here’s an example:
reorderRules
Rearranges the rules to match the order given in ruleIds
. Returns an error if ruleIds
does not match the current set of rules on the AI Config.
Parameters
ruleIds
: Array of IDs of all rules.
Here’s an example:
replaceRules
Removes all targeting rules for the AI Config and replaces them with the list you provide.
Parameters
rules
: A list of rules.
Here’s an example:
replaceTargets
Removes all existing targeting and replaces it with the list of targets you provide.
Parameters
targets
: A list of context targeting. Each item in the list includes an optionalcontextKind
that defaults touser
, a requiredvariationId
, and a required list ofvalues
.
Here’s an example:
updateClause
Replaces the clause indicated by ruleId
and clauseId
with clause
.
Parameters
ruleId
: ID of a rule.clauseId
: ID of a clause in that rule.clause
: Newclause
object, withcontextKind
(string),attribute
(string),op
(string),negate
(boolean), andvalues
(array of strings, numbers, or dates) properties. ThecontextKind
,attribute
, andvalues
are case sensitive. Theop
must be lower-case.
Here’s an example:
updateDefaultVariation
Updates the default on or off variation of the AI Config.
Parameters
onVariationValue
: (Optional) The value of the variation of the new on variation.offVariationValue
: (Optional) The value of the variation of the new off variation
Here’s an example:
updateFallthroughVariationOrRollout
Updates the default or “fallthrough” rule for the AI Config, which the AI Config serves when a context matches none of the targeting rules. The rule can serve either the variation that variationId
indicates, or a percentage rollout that rolloutWeights
and rolloutBucketBy
indicate.
Parameters
variationId
: ID of a variation.
or
rolloutWeights
: Map ofvariationId
to weight, in thousandths of a percent (0-100000).rolloutBucketBy
: (Optional) Context attribute available in the specifiedrolloutContextKind
.rolloutContextKind
: (Optional) Context kind, defaults touser
Here’s an example that uses a variationId
:
Here’s an example that uses a percentage rollout:
updateOffVariation
Updates the default off variation to variationId
. The AI Config serves the default off variation when the AI Config’s targeting is Off.
Parameters
variationId
: ID of a variation.
Here’s an example:
updateRuleDescription
Updates the description of the targeting rule.
Parameters
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 AI Config.
Here’s an example:
updateRuleTrackEvents
Updates whether or not LaunchDarkly tracks events for the AI Config associated with this rule.
Parameters
ruleId
: The ID of the rule. You can retrieve this by making a GET request for the AI Config.trackEvents
: Whether or not events are tracked.
Here’s an example:
updateRuleVariationOrRollout
Updates what ruleId
serves when its clauses evaluate to true. The rule can serve either the variation that variationId
indicates, or a percent rollout that rolloutWeights
and rolloutBucketBy
indicate.
Parameters
ruleId
: ID of a rule.variationId
: ID of a variation.
or
rolloutWeights
: Map ofvariationId
to weight, in thousandths of a percent (0-100000).rolloutBucketBy
: (Optional) Context attribute available in the specifiedrolloutContextKind
.rolloutContextKind
: (Optional) Context kind, defaults touser
Here’s an example:
updateTrackEvents
Updates whether or not LaunchDarkly tracks events for the AI Config, for all rules.
Parameters
trackEvents
: Whether or not events are tracked.
Here’s an example:
updateTrackEventsFallthrough
Updates whether or not LaunchDarkly tracks events for the AI Config, for the default rule.
Parameters
trackEvents
: Whether or not events are tracked.
Here’s an example: