Partial Update Split Definition in Environment

Updates a Split 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 a Key (i.e user) to a treatment whitelist with no keys

The following example will add the key "3" as the first key in the whitelist of 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 a Key (i.e user) to a treatment whitelist with existing keys

The following example will add the key "4" to the whitelist 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 a Key (i.e user) from a treatment whitelist

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 element of the whitelist for the first treatment.

Replace a Key (i.e user) in a treatment whitelist

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 element of the whitelist for the first treatment and sets it to "7".

Add a Segment (i.e employees) to a treatment whitelist

Given a treatment that already has a segment in the whitelist.

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 a Segment (i.e employees) from a treatment whitelist

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 segment from the whitelist 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
Language