# Update AI Config targeting

PATCH https://app.launchdarkly.com/api/v2/projects/{projectKey}/ai-configs/{configKey}/targeting
Content-Type: application/json

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](https://launchdarkly.com/docs/api#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 a `kind` 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.

<details>
<summary>Click to expand instructions for <strong>working with targeting and variations</strong> for AI Configs</summary>

#### 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, with `contextKind` (string), `attribute` (string), `op` (string), `negate` (boolean), and `values` (array of strings, numbers, or dates) properties. The `contextKind`, `attribute`, and `values` are case sensitive. The `op` must be lower-case.

Here's an example:

```json
{
  "environmentKey": "environment-key-123abc",
  "instructions": [{
    "kind": "addClauses",
    "ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29",
    "clauses": [{
      "contextKind": "user",
      "attribute": "country",
      "op": "in",
      "negate": false,
      "values": ["USA", "Canada"]
    }]
  }]
}
```

#### 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, with `contextKind` (string), `attribute` (string), `op` (string), `negate` (boolean), and `values` (array of strings, numbers, or dates) properties. The `contextKind`, `attribute`, and `values` are case sensitive. The `op` must be lower-case.
- `beforeRuleId`: (Optional) ID of a rule.
- Either
- `variationId`: ID of a variation.

or

- `rolloutWeights`: (Optional) Map of `variationId` to weight, in thousandths of a percent (0-100000).
- `rolloutBucketBy`: (Optional) Context attribute available in the specified `rolloutContextKind`.
- `rolloutContextKind`: (Optional) Context kind, defaults to `user`

Here's an example that uses a `variationId`:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [{
  "kind": "addRule",
  "variationId": "2f43f67c-3e4e-4945-a18a-26559378ca00",
  "clauses": [{
    "contextKind": "organization",
    "attribute": "located_in",
    "op": "in",
    "negate": false,
    "values": ["Sweden", "Norway"]
  }]
}]
}
```

Here's an example that uses a percentage rollout:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [{
  "kind": "addRule",
  "clauses": [{
    "contextKind": "organization",
    "attribute": "located_in",
    "op": "in",
    "negate": false,
    "values": ["Sweden", "Norway"]
  }],
  "rolloutContextKind": "organization",
  "rolloutWeights": {
    "2f43f67c-3e4e-4945-a18a-26559378ca00": 15000, // serve 15% this variation
    "e5830889-1ec5-4b0c-9cc9-c48790090c43": 85000  // serve 85% this variation
  }
}]
}
```

#### 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 to `user`
- `variationId`: ID of a variation.

Here's an example:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [{
  "kind": "addTargets",
  "values": ["context-key-123abc", "context-key-456def"],
  "variationId": "2f43f67c-3e4e-4945-a18a-26559378ca00"
}]
}
```

#### 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:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [{
  "kind": "addValuesToClause",
  "ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29",
  "clauseId": "10a58772-3121-400f-846b-b8a04e8944ed",
  "values": ["beta_testers"]
}]
}
```

#### 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:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [ { "kind": "clearTargets", "variationId": "2f43f67c-3e4e-4945-a18a-26559378ca00" } ]
}
```

#### 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:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [{
  "kind": "removeClauses",
  "ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29",
  "clauseIds": ["10a58772-3121-400f-846b-b8a04e8944ed", "36a461dc-235e-4b08-97b9-73ce9365873e"]
}]
}
```

#### 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:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [ { "kind": "removeRule", "ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29" } ]
}
```

#### 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 to `user`
- `variationId`: ID of a variation.

Here's an example:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [{
  "kind": "removeTargets",
  "values": ["context-key-123abc", "context-key-456def"],
  "variationId": "2f43f67c-3e4e-4945-a18a-26559378ca00"
}]
}
```

#### 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:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [{
  "kind": "removeValuesFromClause",
  "ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29",
  "clauseId": "10a58772-3121-400f-846b-b8a04e8944ed",
  "values": ["beta_testers"]
}]
}
```

#### 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:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [{
  "kind": "reorderRules",
  "ruleIds": ["a902ef4a-2faf-4eaf-88e1-ecc356708a29", "63c238d1-835d-435e-8f21-c8d5e40b2a3d"]
}]
}
```

