Zum Hauptinhalt springen

Ziel

Dieser Leitfaden erklärt, wie Sie den Lebenszyklus eines Feature Flags mithilfe der Automation API verwalten. Konfigurieren Sie das erste Flag, indem Sie die folgenden Schritte ausführen:
  1. Ein Feature Flag erstellen mit dem Create a new feature flag-Endpoint.
  2. Eine Rollout-Regel hinzufügen zur Entwicklungsumgebung mit dem Update a feature flag configuration-Endpoint.
  3. Die Rollout-Regel aktualisieren mit dem Update a single rule by ID-Endpoint.

Voraussetzungen

Vorbedingungen

Bevor Sie die Automation API verwenden, stellen Sie sicher, dass die folgenden Informationen verfügbar sind:

Access Token

Die Automation API erfordert ein Access Token. Beziehen Sie ein Token, indem Sie den Anweisungen unter Access Token abrufen folgen.

siteCode

Finden Sie den siteCode, indem Sie in der unteren linken Ecke zu Admin > Projekte navigieren.
SiteID

1. Ein Feature Flag erstellen

Erstellen Sie beispielsweise ein Feature Flag namens test_feature_flag_post mit der Variablen test_variable. Da diese Anfrage keine environmentConfigurations angibt, generiert das System automatisch Konfigurationen für die Umgebungen development, staging und production. Endpoint:
POST https://api.kameleoon.com/feature-flags
Siehe den Create a new feature flag-Endpoint. Beispiel:
curl -L -X POST 'https://api.kameleoon.com/feature-flags' \
-H 'Content-Type: application/json' \
-H 'Accept: */*' \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
--data-raw '{
  "featureKey": "test_feature_flag_post",
  "name": "test_feature_flag_post",
  "siteCode": "pzllysfw2f",
  "description": "",
  "tags": [],
  "variables": [
    {
      "key": "test_variable",
      "type": "STRING",
      "value": "test"
    }
  ],
  "variations": [
    {
      "name": "On",
      "key": "on",
      "variables": [
        {
          "key": "test_variable",
          "type": "STRING",
          "value": "test"
        }
      ]
    },
    {
      "name": "Off",
      "key": "off",
      "variables": [
        {
          "key": "test_variable",
          "type": "STRING",
          "value": "test"
        }
      ]
    }
  ],
  "attributionWindow": 604800000,
  "archived": false
}
'
Antwort:
{
  "id": 13134,
  "siteCode": "pzllysfw2f",
  "featureKey": "test_feature_flag_post",
  "name": "test_feature_flag_post",
  "description": "",
  "tags": [],
  "variables": [
    { "key": "test_variable", "type": "STRING", "value": "test" }
  ],
  "variations": [
    {
      "name": "On",
      "key": "on",
      "variables": [
        { "key": "test_variable", "type": "STRING", "value": "test" }
      ]
    },
    {
      "name": "Off",
      "key": "off",
      "variables": [
        { "key": "test_variable", "type": "STRING", "value": "test" }
      ]
    }
  ],
  "secondaryGoalIds": [],
  "attributionWindow": 604800000,
  "health": "HEALTHY",
  "dateCreated": "2025-12-17T10:42:14",
  "dateModified": "2025-12-17T10:42:14",
  "dateContentModified": "2025-12-17T10:42:14",
  "environmentConfigurations": [
    {
      "environmentKey": "production",
      "featureEnabled": false,
      "defaultVariationKey": "off",
      "rolloutRules": [],
      "integrations": { "deliveryRules": [], "experimentRules": [] },
      "dateModified": "2025-12-17T10:42:14"
    },
    {
      "environmentKey": "staging",
      "featureEnabled": false,
      "defaultVariationKey": "off",
      "rolloutRules": [],
      "integrations": { "deliveryRules": [], "experimentRules": [] },
      "dateModified": "2025-12-17T10:42:14"
    },
    {
      "environmentKey": "development",
      "featureEnabled": true,
      "defaultVariationKey": "on",
      "rolloutRules": [],
      "integrations": { "deliveryRules": [], "experimentRules": [] },
      "dateModified": "2025-12-17T10:42:14"
    }
  ],
  "createdById": 34255,
  "archived": false
}

