Update Gate Rules
curl --request PATCH \
--url https://statsigapi.net/console/v1/gates/{id}/rules/{ruleID} \
--header 'Content-Type: application/json' \
--header 'STATSIG-API-KEY: <api-key>' \
--data '
{
"name": "All Conditions",
"id": "38ttpCpzrQFTMKcqFKk02l:10.00:1",
"baseID": "38ttpCpzrQFTMKcqFKk02l",
"passPercentage": 10,
"conditions": [
{
"type": "user_id",
"targetValue": [
"35sClJFs8l0y5uRQhDwUDo"
],
"operator": "any"
}
],
"environments": [
"staging"
]
}
'import requests
url = "https://statsigapi.net/console/v1/gates/{id}/rules/{ruleID}"
payload = {
"name": "All Conditions",
"id": "38ttpCpzrQFTMKcqFKk02l:10.00:1",
"baseID": "38ttpCpzrQFTMKcqFKk02l",
"passPercentage": 10,
"conditions": [
{
"type": "user_id",
"targetValue": ["35sClJFs8l0y5uRQhDwUDo"],
"operator": "any"
}
],
"environments": ["staging"]
}
headers = {
"STATSIG-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'STATSIG-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'All Conditions',
id: '38ttpCpzrQFTMKcqFKk02l:10.00:1',
baseID: '38ttpCpzrQFTMKcqFKk02l',
passPercentage: 10,
conditions: [{type: 'user_id', targetValue: ['35sClJFs8l0y5uRQhDwUDo'], operator: 'any'}],
environments: ['staging']
})
};
fetch('https://statsigapi.net/console/v1/gates/{id}/rules/{ruleID}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://statsigapi.net/console/v1/gates/{id}/rules/{ruleID}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'All Conditions',
'id' => '38ttpCpzrQFTMKcqFKk02l:10.00:1',
'baseID' => '38ttpCpzrQFTMKcqFKk02l',
'passPercentage' => 10,
'conditions' => [
[
'type' => 'user_id',
'targetValue' => [
'35sClJFs8l0y5uRQhDwUDo'
],
'operator' => 'any'
]
],
'environments' => [
'staging'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"STATSIG-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://statsigapi.net/console/v1/gates/{id}/rules/{ruleID}"
payload := strings.NewReader("{\n \"name\": \"All Conditions\",\n \"id\": \"38ttpCpzrQFTMKcqFKk02l:10.00:1\",\n \"baseID\": \"38ttpCpzrQFTMKcqFKk02l\",\n \"passPercentage\": 10,\n \"conditions\": [\n {\n \"type\": \"user_id\",\n \"targetValue\": [\n \"35sClJFs8l0y5uRQhDwUDo\"\n ],\n \"operator\": \"any\"\n }\n ],\n \"environments\": [\n \"staging\"\n ]\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("STATSIG-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://statsigapi.net/console/v1/gates/{id}/rules/{ruleID}")
.header("STATSIG-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"All Conditions\",\n \"id\": \"38ttpCpzrQFTMKcqFKk02l:10.00:1\",\n \"baseID\": \"38ttpCpzrQFTMKcqFKk02l\",\n \"passPercentage\": 10,\n \"conditions\": [\n {\n \"type\": \"user_id\",\n \"targetValue\": [\n \"35sClJFs8l0y5uRQhDwUDo\"\n ],\n \"operator\": \"any\"\n }\n ],\n \"environments\": [\n \"staging\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://statsigapi.net/console/v1/gates/{id}/rules/{ruleID}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["STATSIG-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"All Conditions\",\n \"id\": \"38ttpCpzrQFTMKcqFKk02l:10.00:1\",\n \"baseID\": \"38ttpCpzrQFTMKcqFKk02l\",\n \"passPercentage\": 10,\n \"conditions\": [\n {\n \"type\": \"user_id\",\n \"targetValue\": [\n \"35sClJFs8l0y5uRQhDwUDo\"\n ],\n \"operator\": \"any\"\n }\n ],\n \"environments\": [\n \"staging\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"message": "Gate updated successfully.",
"data": {
"id": "a_gate",
"isEnabled": true,
"description": "helpful summary of what this gate does",
"status": "In Progress",
"lastModifierName": "CONSOLE API",
"lastModifierID": "1vaasdfLlkaujjajiuOSBP2",
"rules": [
{
"name": "All Conditions",
"id": "38ttpCpzrQFTMKcqFKk02l:10.00:1",
"baseID": "38ttpCpzrQFTMKcqFKk02l",
"passPercentage": 10,
"conditions": [
{
"type": "user_id",
"targetValue": [
"35sClJFs8l0y5uRQhDwUDo"
],
"operator": "any"
}
],
"environments": [
"staging"
]
}
],
"tags": [
"* Core"
]
}
}Gates
Update Gate Rules
Update all given rules. It does NOT create or delete if you add more rules and remove rules in the rules object.
PATCH
/
console
/
v1
/
gates
/
{id}
/
rules
/
{ruleID}
Update Gate Rules
curl --request PATCH \
--url https://statsigapi.net/console/v1/gates/{id}/rules/{ruleID} \
--header 'Content-Type: application/json' \
--header 'STATSIG-API-KEY: <api-key>' \
--data '
{
"name": "All Conditions",
"id": "38ttpCpzrQFTMKcqFKk02l:10.00:1",
"baseID": "38ttpCpzrQFTMKcqFKk02l",
"passPercentage": 10,
"conditions": [
{
"type": "user_id",
"targetValue": [
"35sClJFs8l0y5uRQhDwUDo"
],
"operator": "any"
}
],
"environments": [
"staging"
]
}
'import requests
url = "https://statsigapi.net/console/v1/gates/{id}/rules/{ruleID}"
payload = {
"name": "All Conditions",
"id": "38ttpCpzrQFTMKcqFKk02l:10.00:1",
"baseID": "38ttpCpzrQFTMKcqFKk02l",
"passPercentage": 10,
"conditions": [
{
"type": "user_id",
"targetValue": ["35sClJFs8l0y5uRQhDwUDo"],
"operator": "any"
}
],
"environments": ["staging"]
}
headers = {
"STATSIG-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'STATSIG-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'All Conditions',
id: '38ttpCpzrQFTMKcqFKk02l:10.00:1',
baseID: '38ttpCpzrQFTMKcqFKk02l',
passPercentage: 10,
conditions: [{type: 'user_id', targetValue: ['35sClJFs8l0y5uRQhDwUDo'], operator: 'any'}],
environments: ['staging']
})
};
fetch('https://statsigapi.net/console/v1/gates/{id}/rules/{ruleID}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://statsigapi.net/console/v1/gates/{id}/rules/{ruleID}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'All Conditions',
'id' => '38ttpCpzrQFTMKcqFKk02l:10.00:1',
'baseID' => '38ttpCpzrQFTMKcqFKk02l',
'passPercentage' => 10,
'conditions' => [
[
'type' => 'user_id',
'targetValue' => [
'35sClJFs8l0y5uRQhDwUDo'
],
'operator' => 'any'
]
],
'environments' => [
'staging'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"STATSIG-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://statsigapi.net/console/v1/gates/{id}/rules/{ruleID}"
payload := strings.NewReader("{\n \"name\": \"All Conditions\",\n \"id\": \"38ttpCpzrQFTMKcqFKk02l:10.00:1\",\n \"baseID\": \"38ttpCpzrQFTMKcqFKk02l\",\n \"passPercentage\": 10,\n \"conditions\": [\n {\n \"type\": \"user_id\",\n \"targetValue\": [\n \"35sClJFs8l0y5uRQhDwUDo\"\n ],\n \"operator\": \"any\"\n }\n ],\n \"environments\": [\n \"staging\"\n ]\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("STATSIG-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://statsigapi.net/console/v1/gates/{id}/rules/{ruleID}")
.header("STATSIG-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"All Conditions\",\n \"id\": \"38ttpCpzrQFTMKcqFKk02l:10.00:1\",\n \"baseID\": \"38ttpCpzrQFTMKcqFKk02l\",\n \"passPercentage\": 10,\n \"conditions\": [\n {\n \"type\": \"user_id\",\n \"targetValue\": [\n \"35sClJFs8l0y5uRQhDwUDo\"\n ],\n \"operator\": \"any\"\n }\n ],\n \"environments\": [\n \"staging\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://statsigapi.net/console/v1/gates/{id}/rules/{ruleID}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["STATSIG-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"All Conditions\",\n \"id\": \"38ttpCpzrQFTMKcqFKk02l:10.00:1\",\n \"baseID\": \"38ttpCpzrQFTMKcqFKk02l\",\n \"passPercentage\": 10,\n \"conditions\": [\n {\n \"type\": \"user_id\",\n \"targetValue\": [\n \"35sClJFs8l0y5uRQhDwUDo\"\n ],\n \"operator\": \"any\"\n }\n ],\n \"environments\": [\n \"staging\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"message": "Gate updated successfully.",
"data": {
"id": "a_gate",
"isEnabled": true,
"description": "helpful summary of what this gate does",
"status": "In Progress",
"lastModifierName": "CONSOLE API",
"lastModifierID": "1vaasdfLlkaujjajiuOSBP2",
"rules": [
{
"name": "All Conditions",
"id": "38ttpCpzrQFTMKcqFKk02l:10.00:1",
"baseID": "38ttpCpzrQFTMKcqFKk02l",
"passPercentage": 10,
"conditions": [
{
"type": "user_id",
"targetValue": [
"35sClJFs8l0y5uRQhDwUDo"
],
"operator": "any"
}
],
"environments": [
"staging"
]
}
],
"tags": [
"* Core"
]
}
}Authorizations
Headers
Optional header to respect review settings for mutation endpoints.
Body
application/json
The name of this rule.
Of the users that meet the conditions of this rule, what percent should return true.
Required range:
0 <= x <= 100Must be a multiple of 0.01An array of Condition objects.
Show child attributes
Show child attributes
The environments this rule is enabled for.
The Statsig ID of this rule.
The base ID of this rule, i.e. without any added metadata. Will remain the exact same throughout
The return value of the rule.
Show child attributes
Show child attributes
⌘I