#### 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:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [
  {
    "kind": "replaceRules",
    "rules": [
      {
        "variationId": "2f43f67c-3e4e-4945-a18a-26559378ca00",
        "description": "My new rule",
        "clauses": [
          {
            "contextKind": "user",
            "attribute": "segmentMatch",
            "op": "segmentMatch",
            "values": ["test"]
          }
        ]
      }
    ]
  }
]
}
```

#### 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 optional `contextKind` that defaults to `user`, a required `variationId`, and a required list of `values`.

Here's an example:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [
  {
    "kind": "replaceTargets",
    "targets": [
      {
        "contextKind": "user",
        "variationId": "2f43f67c-3e4e-4945-a18a-26559378ca00",
        "values": ["user-key-123abc"]
      },
      {
        "contextKind": "device",
        "variationId": "e5830889-1ec5-4b0c-9cc9-c48790090c43",
        "values": ["device-key-456def"]
      }
    ]
  }
]
}
```

#### 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`: New `clause` object, with `contextKind` (string), `attribute` (string), `op` (string), `negate` (boolean), and `values` (array of strings, numbers, or dates) properties. The `contextKind`, `attribute`, and `values` are case sensitive. The `op` must be lower-case.

Here's an example:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [{
  "kind": "updateClause",
  "ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29",
  "clauseId": "10c7462a-2062-45ba-a8bb-dfb3de0f8af5",
  "clause": {
    "contextKind": "user",
    "attribute": "country",
    "op": "in",
    "negate": false,
    "values": ["Mexico", "Canada"]
  }
}]
}
```

#### 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:

```json
{
"instructions": [ { "kind": "updateDefaultVariation", "OnVariationValue": true, "OffVariationValue": false } ]
}
```

#### 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 of `variationId` to weight, in thousandths of a percent (0-100000).
- `rolloutBucketBy`: (Optional) Context attribute available in the specified `rolloutContextKind`.
- `rolloutContextKind`: (Optional) Context kind, defaults to `user`

Here's an example that uses a `variationId`:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [{
  "kind": "updateFallthroughVariationOrRollout",
  "variationId": "2f43f67c-3e4e-4945-a18a-26559378ca00"
}]
}
```

Here's an example that uses a percentage rollout:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [{
  "kind": "updateFallthroughVariationOrRollout",
  "rolloutContextKind": "user",
  "rolloutWeights": {
    "2f43f67c-3e4e-4945-a18a-26559378ca00": 15000, // serve 15% this variation
    "e5830889-1ec5-4b0c-9cc9-c48790090c43": 85000  // serve 85% this variation
  }
}]
}
```

#### 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:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [ { "kind": "updateOffVariation", "variationId": "2f43f67c-3e4e-4945-a18a-26559378ca00" } ]
}
```

#### 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:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [{
  "kind": "updateRuleDescription",
  "description": "New rule description",
  "ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29"
}]
}
```

#### 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:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [{
  "kind": "updateRuleTrackEvents",
  "ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29",
  "trackEvents": true
}]
}
```

#### 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 of `variationId` to weight, in thousandths of a percent (0-100000).
- `rolloutBucketBy`: (Optional) Context attribute available in the specified `rolloutContextKind`.
- `rolloutContextKind`: (Optional) Context kind, defaults to `user`

Here's an example:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [{
  "kind": "updateRuleVariationOrRollout",
  "ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29",
  "variationId": "2f43f67c-3e4e-4945-a18a-26559378ca00"
}]
}
```

#### 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:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [ { "kind": "updateTrackEvents", "trackEvents": true } ]
}
```

#### 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:

```json
{
"environmentKey": "environment-key-123abc",
"instructions": [ { "kind": "updateTrackEventsFallthrough", "trackEvents": true } ]
}
```
</details>