2. Das Feature Flag aktualisieren

Aktualisieren Sie das Feature Flag, um eine TARGETED_DELIVERY-Rollout-Regel zur Umgebung development mit der folgenden Konfiguration hinzuzufügen:
Endpoint:
PATCH https://api.kameleoon.com/feature-flags/:siteCode/:featureKey
Siehe den Update a feature flag configuration-Endpoint. Beispiel:
curl -L -X PATCH 'https://api.kameleoon.com/feature-flags/pzllysfw2f/test_feature_flag_post' \
-H 'Content-Type: application/json' \
-H 'Accept: */*' \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
--data-raw '{
  "environmentConfigurations": [
    {
      "environmentKey": "development",
      "featureEnabled": true,
      "defaultVariationKey": "on",
      "rolloutRules": [
        {
          "name": "test rollout rule",
          "type": "TARGETED_DELIVERY",
          "variations": [],
          "trafficAllocations": [
            {
              "variationKey": "on",
              "exposition": 59.0
            }
          ],
          "reallocationTimestamp": null,
          "release": {
            "releaseFrom": "2025-12-11T11:58:01",
            "releaseTo": "2025-12-13T11:58:01",
            "timeZone": "Europe/Paris"
          },
          "state": "ACTIVE",
          "rollbackConditions": [
            {
              "target": "RULE",
              "criteria": "CONVERSION_RATE",
              "comparisonOperator": "GREATER_THAN",
              "matchValue": 20.0,
              "goalId": 400899,
              "visitors": 2,
              "recipients": []
            }
          ],
          "segmentId": 403694,
          "exposition": 59,
          "variationKey": "on"
        }
      ],
      "integrations": {
        "deliveryRules": [],
        "experimentRules": []
      }
    }
  ]
}'
Antwort:
{
  "id": 13134,
  "siteCode": "pzllysfw2f",
  "featureKey": "test_feature_flag_post",
  "name": "test_feature_flag_post",
  "description": "",
  "tags": [],
  "variables": [
    { "key": "test_variable", "type": "STRING", "value": "test" }
  ],
  "variations": [
    {
      "name": "On",
      "key": "on",
      "variables": [
        { "key": "test_variable", "type": "STRING", "value": "test" }
      ]
    },
    {
      "name": "Off",
      "key": "off",
      "variables": [
        { "key": "test_variable", "type": "STRING", "value": "test" }
      ]
    }
  ],
  "secondaryGoalIds": [],
  "attributionWindow": 604800000,
  "health": "HEALTHY",
  "dateCreated": "2025-12-17T10:42:14",
  "dateModified": "2025-12-17T10:42:14",
  "dateContentModified": "2025-12-17T10:42:14",
  "environmentConfigurations": [
    {
      "environmentKey": "production",
      "featureEnabled": false,
      "defaultVariationKey": "off",
      "rolloutRules": [],
      "integrations": { "deliveryRules": [], "experimentRules": [] },
      "dateModified": "2025-12-17T10:42:14"
    },
    {
      "environmentKey": "staging",
      "featureEnabled": false,
      "defaultVariationKey": "off",
      "rolloutRules": [],
      "integrations": { "deliveryRules": [], "experimentRules": [] },
      "dateModified": "2025-12-17T10:42:14"
    },
    {
      "environmentKey": "development",
      "featureEnabled": true,
      "defaultVariationKey": "on",
      "rolloutRules": [
        {
          "id": 20557,
          "name": "test rollout rule",
          "type": "TARGETED_DELIVERY",
          "experimentId": 354972,
          "variations": [],
          "trafficAllocations": [{ "variationKey": "on", "exposition": 59.0 }],
          "reallocationTimestamp": null,
          "release": {
            "releaseFrom": "2025-12-11T11:58:01",
            "releaseTo": "2025-12-13T11:58:01",
            "timeZone": "Europe/Paris"
          },
          "status": "PAUSED",
          "state": "ACTIVE",
          "rollbackConditions": [
            {
              "id": 648,
              "target": "RULE",
              "criteria": "CONVERSION_RATE",
              "comparisonOperator": "GREATER_THAN",
              "matchValue": 20.0,
              "goalId": 400899,
              "visitors": 2,
              "recipients": []
            }
          ],
          "segmentId": 403694,
          "exposition": 59,
          "variationKey": "on"
        }
      ],
      "integrations": { "deliveryRules": [], "experimentRules": [] },
      "dateModified": "2025-12-17T10:42:14"
    }
  ],
  "createdById": 34255,
  "archived": false
}

