Updates a feature flag definition for a specific environment.
This API call allows to update any field of a split using JsonPatch.
A few examples below.
Kill / Restore a Split
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 will kill a Split for a particular environment.
Change Traffic Allocation
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 will change the traffic allocation 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 will set the default treatment to "on".
Add an Individually Targeted Key (i.e., user) to a treatment with no keys
The following example will add 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 will add 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 will remove 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 will add 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 will remove the second individually targeted segment for the first treatment.
Rename a Treatment
Given the Split 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 Split 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 will add the "In Segment" rule as the first rule of the Split.
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 will remove the second rule of the Split.
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