Reference: https://launchdarkly.com/docs/api/ai-configs/patch-ai-config-targeting

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/projects/{projectKey}/ai-configs/{configKey}/targeting:
    patch:
      operationId: patch-ai-config-targeting
      summary: Update AI Config targeting
      description: >
        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](https://launchdarkly.com/docs/api#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 a `kind`
        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.


        <details>

        <summary>Click to expand instructions for <strong>working with targeting
        and variations</strong> for AI Configs</summary>


        #### 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, with `contextKind` (string),
        `attribute` (string), `op` (string), `negate` (boolean), and `values`
        (array of strings, numbers, or dates) properties. The `contextKind`,
        `attribute`, and `values` are case sensitive. The `op` must be
        lower-case.


        Here's an example:


        ```json

        {
          "environmentKey": "environment-key-123abc",
          "instructions": [{
            "kind": "addClauses",
            "ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29",
            "clauses": [{
              "contextKind": "user",
              "attribute": "country",
              "op": "in",
              "negate": false,
              "values": ["USA", "Canada"]
            }]
          }]
        }

        ```


        #### 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, with `contextKind` (string),
        `attribute` (string), `op` (string), `negate` (boolean), and `values`
        (array of strings, numbers, or dates) properties. The `contextKind`,
        `attribute`, and `values` are case sensitive. The `op` must be
        lower-case.

        - `beforeRuleId`: (Optional) ID of a rule.

        - Either

        - `variationId`: ID of a variation.


        or


        - `rolloutWeights`: (Optional) Map of `variationId` to weight, in
        thousandths of a percent (0-100000).

        - `rolloutBucketBy`: (Optional) Context attribute available in the
        specified `rolloutContextKind`.

        - `rolloutContextKind`: (Optional) Context kind, defaults to `user`


        Here's an example that uses a `variationId`:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [{
          "kind": "addRule",
          "variationId": "2f43f67c-3e4e-4945-a18a-26559378ca00",
          "clauses": [{
            "contextKind": "organization",
            "attribute": "located_in",
            "op": "in",
            "negate": false,
            "values": ["Sweden", "Norway"]
          }]
        }]

        }

        ```


        Here's an example that uses a percentage rollout:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [{
          "kind": "addRule",
          "clauses": [{
            "contextKind": "organization",
            "attribute": "located_in",
            "op": "in",
            "negate": false,
            "values": ["Sweden", "Norway"]
          }],
          "rolloutContextKind": "organization",
          "rolloutWeights": {
            "2f43f67c-3e4e-4945-a18a-26559378ca00": 15000, // serve 15% this variation
            "e5830889-1ec5-4b0c-9cc9-c48790090c43": 85000  // serve 85% this variation
          }
        }]

        }

        ```


        #### 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 to `user`

        - `variationId`: ID of a variation.


        Here's an example:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [{
          "kind": "addTargets",
          "values": ["context-key-123abc", "context-key-456def"],
          "variationId": "2f43f67c-3e4e-4945-a18a-26559378ca00"
        }]

        }

        ```


        #### 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:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [{
          "kind": "addValuesToClause",
          "ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29",
          "clauseId": "10a58772-3121-400f-846b-b8a04e8944ed",
          "values": ["beta_testers"]
        }]

        }

        ```


        #### 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:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [ { "kind": "clearTargets", "variationId":
        "2f43f67c-3e4e-4945-a18a-26559378ca00" } ]

        }

        ```


        #### 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:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [{
          "kind": "removeClauses",
          "ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29",
          "clauseIds": ["10a58772-3121-400f-846b-b8a04e8944ed", "36a461dc-235e-4b08-97b9-73ce9365873e"]
        }]

        }

        ```


        #### 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:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [ { "kind": "removeRule", "ruleId":
        "a902ef4a-2faf-4eaf-88e1-ecc356708a29" } ]

        }

        ```


        #### 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 to `user`

        - `variationId`: ID of a variation.


        Here's an example:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [{
          "kind": "removeTargets",
          "values": ["context-key-123abc", "context-key-456def"],
          "variationId": "2f43f67c-3e4e-4945-a18a-26559378ca00"
        }]

        }

        ```


        #### 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:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [{
          "kind": "removeValuesFromClause",
          "ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29",
          "clauseId": "10a58772-3121-400f-846b-b8a04e8944ed",
          "values": ["beta_testers"]
        }]

        }

        ```


        #### 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:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [{
          "kind": "reorderRules",
          "ruleIds": ["a902ef4a-2faf-4eaf-88e1-ecc356708a29", "63c238d1-835d-435e-8f21-c8d5e40b2a3d"]
        }]

        }

        ```


        #### 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:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [
          {
            "kind": "replaceRules",
            "rules": [
              {
                "variationId": "2f43f67c-3e4e-4945-a18a-26559378ca00",
                "description": "My new rule",
                "clauses": [
                  {
                    "contextKind": "user",
                    "attribute": "segmentMatch",
                    "op": "segmentMatch",
                    "values": ["test"]
                  }
                ]
              }
            ]
          }
        ]

        }

        ```


        #### 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 optional `contextKind` that defaults to `user`, a required
        `variationId`, and a required list of `values`.


        Here's an example:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [
          {
            "kind": "replaceTargets",
            "targets": [
              {
                "contextKind": "user",
                "variationId": "2f43f67c-3e4e-4945-a18a-26559378ca00",
                "values": ["user-key-123abc"]
              },
              {
                "contextKind": "device",
                "variationId": "e5830889-1ec5-4b0c-9cc9-c48790090c43",
                "values": ["device-key-456def"]
              }
            ]
          }
        ]

        }

        ```


        #### 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`: New `clause` object, with `contextKind` (string),
        `attribute` (string), `op` (string), `negate` (boolean), and `values`
        (array of strings, numbers, or dates) properties. The `contextKind`,
        `attribute`, and `values` are case sensitive. The `op` must be
        lower-case.


        Here's an example:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [{
          "kind": "updateClause",
          "ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29",
          "clauseId": "10c7462a-2062-45ba-a8bb-dfb3de0f8af5",
          "clause": {
            "contextKind": "user",
            "attribute": "country",
            "op": "in",
            "negate": false,
            "values": ["Mexico", "Canada"]
          }
        }]

        }

        ```


        #### 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:


        ```json

        {

        "instructions": [ { "kind": "updateDefaultVariation",
        "OnVariationValue": true, "OffVariationValue": false } ]

        }

        ```


        #### 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 of `variationId` to weight, in thousandths of a
        percent (0-100000).

        - `rolloutBucketBy`: (Optional) Context attribute available in the
        specified `rolloutContextKind`.

        - `rolloutContextKind`: (Optional) Context kind, defaults to `user`


        Here's an example that uses a `variationId`:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [{
          "kind": "updateFallthroughVariationOrRollout",
          "variationId": "2f43f67c-3e4e-4945-a18a-26559378ca00"
        }]

        }

        ```


        Here's an example that uses a percentage rollout:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [{
          "kind": "updateFallthroughVariationOrRollout",
          "rolloutContextKind": "user",
          "rolloutWeights": {
            "2f43f67c-3e4e-4945-a18a-26559378ca00": 15000, // serve 15% this variation
            "e5830889-1ec5-4b0c-9cc9-c48790090c43": 85000  // serve 85% this variation
          }
        }]

        }

        ```


        #### 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:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [ { "kind": "updateOffVariation", "variationId":
        "2f43f67c-3e4e-4945-a18a-26559378ca00" } ]

        }

        ```


        #### 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:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [{
          "kind": "updateRuleDescription",
          "description": "New rule description",
          "ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29"
        }]

        }

        ```


        #### 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:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [{
          "kind": "updateRuleTrackEvents",
          "ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29",
          "trackEvents": true
        }]

        }

        ```


        #### 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 of `variationId` to weight, in thousandths of a
        percent (0-100000).

        - `rolloutBucketBy`: (Optional) Context attribute available in the
        specified `rolloutContextKind`.

        - `rolloutContextKind`: (Optional) Context kind, defaults to `user`


        Here's an example:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [{
          "kind": "updateRuleVariationOrRollout",
          "ruleId": "a902ef4a-2faf-4eaf-88e1-ecc356708a29",
          "variationId": "2f43f67c-3e4e-4945-a18a-26559378ca00"
        }]

        }

        ```


        #### 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:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [ { "kind": "updateTrackEvents", "trackEvents": true } ]

        }

        ```


        #### 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:


        ```json

        {

        "environmentKey": "environment-key-123abc",

        "instructions": [ { "kind": "updateTrackEventsFallthrough",
        "trackEvents": true } ]

        }

        ```

        </details>
      tags:
        - subpackage_aiConfigs
      parameters:
        - name: projectKey
          in: path
          required: true
          schema:
            type: string
        - name: configKey
          in: path
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: AI Config targeting updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIConfigTargeting'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      requestBody:
        description: AI Config targeting semantic patch instructions
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AIConfigTargetingPatch'
servers:
  - url: https://app.launchdarkly.com
  - url: https://app.launchdarkly.us