3. Die Rollout-Regel aktualisieren

Ändern Sie schließlich den matchValue der rollbackConditions auf 25 für die Rollout-Regel mit der ID 20557. Endpoint:
PATCH https://api.kameleoon.com/feature-flags/rules/:ruleId
Siehe den Update a feature flag configuration-Endpoint. Beispiel:
curl -L -X PATCH 'https://api.kameleoon.com/rules/20557' \
-H 'Content-Type: application/json' \
-H 'Accept: */*' \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
--data-raw '{
  "rollbackConditions": [
    {
      "id": 648,
      "target": "RULE",
      "criteria": "CONVERSION_RATE",
      "comparisonOperator": "GREATER_THAN",
      "matchValue": 25.0,
      "goalId": 400899,
      "visitors": 2,
      "recipients": []
    }
  ]
}'
Antwort:
{
  "id": 13134,
  "siteCode": "pzllysfw2f",
  "featureKey": "test_feature_flag_post",
  "name": "test_feature_flag_post",
  "description": "",
  "tags": [],
  "variables": [
    { "key": "test_variable", "type": "STRING", "value": "test" }
  ],
  "variations": [
    {
      "name": "On",
      "key": "on",
      "variables": [
        { "key": "test_variable", "type": "STRING", "value": "test" }
      ]
    },
    {
      "name": "Off",
      "key": "off",
      "variables": [
        { "key": "test_variable", "type": "STRING", "value": "test" }
      ]
    }
  ],
  "secondaryGoalIds": [],
  "attributionWindow": 604800000,
  "health": "HEALTHY",
  "dateCreated": "2025-12-17T10:42:14",
  "dateModified": "2025-12-17T10:42:14",
  "dateContentModified": "2025-12-17T10:42:14",
  "environmentConfigurations": [
    {
      "environmentKey": "production",
      "featureEnabled": false,
      "defaultVariationKey": "off",
      "rolloutRules": [],
      "integrations": { "deliveryRules": [], "experimentRules": [] },
      "dateModified": "2025-12-17T10:42:14"
    },
    {
      "environmentKey": "staging",
      "featureEnabled": false,
      "defaultVariationKey": "off",
      "rolloutRules": [],
      "integrations": { "deliveryRules": [], "experimentRules": [] },
      "dateModified": "2025-12-17T10:42:14"
    },
    {
      "environmentKey": "development",
      "featureEnabled": true,
      "defaultVariationKey": "on",
      "rolloutRules": [
        {
          "id": 20557,
          "name": "test rollout rule",
          "type": "TARGETED_DELIVERY",
          "experimentId": 354972,
          "variations": [],
          "trafficAllocations": [{ "variationKey": "on", "exposition": 59.0 }],
          "reallocationTimestamp": null,
          "release": {
            "releaseFrom": "2025-12-11T11:58:01",
            "releaseTo": "2025-12-13T11:58:01",
            "timeZone": "Europe/Paris"
          },
          "status": "PAUSED",
          "state": "ACTIVE",
          "rollbackConditions": [
            {
              "id": 648,
              "target": "RULE",
              "criteria": "CONVERSION_RATE",
              "comparisonOperator": "GREATER_THAN",
              "matchValue": 25.0,
              "goalId": 400899,
              "visitors": 2,
              "recipients": []
            }
          ],
          "segmentId": 403694,
          "exposition": 59,
          "variationKey": "on"
        }
      ],
      "integrations": { "deliveryRules": [], "experimentRules": [] },
      "dateModified": "2025-12-17T10:42:14"
    }
  ],
  "createdById": 34255,
  "archived": false
}