Partial update feature flag definition in environment

Updates a feature flag definition for a specific environment.

Access requirements

The Authorization Bearer (Admin API Key authorizing the request) must have one of the following roles and scopes:

Admin API Key roles accepted

  • API_ALL_GRANTED
  • API_FEATURE_FLAG_EDITOR

Admin API Key scopes accepted

  • GLOBAL
  • WORKSPACE
  • ENVIRONMENT

To learn more about Admin API Key roles and scopes, see API keys overview.


This API call allows to update any field of a feature flag using JsonPatch.

A few examples below.

Kill / Restore a feature flag

curl -v -X PATCH \
  -d '[{"op": "replace", "path": "/killed", "value": true}]' \
  -H 'Content-Type:application/json' \
  -H 'Authorization: Bearer ADMIN_API_KEY' \
  https://api.split.io/internal/api/v2/splits/ws/123456/paywall_beta/environments/Production

The example above kills a feature flag for a particular environment.

Change Limit Exposure

curl -v -X PATCH \
  -d '[{"op": "replace", "path": "/trafficAllocation", "value":50}]' \
  -H 'Content-Type:application/json' \
  -H 'Authorization: Bearer ADMIN_API_KEY' \
  https://api.split.io/internal/api/v2/splits/ws/123456/paywall_beta/environments/Production

The example above changes limit exposure to 50.

Change Default Treatment

curl -v -X PATCH \
  -d '[{"op": "replace", "path": "/defaultTreatment", "value": "on"}]' \
  -H 'Content-Type:application/json' \
  -H 'Authorization: Bearer ADMIN_API_KEY' \
  https://api.split.io/internal/api/v2/splits/ws/123456/paywall_beta/environments/Production

The example above sets the default treatment to "on".

Add an Individually Targeted Key (i.e., user) to a treatment with no keys

The following example adds the key "3" as the first individually targeted key in the first treatment.

curl -v -X PATCH \
  -d '[{"op": "add", "path": "/treatments/0/keys", "value": ["3"]}]' \
  -H 'Content-Type:application/json' \
  -H 'Authorization: Bearer ADMIN_API_KEY' \
  https://api.split.io/internal/api/v2/splits/ws/123456/paywall_beta/environments/Production

Add an Individually Targeted Key (i.e., user) to a treatment with existing keys

The following example adds the individually targeted key "4" for the first treatment, given that a treatment that already has one or more keys.

curl -v -X PATCH \
  -d '[{"op": "add", "path": "/treatments/0/keys/-", "value": "4"}]' \
  -H 'Content-Type:application/json' \
  -H 'Authorization: Bearer ADMIN_API_KEY' \
  https://api.split.io/internal/api/v2/splits/ws/123456/paywall_beta/environments/Production

Remove an Individually Targeted Key (i.e., user) from a treatment

curl -v -X PATCH \
  -d '[{"op": "remove", "path": "/treatments/0/keys/2"}]' \
  -H 'Content-Type:application/json' \
  -H 'Authorization: Bearer ADMIN_API_KEY' \
  https://api.split.io/internal/api/v2/splits/ws/123456/paywall_beta/environments/Production

The example above removes the third individually targeted key for the first treatment.

Replace an Individually Targeted Key (i.e., user) in a treatment

curl -v -X PATCH \
  -d '[{"op": "replace", "path": "/treatments/0/keys/0", "value": "7"}]' \
  -H 'Content-Type:application/json' \
  -H 'Authorization: Bearer ADMIN_API_KEY' \
  https://api.split.io/internal/api/v2/splits/ws/123456/paywall_beta/environments/Production

The example above replaces the first individually targeted key for the first treatment and sets it to "7".

Add an Individually Targeted Segment (i.e., employees) to a treatment

Given a treatment that already has an individually targeted segment.

curl -v -X PATCH \
  -d '[{"op": "add", "path": "/treatments/1/segments/-", "value": "beta"}]' \
  -H 'Content-Type:application/json' \
  -H 'Authorization: Bearer ADMIN_API_KEY' \
  https://api.split.io/internal/api/v2/splits/ws/123456/paywall_beta/environments/Production

The example above adds the segment "beta" to the second treatment.

Remove an Individually Targeted Segment (i.e., employees) from a treatment

curl -v -X PATCH \
  -d '[{"op": "remove", "path": "/treatments/0/segments/1"}]' \
  -H 'Content-Type:application/json' \
  -H 'Authorization: Bearer ADMIN_API_KEY' \
  https://api.split.io/internal/api/v2/splits/ws/123456/paywall_beta/environments/Production

The example above removes the second individually targeted segment for the first treatment.

Rename a Treatment

Given the feature flag definition,

{
 "...",
 "treatments" :[{ "name":"on" }, {"name":"off" } ],
 "rules" :[
  {
   "...",
   "buckets": [
    { "treatment":"on","size":80 },
    { "treatment":"off","size":20 }
   ]
  }
 ],
 "defaultRule": [
   { "treatment":"on", "size": 50 },
   { "treatment":"off", "size": 50}
 ],
 "..."
}

To rename "on" to "first_version",

curl -v -X PATCH \
  -d '[{ "op": "replace", "path": "/rules/0/buckets/0/treatment", "value": "first_version" }, { "op": "replace", "path": "/treatments/0/name", "value": "first_version" }, { "op": "replace", "path": "/defaultRule/0/treatment", "value": "first_version" }]' \
  -H 'Content-Type:application/json' \
  -H 'Authorization: Bearer ADMIN_API_KEY' \
  https://api.split.io/internal/api/v2/splits/ws/123456/paywall_beta/environments/Production

Add a Rule

Given the feature flag definition,

{
 "...",
 "treatments" :[{ "name":"on" }, {"name":"off" } ],
 "rules" :[{"..."}],
 "defaultRule": [
   { "treatment":"on", "size": 50 },
   { "treatment":"off", "size": 50}
 ],
 "..."
}

To add a rule,

curl -v -X PATCH \
  -d '[{"op": "add", "path": "/rules/0", "value": {"buckets":[{"treatment":"on","size":50},{"treatment":"off","size":50}],"condition":{"matchers":[{"type":"IN_SEGMENT","string":"employees"}]}}}]' \
  -H 'Content-Type:application/json' \
  -H 'Authorization: Bearer ADMIN_API_KEY' \
  https://api.split.io/internal/api/v2/splits/ws/123456/paywall_beta/environments/Production

The example above adds the "In Segment" rule as the first rule of the feature flag.

Remove a Rule

curl -v -X PATCH \
  -d '[{"op": "remove", "path": "/rules/1"}]' \
  -H 'Content-Type:application/json' \
  -H 'Authorization: Bearer ADMIN_API_KEY' \
  https://api.split.io/internal/api/v2/splits/ws/123456/paywall_beta/environments/Production

The example above removes the second rule of the feature flag.

Change Alert Baseline Treatment

curl -v -X PATCH \
  -d '[{"op": "replace", "path": "/baselineTreatment", "value":"off"}]' \
  -H 'Content-Type:application/json' \
  -H 'Authorization: Bearer ADMIN_API_KEY' \
  https://api.split.io/internal/api/v2/splits/ws/123456/paywall_beta/environments/Production
Language