components:
  schemas:
    AIConfigTargetingPatch:
      type: object
      properties:
        comment:
          type: string
        environmentKey:
          type: string
        instructions:
          type: array
          items:
            type: object
            additionalProperties:
              description: Any type
      required:
        - environmentKey
        - instructions
      title: AIConfigTargetingPatch
    AIConfigTargetingDefaults:
      type: object
      properties:
        onVariation:
          type: integer
        offVariation:
          type: integer
      required:
        - onVariation
        - offVariation
      title: AIConfigTargetingDefaults
    AIConfigTargetingEnvironmentTarget:
      type: object
      properties:
        contextKind:
          type: string
        values:
          type: array
          items:
            type: string
        variation:
          type: integer
      required:
        - contextKind
        - values
        - variation
      title: AIConfigTargetingEnvironmentTarget
    AIConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocation:
      type: object
      properties:
        canReshuffle:
          type: boolean
        defaultVariation:
          type: integer
        type:
          type: string
      required:
        - canReshuffle
        - defaultVariation
        - type
      title: AIConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocation
    AIConfigTargetingEnvironmentFallthroughRolloutVariation:
      type: object
      properties:
        _untracked:
          type: boolean
        variation:
          type: integer
        weight:
          type: integer
      required:
        - variation
        - weight
      title: AIConfigTargetingEnvironmentFallthroughRolloutVariation
    AIConfigTargetingEnvironmentFallthroughRollout:
      type: object
      properties:
        bucketBy:
          type: string
        contextKind:
          type: string
        experimentAllocation:
          $ref: >-
            #/components/schemas/AIConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocation
        seed:
          type: integer
        variations:
          type: array
          items:
            $ref: >-
              #/components/schemas/AIConfigTargetingEnvironmentFallthroughRolloutVariation
      required:
        - contextKind
        - variations
      title: AIConfigTargetingEnvironmentFallthroughRollout
    AIConfigTargetingEnvironmentFallthrough:
      type: object
      properties:
        variation:
          type: integer
        rollout:
          $ref: '#/components/schemas/AIConfigTargetingEnvironmentFallthroughRollout'
      title: AIConfigTargetingEnvironmentFallthrough
    AIConfigTargetingEnvironmentRuleClause:
      type: object
      properties:
        attribute:
          type: string
        id:
          type: string
        negate:
          type: boolean
        op:
          type: string
        values:
          type: array
          items:
            description: Any type
      required:
        - attribute
        - id
        - negate
        - op
        - values
      title: AIConfigTargetingEnvironmentRuleClause
    AIConfigTargetingEnvironmentRule:
      type: object
      properties:
        clauses:
          type: array
          items:
            $ref: '#/components/schemas/AIConfigTargetingEnvironmentRuleClause'
        trackEvents:
          type: boolean
      required:
        - clauses
        - trackEvents
      title: AIConfigTargetingEnvironmentRule
    AIConfigTargetingEnvironment:
      type: object
      properties:
        contextTargets:
          type: array
          items:
            $ref: '#/components/schemas/AIConfigTargetingEnvironmentTarget'
        enabled:
          type: boolean
        fallthrough:
          $ref: '#/components/schemas/AIConfigTargetingEnvironmentFallthrough'
        lastModified:
          type: integer
          format: int64
        offVariation:
          type: integer
        rules:
          type: array
          items:
            $ref: '#/components/schemas/AIConfigTargetingEnvironmentRule'
        targets:
          type: array
          items:
            $ref: '#/components/schemas/AIConfigTargetingEnvironmentTarget'
        trackEvents:
          type: boolean
        trackEventsFallthrough:
          type: boolean
        _environmentName:
          type: string
        _version:
          type: integer
      required:
        - contextTargets
        - enabled
        - fallthrough
        - lastModified
        - rules
        - targets
        - trackEvents
        - trackEventsFallthrough
        - _environmentName
        - _version
      title: AIConfigTargetingEnvironment
    AiConfigsMetricListingRepKind:
      type: string
      enum:
        - pageview
        - click
        - custom
      description: The kind of event the metric tracks
      title: AiConfigsMetricListingRepKind
    AiConfigsLink:
      type: object
      properties:
        href:
          type: string
        type:
          type: string
      title: AiConfigsLink
    ActionSpecifier:
      type: string
      title: ActionSpecifier
    AiConfigsAccessDeniedReasonEffect:
      type: string
      enum:
        - allow
        - deny
      description: Whether this statement should allow or deny actions on the resources.
      title: AiConfigsAccessDeniedReasonEffect
    AiConfigsAccessDeniedReason:
      type: object
      properties:
        resources:
          type: array
          items:
            type: string
          description: Resource specifier strings
        notResources:
          type: array
          items:
            type: string
          description: >-
            Targeted resources are the resources NOT in this list. The
            <code>resources</code> and <code>notActions</code> fields must be
            empty to use this field.
        actions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: Actions to perform on a resource
        notActions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: >-
            Targeted actions are the actions NOT in this list. The
            <code>actions</code> and <code>notResources</code> fields must be
            empty to use this field.
        effect:
          $ref: '#/components/schemas/AiConfigsAccessDeniedReasonEffect'
          description: >-
            Whether this statement should allow or deny actions on the
            resources.
        role_name:
          type: string
      required:
        - effect
      title: AiConfigsAccessDeniedReason
    AiConfigsAccessDenied:
      type: object
      properties:
        action:
          type: string
        reason:
          $ref: '#/components/schemas/AiConfigsAccessDeniedReason'
      required:
        - action
        - reason
      title: AiConfigsAccessDenied
    AiConfigsAccessAllowedReasonEffect:
      type: string
      enum:
        - allow
        - deny
      description: Whether this statement should allow or deny actions on the resources.
      title: AiConfigsAccessAllowedReasonEffect
    AiConfigsAccessAllowedReason:
      type: object
      properties:
        resources:
          type: array
          items:
            type: string
          description: Resource specifier strings
        notResources:
          type: array
          items:
            type: string
          description: >-
            Targeted resources are the resources NOT in this list. The
            <code>resources</code> and <code>notActions</code> fields must be
            empty to use this field.
        actions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: Actions to perform on a resource
        notActions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: >-
            Targeted actions are the actions NOT in this list. The
            <code>actions</code> and <code>notResources</code> fields must be
            empty to use this field.
        effect:
          $ref: '#/components/schemas/AiConfigsAccessAllowedReasonEffect'
          description: >-
            Whether this statement should allow or deny actions on the
            resources.
        role_name:
          type: string
      required:
        - effect
      title: AiConfigsAccessAllowedReason
    AiConfigsAccessAllowedRep:
      type: object
      properties:
        action:
          type: string
        reason:
          $ref: '#/components/schemas/AiConfigsAccessAllowedReason'
      required:
        - action
        - reason
      title: AiConfigsAccessAllowedRep
    AiConfigsAccess:
      type: object
      properties:
        denied:
          type: array
          items:
            $ref: '#/components/schemas/AiConfigsAccessDenied'
        allowed:
          type: array
          items:
            $ref: '#/components/schemas/AiConfigsAccessAllowedRep'
      required:
        - denied
        - allowed
      title: AiConfigsAccess
    AiConfigsModification:
      type: object
      properties:
        date:
          type: string
          format: date-time
      title: AiConfigsModification
    AiConfigsMemberSummary:
      type: object
      properties:
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/AiConfigsLink'
          description: The location and content type of related resources
        _id:
          type: string
          description: The member's ID
        firstName:
          type: string
          description: The member's first name
        lastName:
          type: string
          description: The member's last name
        role:
          type: string
          description: >-
            The member's base role. If the member has no additional roles, this
            role will be in effect.
        email:
          type: string
          description: The member's email address
      required:
        - _links
        - _id
        - role
        - email
      title: AiConfigsMemberSummary
    AiConfigsMetricListingRepSuccessCriteria:
      type: string
      enum:
        - HigherThanBaseline
        - LowerThanBaseline
      description: For custom metrics, the success criteria
      title: AiConfigsMetricListingRepSuccessCriteria
    AiConfigsFilterType:
      type: string
      enum:
        - group
        - contextAttribute
        - eventProperty
      description: Filter type. One of [contextAttribute, eventProperty, group]
      title: AiConfigsFilterType
    AiConfigsFilter:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/AiConfigsFilterType'
          description: Filter type. One of [contextAttribute, eventProperty, group]
        attribute:
          type: string
          description: >-
            If not a group node, the context attribute name or event property
            name to filter on
        op:
          type: string
        values:
          type: array
          items:
            description: Any type
          description: The context attribute / event property values or group member nodes
        contextKind:
          type: string
          description: For context attribute filters, the context kind.
        negate:
          type: boolean
          description: >-
            If set, then take the inverse of the operator. 'in' becomes 'not
            in'.
      required:
        - type
        - op
        - values
        - negate
      title: AiConfigsFilter
    AiConfigsMetricListingRepUnitAggregationType:
      type: string
      enum:
        - average
        - sum
      description: The method by which multiple unit event values are aggregated
      title: AiConfigsMetricListingRepUnitAggregationType
    AiConfigsMetricListingRepAnalysisType:
      type: string
      enum:
        - mean
        - percentile
      description: The method for analyzing metric events
      title: AiConfigsMetricListingRepAnalysisType
    AiConfigsMetricEventDefaultRep:
      type: object
      properties:
        disabled:
          type: boolean
          description: >-
            Whether to disable defaulting missing unit events when calculating
            results. Defaults to false
        value:
          type: number
          format: double
          description: >-
            The default value applied to missing unit events. Set to 0 when
            <code>disabled</code> is false. No other values are currently
            supported.
      title: AiConfigsMetricEventDefaultRep
    AiConfigsMetricDataSourceRefRep:
      type: object
      properties:
        key:
          type: string
        environmentKey:
          type: string
        _name:
          type: string
        _integrationKey:
          type: string
      required:
        - key
      title: AiConfigsMetricDataSourceRefRep
    UrlMatcher:
      type: object
      additionalProperties:
        description: Any type
      title: UrlMatcher
    AiConfigsMetricListingRep:
      type: object
      properties:
        experimentCount:
          type: integer
          description: The number of experiments using this metric
        metricGroupCount:
          type: integer
          description: The number of metric groups using this metric
        guardedRolloutCount:
          type: integer
          description: The number of guarded rollouts using this metric
        releasePolicyCount:
          type: integer
          description: The number of release policies using this metric
        activeExperimentCount:
          type: integer
          description: The number of active experiments using this metric
        activeGuardedRolloutCount:
          type: integer
          description: The number of active guarded rollouts using this metric
        _id:
          type: string
          description: The ID of this metric
        _versionId:
          type: string
          description: The version ID of the metric
        _version:
          type: integer
          description: Version of the metric
        key:
          type: string
          description: A unique key to reference the metric
        name:
          type: string
          description: A human-friendly name for the metric
        kind:
          $ref: '#/components/schemas/AiConfigsMetricListingRepKind'
          description: The kind of event the metric tracks
        _attachedFlagCount:
          type: integer
          description: The number of feature flags currently attached to this metric
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/AiConfigsLink'
          description: The location and content type of related resources
        _site:
          $ref: '#/components/schemas/AiConfigsLink'
        _access:
          $ref: '#/components/schemas/AiConfigsAccess'
        tags:
          type: array
          items:
            type: string
          description: Tags for the metric
        _creationDate:
          type: integer
          format: int64
        lastModified:
          $ref: '#/components/schemas/AiConfigsModification'
        maintainerId:
          type: string
          description: The ID of the member who maintains this metric
        _maintainer:
          $ref: '#/components/schemas/AiConfigsMemberSummary'
        description:
          type: string
          description: Description of the metric
        category:
          type: string
          description: The category of the metric
        isNumeric:
          type: boolean
          description: >-
            For custom metrics, whether to track numeric changes in value
            against a baseline (<code>true</code>) or to track a conversion when
            an end user takes an action (<code>false</code>).
        successCriteria:
          $ref: '#/components/schemas/AiConfigsMetricListingRepSuccessCriteria'
          description: For custom metrics, the success criteria
        unit:
          type: string
          description: For numeric custom metrics, the unit of measure
        eventKey:
          type: string
          description: For custom metrics, the event key to use in your code
        randomizationUnits:
          type: array
          items:
            type: string
          description: An array of randomization units allowed for this metric
        filters:
          $ref: '#/components/schemas/AiConfigsFilter'
        unitAggregationType:
          $ref: '#/components/schemas/AiConfigsMetricListingRepUnitAggregationType'
          description: The method by which multiple unit event values are aggregated
        analysisType:
          $ref: '#/components/schemas/AiConfigsMetricListingRepAnalysisType'
          description: The method for analyzing metric events
        percentileValue:
          type: integer
          description: >-
            The percentile for the analysis method. An integer denoting the
            target percentile between 0 and 100. Required when
            <code>analysisType</code> is <code>percentile</code>.
        eventDefault:
          $ref: '#/components/schemas/AiConfigsMetricEventDefaultRep'
        dataSource:
          $ref: '#/components/schemas/AiConfigsMetricDataSourceRefRep'
        lastSeen:
          type: integer
          format: int64
        archived:
          type: boolean
          description: Whether the metric version is archived
        archivedAt:
          type: integer
          format: int64
        selector:
          type: string
          description: For click metrics, the CSS selectors
        urls:
          type: array
          items:
            $ref: '#/components/schemas/UrlMatcher'
        windowStartOffset:
          type: integer
          format: int64
          description: >-
            Not yet implemented - The start of the measurement window, in
            milliseconds relative to the unit's first exposure to a flag
            variation
        windowEndOffset:
          type: integer
          format: int64
          description: >-
            Not yet implemented - The end of the measurement window, in
            milliseconds relative to the unit's first exposure to a flag
            variation
        traceQuery:
          type: string
          description: For trace metrics, the trace query to use for the metric.
        traceValueLocation:
          type: string
          description: >-
            For trace metrics, the location in the trace to use for numeric
            values.
      required:
        - _id
        - _versionId
        - key
        - name
        - kind
        - _links
        - tags
        - _creationDate
        - dataSource
      title: AiConfigsMetricListingRep
    AiConfigsExperimentEnabledPeriodRep:
      type: object
      properties:
        startDate:
          type: integer
          format: int64
        stopDate:
          type: integer
          format: int64
      title: AiConfigsExperimentEnabledPeriodRep
    AiConfigsExperimentEnvironmentSettingRep:
      type: object
      properties:
        startDate:
          type: integer
          format: int64
        stopDate:
          type: integer
          format: int64
        enabledPeriods:
          type: array
          items:
            $ref: '#/components/schemas/AiConfigsExperimentEnabledPeriodRep'
      title: AiConfigsExperimentEnvironmentSettingRep
    AiConfigsLegacyExperimentRep:
      type: object
      properties:
        metricKey:
          type: string
        _metric:
          $ref: '#/components/schemas/AiConfigsMetricListingRep'
        environments:
          type: array
          items:
            type: string
        _environmentSettings:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/AiConfigsExperimentEnvironmentSettingRep'
      title: AiConfigsLegacyExperimentRep
    AiConfigsExperimentInfoRep:
      type: object
      properties:
        baselineIdx:
          type: integer
        items:
          type: array
          items:
            $ref: '#/components/schemas/AiConfigsLegacyExperimentRep'
      required:
        - baselineIdx
        - items
      title: AiConfigsExperimentInfoRep
    AIConfigTargetingVariationBoolean:
      type: boolean
      title: AIConfigTargetingVariationBoolean
    AIConfigTargetingVariationJSON:
      type: object
      properties: {}
      title: AIConfigTargetingVariationJSON
    AIConfigTargetingVariationNumber:
      type: number
      format: double
      title: AIConfigTargetingVariationNumber
    AIConfigTargetingVariationString:
      type: string
      title: AIConfigTargetingVariationString
    AIConfigTargetingVariation_value:
      oneOf:
        - $ref: '#/components/schemas/AIConfigTargetingVariationBoolean'
        - $ref: '#/components/schemas/AIConfigTargetingVariationJSON'
        - $ref: '#/components/schemas/AIConfigTargetingVariationNumber'
        - $ref: '#/components/schemas/AIConfigTargetingVariationString'
      title: AIConfigTargetingVariation_value
    AIConfigTargetingVariation:
      type: object
      properties:
        _id:
          type: string
        description:
          type: string
        name:
          type: string
        value:
          $ref: '#/components/schemas/AIConfigTargetingVariation_value'
      required:
        - _id
        - description
        - name
        - value
      title: AIConfigTargetingVariation
    AIConfigTargeting:
      type: object
      properties:
        createdAt:
          type: integer
          format: int64
          description: Unix timestamp in milliseconds
        defaults:
          $ref: '#/components/schemas/AIConfigTargetingDefaults'
        environments:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/AIConfigTargetingEnvironment'
        experiments:
          $ref: '#/components/schemas/AiConfigsExperimentInfoRep'
        key:
          type: string
        name:
          type: string
        tags:
          type: array
          items:
            type: string
        variations:
          type: array
          items:
            $ref: '#/components/schemas/AIConfigTargetingVariation'
        _version:
          type: integer
      required:
        - createdAt
        - environments
        - experiments
        - key
        - name
        - tags
        - variations
        - _version
      title: AIConfigTargeting
    Error:
      type: object
      properties:
        message:
          type: string
        code:
          type: string
      required:
        - message
        - code
      title: Error
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

```

## SDK Code Examples

```python
import requests

url = "https://app.launchdarkly.com/api/v2/projects/projectKey/ai-configs/configKey/targeting"

payload = {
    "environmentKey": "environmentKey",
    "instructions": [{ "key": "" }, { "key": "" }],
    "comment": "comment"
}
headers = {
    "Authorization": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://app.launchdarkly.com/api/v2/projects/projectKey/ai-configs/configKey/targeting';
const options = {
  method: 'PATCH',
  headers: {Authorization: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"environmentKey":"environmentKey","instructions":[{"key":""},{"key":""}],"comment":"comment"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://app.launchdarkly.com/api/v2/projects/projectKey/ai-configs/configKey/targeting"

	payload := strings.NewReader("{\n  \"environmentKey\": \"environmentKey\",\n  \"instructions\": [\n    {\n      \"key\": \"\"\n    },\n    {\n      \"key\": \"\"\n    }\n  ],\n  \"comment\": \"comment\"\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://app.launchdarkly.com/api/v2/projects/projectKey/ai-configs/configKey/targeting")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"environmentKey\": \"environmentKey\",\n  \"instructions\": [\n    {\n      \"key\": \"\"\n    },\n    {\n      \"key\": \"\"\n    }\n  ],\n  \"comment\": \"comment\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://app.launchdarkly.com/api/v2/projects/projectKey/ai-configs/configKey/targeting")
  .header("Authorization", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"environmentKey\": \"environmentKey\",\n  \"instructions\": [\n    {\n      \"key\": \"\"\n    },\n    {\n      \"key\": \"\"\n    }\n  ],\n  \"comment\": \"comment\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://app.launchdarkly.com/api/v2/projects/projectKey/ai-configs/configKey/targeting', [
  'body' => '{
  "environmentKey": "environmentKey",
  "instructions": [
    {
      "key": ""
    },
    {
      "key": ""
    }
  ],
  "comment": "comment"
}',
  'headers' => [
    'Authorization' => '<apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/projects/projectKey/ai-configs/configKey/targeting");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"environmentKey\": \"environmentKey\",\n  \"instructions\": [\n    {\n      \"key\": \"\"\n    },\n    {\n      \"key\": \"\"\n    }\n  ],\n  \"comment\": \"comment\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "environmentKey": "environmentKey",
  "instructions": [["key": ""], ["key": ""]],
  "comment": "comment"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://app.launchdarkly.com/api/v2/projects/projectKey/ai-configs/configKey/targeting")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```