Create Gate
curl --request POST \
--url https://statsigapi.net/console/v1/gates \
--header 'Content-Type: application/json' \
--header 'STATSIG-API-KEY: <api-key>' \
--data '
{
"name": "a_verbose_gate",
"idType": "userID",
"isEnabled": false,
"description": "helpful summary of what this gate does",
"lastModifierName": "CONSOLE API",
"lastModifierID": "5rfuqoxLIYTscuSaaCOlB8",
"targetApps": [
"my_app"
],
"team": "team",
"rules": [
{
"name": "All Conditions",
"passPercentage": 10,
"conditions": [
{
"type": "public"
},
{
"type": "user_id",
"targetValue": [
"111",
"222"
],
"operator": "any"
},
{
"type": "email",
"targetValue": [
"@outlook.com",
"@gmail.com"
],
"operator": "str_contains_any"
},
{
"type": "custom_field",
"targetValue": 31,
"operator": "gt",
"field": "age"
},
{
"type": "app_version",
"targetValue": "1.1.1",
"operator": "version_gt"
},
{
"type": "browser_name",
"targetValue": [
"Android",
"Chrome"
],
"operator": "any"
},
{
"type": "browser_version",
"targetValue": [
"94.0.4606.81",
"94.0.4606.92"
],
"operator": "any"
},
{
"type": "os_name",
"targetValue": [
"Android",
"Windows"
],
"operator": "none"
},
{
"type": "os_version",
"targetValue": "11.0.0",
"operator": "version_lte"
},
{
"type": "country",
"targetValue": [
"NZ",
"US"
],
"operator": "any"
},
{
"type": "passes_gate",
"targetValue": "my_gate_2"
},
{
"type": "fails_gate",
"targetValue": "my_gate_2"
},
{
"type": "time",
"targetValue": 1643070357193,
"operator": "after"
},
{
"type": "environment_tier",
"targetValue": [
"production"
],
"operator": "any"
},
{
"type": "passes_segment",
"targetValue": "growth_org"
},
{
"type": "fails_segment",
"targetValue": "growth_org"
},
{
"type": "ip_address",
"targetValue": [
"1.1.1.1",
"8.8.8.8"
],
"operator": "any"
}
],
"environment": null
}
],
"checksPerHour": 0,
"tags": [],
"monitoringMetrics": [
{
"name": "dau",
"type": "user"
}
]
}
'import requests
url = "https://statsigapi.net/console/v1/gates"
payload = {
"name": "a_verbose_gate",
"idType": "userID",
"isEnabled": False,
"description": "helpful summary of what this gate does",
"lastModifierName": "CONSOLE API",
"lastModifierID": "5rfuqoxLIYTscuSaaCOlB8",
"targetApps": ["my_app"],
"team": "team",
"rules": [
{
"name": "All Conditions",
"passPercentage": 10,
"conditions": [
{ "type": "public" },
{
"type": "user_id",
"targetValue": ["111", "222"],
"operator": "any"
},
{
"type": "email",
"targetValue": ["@outlook.com", "@gmail.com"],
"operator": "str_contains_any"
},
{
"type": "custom_field",
"targetValue": 31,
"operator": "gt",
"field": "age"
},
{
"type": "app_version",
"targetValue": "1.1.1",
"operator": "version_gt"
},
{
"type": "browser_name",
"targetValue": ["Android", "Chrome"],
"operator": "any"
},
{
"type": "browser_version",
"targetValue": ["94.0.4606.81", "94.0.4606.92"],
"operator": "any"
},
{
"type": "os_name",
"targetValue": ["Android", "Windows"],
"operator": "none"
},
{
"type": "os_version",
"targetValue": "11.0.0",
"operator": "version_lte"
},
{
"type": "country",
"targetValue": ["NZ", "US"],
"operator": "any"
},
{
"type": "passes_gate",
"targetValue": "my_gate_2"
},
{
"type": "fails_gate",
"targetValue": "my_gate_2"
},
{
"type": "time",
"targetValue": 1643070357193,
"operator": "after"
},
{
"type": "environment_tier",
"targetValue": ["production"],
"operator": "any"
},
{
"type": "passes_segment",
"targetValue": "growth_org"
},
{
"type": "fails_segment",
"targetValue": "growth_org"
},
{
"type": "ip_address",
"targetValue": ["1.1.1.1", "8.8.8.8"],
"operator": "any"
}
],
"environment": None
}
],
"checksPerHour": 0,
"tags": [],
"monitoringMetrics": [
{
"name": "dau",
"type": "user"
}
]
}
headers = {
"STATSIG-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'STATSIG-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'a_verbose_gate',
idType: 'userID',
isEnabled: false,
description: 'helpful summary of what this gate does',
lastModifierName: 'CONSOLE API',
lastModifierID: '5rfuqoxLIYTscuSaaCOlB8',
targetApps: ['my_app'],
team: 'team',
rules: [
{
name: 'All Conditions',
passPercentage: 10,
conditions: [
{type: 'public'},
{type: 'user_id', targetValue: ['111', '222'], operator: 'any'},
{
type: 'email',
targetValue: ['@outlook.com', '@gmail.com'],
operator: 'str_contains_any'
},
{type: 'custom_field', targetValue: 31, operator: 'gt', field: 'age'},
{type: 'app_version', targetValue: '1.1.1', operator: 'version_gt'},
{type: 'browser_name', targetValue: ['Android', 'Chrome'], operator: 'any'},
{
type: 'browser_version',
targetValue: ['94.0.4606.81', '94.0.4606.92'],
operator: 'any'
},
{type: 'os_name', targetValue: ['Android', 'Windows'], operator: 'none'},
{type: 'os_version', targetValue: '11.0.0', operator: 'version_lte'},
{type: 'country', targetValue: ['NZ', 'US'], operator: 'any'},
{type: 'passes_gate', targetValue: 'my_gate_2'},
{type: 'fails_gate', targetValue: 'my_gate_2'},
{type: 'time', targetValue: 1643070357193, operator: 'after'},
{type: 'environment_tier', targetValue: ['production'], operator: 'any'},
{type: 'passes_segment', targetValue: 'growth_org'},
{type: 'fails_segment', targetValue: 'growth_org'},
{type: 'ip_address', targetValue: ['1.1.1.1', '8.8.8.8'], operator: 'any'}
],
environment: null
}
],
checksPerHour: 0,
tags: [],
monitoringMetrics: [{name: 'dau', type: 'user'}]
})
};
fetch('https://statsigapi.net/console/v1/gates', 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",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'a_verbose_gate',
'idType' => 'userID',
'isEnabled' => false,
'description' => 'helpful summary of what this gate does',
'lastModifierName' => 'CONSOLE API',
'lastModifierID' => '5rfuqoxLIYTscuSaaCOlB8',
'targetApps' => [
'my_app'
],
'team' => 'team',
'rules' => [
[
'name' => 'All Conditions',
'passPercentage' => 10,
'conditions' => [
[
'type' => 'public'
],
[
'type' => 'user_id',
'targetValue' => [
'111',
'222'
],
'operator' => 'any'
],
[
'type' => 'email',
'targetValue' => [
'@outlook.com',
'@gmail.com'
],
'operator' => 'str_contains_any'
],
[
'type' => 'custom_field',
'targetValue' => 31,
'operator' => 'gt',
'field' => 'age'
],
[
'type' => 'app_version',
'targetValue' => '1.1.1',
'operator' => 'version_gt'
],
[
'type' => 'browser_name',
'targetValue' => [
'Android',
'Chrome'
],
'operator' => 'any'
],
[
'type' => 'browser_version',
'targetValue' => [
'94.0.4606.81',
'94.0.4606.92'
],
'operator' => 'any'
],
[
'type' => 'os_name',
'targetValue' => [
'Android',
'Windows'
],
'operator' => 'none'
],
[
'type' => 'os_version',
'targetValue' => '11.0.0',
'operator' => 'version_lte'
],
[
'type' => 'country',
'targetValue' => [
'NZ',
'US'
],
'operator' => 'any'
],
[
'type' => 'passes_gate',
'targetValue' => 'my_gate_2'
],
[
'type' => 'fails_gate',
'targetValue' => 'my_gate_2'
],
[
'type' => 'time',
'targetValue' => 1643070357193,
'operator' => 'after'
],
[
'type' => 'environment_tier',
'targetValue' => [
'production'
],
'operator' => 'any'
],
[
'type' => 'passes_segment',
'targetValue' => 'growth_org'
],
[
'type' => 'fails_segment',
'targetValue' => 'growth_org'
],
[
'type' => 'ip_address',
'targetValue' => [
'1.1.1.1',
'8.8.8.8'
],
'operator' => 'any'
]
],
'environment' => null
]
],
'checksPerHour' => 0,
'tags' => [
],
'monitoringMetrics' => [
[
'name' => 'dau',
'type' => 'user'
]
]
]),
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"
payload := strings.NewReader("{\n \"name\": \"a_verbose_gate\",\n \"idType\": \"userID\",\n \"isEnabled\": false,\n \"description\": \"helpful summary of what this gate does\",\n \"lastModifierName\": \"CONSOLE API\",\n \"lastModifierID\": \"5rfuqoxLIYTscuSaaCOlB8\",\n \"targetApps\": [\n \"my_app\"\n ],\n \"team\": \"team\",\n \"rules\": [\n {\n \"name\": \"All Conditions\",\n \"passPercentage\": 10,\n \"conditions\": [\n {\n \"type\": \"public\"\n },\n {\n \"type\": \"user_id\",\n \"targetValue\": [\n \"111\",\n \"222\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"email\",\n \"targetValue\": [\n \"@outlook.com\",\n \"@gmail.com\"\n ],\n \"operator\": \"str_contains_any\"\n },\n {\n \"type\": \"custom_field\",\n \"targetValue\": 31,\n \"operator\": \"gt\",\n \"field\": \"age\"\n },\n {\n \"type\": \"app_version\",\n \"targetValue\": \"1.1.1\",\n \"operator\": \"version_gt\"\n },\n {\n \"type\": \"browser_name\",\n \"targetValue\": [\n \"Android\",\n \"Chrome\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"browser_version\",\n \"targetValue\": [\n \"94.0.4606.81\",\n \"94.0.4606.92\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"os_name\",\n \"targetValue\": [\n \"Android\",\n \"Windows\"\n ],\n \"operator\": \"none\"\n },\n {\n \"type\": \"os_version\",\n \"targetValue\": \"11.0.0\",\n \"operator\": \"version_lte\"\n },\n {\n \"type\": \"country\",\n \"targetValue\": [\n \"NZ\",\n \"US\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"passes_gate\",\n \"targetValue\": \"my_gate_2\"\n },\n {\n \"type\": \"fails_gate\",\n \"targetValue\": \"my_gate_2\"\n },\n {\n \"type\": \"time\",\n \"targetValue\": 1643070357193,\n \"operator\": \"after\"\n },\n {\n \"type\": \"environment_tier\",\n \"targetValue\": [\n \"production\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"passes_segment\",\n \"targetValue\": \"growth_org\"\n },\n {\n \"type\": \"fails_segment\",\n \"targetValue\": \"growth_org\"\n },\n {\n \"type\": \"ip_address\",\n \"targetValue\": [\n \"1.1.1.1\",\n \"8.8.8.8\"\n ],\n \"operator\": \"any\"\n }\n ],\n \"environment\": null\n }\n ],\n \"checksPerHour\": 0,\n \"tags\": [],\n \"monitoringMetrics\": [\n {\n \"name\": \"dau\",\n \"type\": \"user\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", 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.post("https://statsigapi.net/console/v1/gates")
.header("STATSIG-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"a_verbose_gate\",\n \"idType\": \"userID\",\n \"isEnabled\": false,\n \"description\": \"helpful summary of what this gate does\",\n \"lastModifierName\": \"CONSOLE API\",\n \"lastModifierID\": \"5rfuqoxLIYTscuSaaCOlB8\",\n \"targetApps\": [\n \"my_app\"\n ],\n \"team\": \"team\",\n \"rules\": [\n {\n \"name\": \"All Conditions\",\n \"passPercentage\": 10,\n \"conditions\": [\n {\n \"type\": \"public\"\n },\n {\n \"type\": \"user_id\",\n \"targetValue\": [\n \"111\",\n \"222\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"email\",\n \"targetValue\": [\n \"@outlook.com\",\n \"@gmail.com\"\n ],\n \"operator\": \"str_contains_any\"\n },\n {\n \"type\": \"custom_field\",\n \"targetValue\": 31,\n \"operator\": \"gt\",\n \"field\": \"age\"\n },\n {\n \"type\": \"app_version\",\n \"targetValue\": \"1.1.1\",\n \"operator\": \"version_gt\"\n },\n {\n \"type\": \"browser_name\",\n \"targetValue\": [\n \"Android\",\n \"Chrome\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"browser_version\",\n \"targetValue\": [\n \"94.0.4606.81\",\n \"94.0.4606.92\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"os_name\",\n \"targetValue\": [\n \"Android\",\n \"Windows\"\n ],\n \"operator\": \"none\"\n },\n {\n \"type\": \"os_version\",\n \"targetValue\": \"11.0.0\",\n \"operator\": \"version_lte\"\n },\n {\n \"type\": \"country\",\n \"targetValue\": [\n \"NZ\",\n \"US\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"passes_gate\",\n \"targetValue\": \"my_gate_2\"\n },\n {\n \"type\": \"fails_gate\",\n \"targetValue\": \"my_gate_2\"\n },\n {\n \"type\": \"time\",\n \"targetValue\": 1643070357193,\n \"operator\": \"after\"\n },\n {\n \"type\": \"environment_tier\",\n \"targetValue\": [\n \"production\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"passes_segment\",\n \"targetValue\": \"growth_org\"\n },\n {\n \"type\": \"fails_segment\",\n \"targetValue\": \"growth_org\"\n },\n {\n \"type\": \"ip_address\",\n \"targetValue\": [\n \"1.1.1.1\",\n \"8.8.8.8\"\n ],\n \"operator\": \"any\"\n }\n ],\n \"environment\": null\n }\n ],\n \"checksPerHour\": 0,\n \"tags\": [],\n \"monitoringMetrics\": [\n {\n \"name\": \"dau\",\n \"type\": \"user\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://statsigapi.net/console/v1/gates")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["STATSIG-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"a_verbose_gate\",\n \"idType\": \"userID\",\n \"isEnabled\": false,\n \"description\": \"helpful summary of what this gate does\",\n \"lastModifierName\": \"CONSOLE API\",\n \"lastModifierID\": \"5rfuqoxLIYTscuSaaCOlB8\",\n \"targetApps\": [\n \"my_app\"\n ],\n \"team\": \"team\",\n \"rules\": [\n {\n \"name\": \"All Conditions\",\n \"passPercentage\": 10,\n \"conditions\": [\n {\n \"type\": \"public\"\n },\n {\n \"type\": \"user_id\",\n \"targetValue\": [\n \"111\",\n \"222\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"email\",\n \"targetValue\": [\n \"@outlook.com\",\n \"@gmail.com\"\n ],\n \"operator\": \"str_contains_any\"\n },\n {\n \"type\": \"custom_field\",\n \"targetValue\": 31,\n \"operator\": \"gt\",\n \"field\": \"age\"\n },\n {\n \"type\": \"app_version\",\n \"targetValue\": \"1.1.1\",\n \"operator\": \"version_gt\"\n },\n {\n \"type\": \"browser_name\",\n \"targetValue\": [\n \"Android\",\n \"Chrome\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"browser_version\",\n \"targetValue\": [\n \"94.0.4606.81\",\n \"94.0.4606.92\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"os_name\",\n \"targetValue\": [\n \"Android\",\n \"Windows\"\n ],\n \"operator\": \"none\"\n },\n {\n \"type\": \"os_version\",\n \"targetValue\": \"11.0.0\",\n \"operator\": \"version_lte\"\n },\n {\n \"type\": \"country\",\n \"targetValue\": [\n \"NZ\",\n \"US\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"passes_gate\",\n \"targetValue\": \"my_gate_2\"\n },\n {\n \"type\": \"fails_gate\",\n \"targetValue\": \"my_gate_2\"\n },\n {\n \"type\": \"time\",\n \"targetValue\": 1643070357193,\n \"operator\": \"after\"\n },\n {\n \"type\": \"environment_tier\",\n \"targetValue\": [\n \"production\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"passes_segment\",\n \"targetValue\": \"growth_org\"\n },\n {\n \"type\": \"fails_segment\",\n \"targetValue\": \"growth_org\"\n },\n {\n \"type\": \"ip_address\",\n \"targetValue\": [\n \"1.1.1.1\",\n \"8.8.8.8\"\n ],\n \"operator\": \"any\"\n }\n ],\n \"environment\": null\n }\n ],\n \"checksPerHour\": 0,\n \"tags\": [],\n \"monitoringMetrics\": [\n {\n \"name\": \"dau\",\n \"type\": \"user\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"message": "Gate created successfully.",
"data": {
"id": "a_gate",
"name": "A Gate",
"description": "description",
"idType": "userID",
"lastModifierID": "1vaQaBoLlkauH9iiuOSBP2",
"lastModifiedTime": 1704929983827,
"lastModifierName": "CONSOLE API",
"lastModifierEmail": null,
"creatorID": "1vaQaBoLlkauH9iiuOSBP2",
"createdTime": 1704929979761,
"creatorName": "CONSOLE API",
"creatorEmail": null,
"targetApps": [],
"holdoutIDs": [],
"tags": [],
"isEnabled": true,
"status": "In Progress",
"rules": [],
"checksPerHour": 0,
"type": "PERMANENT",
"typeReason": "NONE",
"team": null,
"reviewSettings": {
"requiredReview": false,
"allowedReviewers": []
},
"measureMetricLifts": true,
"owner": {
"ownerID": "user123",
"ownerName": "CONSOLE API",
"ownerType": "SDK_KEY",
"ownerEmail": ""
},
"monitoringMetrics": [],
"version": 1
}
}Gates
Create Gate
POST
/
console
/
v1
/
gates
Create Gate
curl --request POST \
--url https://statsigapi.net/console/v1/gates \
--header 'Content-Type: application/json' \
--header 'STATSIG-API-KEY: <api-key>' \
--data '
{
"name": "a_verbose_gate",
"idType": "userID",
"isEnabled": false,
"description": "helpful summary of what this gate does",
"lastModifierName": "CONSOLE API",
"lastModifierID": "5rfuqoxLIYTscuSaaCOlB8",
"targetApps": [
"my_app"
],
"team": "team",
"rules": [
{
"name": "All Conditions",
"passPercentage": 10,
"conditions": [
{
"type": "public"
},
{
"type": "user_id",
"targetValue": [
"111",
"222"
],
"operator": "any"
},
{
"type": "email",
"targetValue": [
"@outlook.com",
"@gmail.com"
],
"operator": "str_contains_any"
},
{
"type": "custom_field",
"targetValue": 31,
"operator": "gt",
"field": "age"
},
{
"type": "app_version",
"targetValue": "1.1.1",
"operator": "version_gt"
},
{
"type": "browser_name",
"targetValue": [
"Android",
"Chrome"
],
"operator": "any"
},
{
"type": "browser_version",
"targetValue": [
"94.0.4606.81",
"94.0.4606.92"
],
"operator": "any"
},
{
"type": "os_name",
"targetValue": [
"Android",
"Windows"
],
"operator": "none"
},
{
"type": "os_version",
"targetValue": "11.0.0",
"operator": "version_lte"
},
{
"type": "country",
"targetValue": [
"NZ",
"US"
],
"operator": "any"
},
{
"type": "passes_gate",
"targetValue": "my_gate_2"
},
{
"type": "fails_gate",
"targetValue": "my_gate_2"
},
{
"type": "time",
"targetValue": 1643070357193,
"operator": "after"
},
{
"type": "environment_tier",
"targetValue": [
"production"
],
"operator": "any"
},
{
"type": "passes_segment",
"targetValue": "growth_org"
},
{
"type": "fails_segment",
"targetValue": "growth_org"
},
{
"type": "ip_address",
"targetValue": [
"1.1.1.1",
"8.8.8.8"
],
"operator": "any"
}
],
"environment": null
}
],
"checksPerHour": 0,
"tags": [],
"monitoringMetrics": [
{
"name": "dau",
"type": "user"
}
]
}
'import requests
url = "https://statsigapi.net/console/v1/gates"
payload = {
"name": "a_verbose_gate",
"idType": "userID",
"isEnabled": False,
"description": "helpful summary of what this gate does",
"lastModifierName": "CONSOLE API",
"lastModifierID": "5rfuqoxLIYTscuSaaCOlB8",
"targetApps": ["my_app"],
"team": "team",
"rules": [
{
"name": "All Conditions",
"passPercentage": 10,
"conditions": [
{ "type": "public" },
{
"type": "user_id",
"targetValue": ["111", "222"],
"operator": "any"
},
{
"type": "email",
"targetValue": ["@outlook.com", "@gmail.com"],
"operator": "str_contains_any"
},
{
"type": "custom_field",
"targetValue": 31,
"operator": "gt",
"field": "age"
},
{
"type": "app_version",
"targetValue": "1.1.1",
"operator": "version_gt"
},
{
"type": "browser_name",
"targetValue": ["Android", "Chrome"],
"operator": "any"
},
{
"type": "browser_version",
"targetValue": ["94.0.4606.81", "94.0.4606.92"],
"operator": "any"
},
{
"type": "os_name",
"targetValue": ["Android", "Windows"],
"operator": "none"
},
{
"type": "os_version",
"targetValue": "11.0.0",
"operator": "version_lte"
},
{
"type": "country",
"targetValue": ["NZ", "US"],
"operator": "any"
},
{
"type": "passes_gate",
"targetValue": "my_gate_2"
},
{
"type": "fails_gate",
"targetValue": "my_gate_2"
},
{
"type": "time",
"targetValue": 1643070357193,
"operator": "after"
},
{
"type": "environment_tier",
"targetValue": ["production"],
"operator": "any"
},
{
"type": "passes_segment",
"targetValue": "growth_org"
},
{
"type": "fails_segment",
"targetValue": "growth_org"
},
{
"type": "ip_address",
"targetValue": ["1.1.1.1", "8.8.8.8"],
"operator": "any"
}
],
"environment": None
}
],
"checksPerHour": 0,
"tags": [],
"monitoringMetrics": [
{
"name": "dau",
"type": "user"
}
]
}
headers = {
"STATSIG-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'STATSIG-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'a_verbose_gate',
idType: 'userID',
isEnabled: false,
description: 'helpful summary of what this gate does',
lastModifierName: 'CONSOLE API',
lastModifierID: '5rfuqoxLIYTscuSaaCOlB8',
targetApps: ['my_app'],
team: 'team',
rules: [
{
name: 'All Conditions',
passPercentage: 10,
conditions: [
{type: 'public'},
{type: 'user_id', targetValue: ['111', '222'], operator: 'any'},
{
type: 'email',
targetValue: ['@outlook.com', '@gmail.com'],
operator: 'str_contains_any'
},
{type: 'custom_field', targetValue: 31, operator: 'gt', field: 'age'},
{type: 'app_version', targetValue: '1.1.1', operator: 'version_gt'},
{type: 'browser_name', targetValue: ['Android', 'Chrome'], operator: 'any'},
{
type: 'browser_version',
targetValue: ['94.0.4606.81', '94.0.4606.92'],
operator: 'any'
},
{type: 'os_name', targetValue: ['Android', 'Windows'], operator: 'none'},
{type: 'os_version', targetValue: '11.0.0', operator: 'version_lte'},
{type: 'country', targetValue: ['NZ', 'US'], operator: 'any'},
{type: 'passes_gate', targetValue: 'my_gate_2'},
{type: 'fails_gate', targetValue: 'my_gate_2'},
{type: 'time', targetValue: 1643070357193, operator: 'after'},
{type: 'environment_tier', targetValue: ['production'], operator: 'any'},
{type: 'passes_segment', targetValue: 'growth_org'},
{type: 'fails_segment', targetValue: 'growth_org'},
{type: 'ip_address', targetValue: ['1.1.1.1', '8.8.8.8'], operator: 'any'}
],
environment: null
}
],
checksPerHour: 0,
tags: [],
monitoringMetrics: [{name: 'dau', type: 'user'}]
})
};
fetch('https://statsigapi.net/console/v1/gates', 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",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'a_verbose_gate',
'idType' => 'userID',
'isEnabled' => false,
'description' => 'helpful summary of what this gate does',
'lastModifierName' => 'CONSOLE API',
'lastModifierID' => '5rfuqoxLIYTscuSaaCOlB8',
'targetApps' => [
'my_app'
],
'team' => 'team',
'rules' => [
[
'name' => 'All Conditions',
'passPercentage' => 10,
'conditions' => [
[
'type' => 'public'
],
[
'type' => 'user_id',
'targetValue' => [
'111',
'222'
],
'operator' => 'any'
],
[
'type' => 'email',
'targetValue' => [
'@outlook.com',
'@gmail.com'
],
'operator' => 'str_contains_any'
],
[
'type' => 'custom_field',
'targetValue' => 31,
'operator' => 'gt',
'field' => 'age'
],
[
'type' => 'app_version',
'targetValue' => '1.1.1',
'operator' => 'version_gt'
],
[
'type' => 'browser_name',
'targetValue' => [
'Android',
'Chrome'
],
'operator' => 'any'
],
[
'type' => 'browser_version',
'targetValue' => [
'94.0.4606.81',
'94.0.4606.92'
],
'operator' => 'any'
],
[
'type' => 'os_name',
'targetValue' => [
'Android',
'Windows'
],
'operator' => 'none'
],
[
'type' => 'os_version',
'targetValue' => '11.0.0',
'operator' => 'version_lte'
],
[
'type' => 'country',
'targetValue' => [
'NZ',
'US'
],
'operator' => 'any'
],
[
'type' => 'passes_gate',
'targetValue' => 'my_gate_2'
],
[
'type' => 'fails_gate',
'targetValue' => 'my_gate_2'
],
[
'type' => 'time',
'targetValue' => 1643070357193,
'operator' => 'after'
],
[
'type' => 'environment_tier',
'targetValue' => [
'production'
],
'operator' => 'any'
],
[
'type' => 'passes_segment',
'targetValue' => 'growth_org'
],
[
'type' => 'fails_segment',
'targetValue' => 'growth_org'
],
[
'type' => 'ip_address',
'targetValue' => [
'1.1.1.1',
'8.8.8.8'
],
'operator' => 'any'
]
],
'environment' => null
]
],
'checksPerHour' => 0,
'tags' => [
],
'monitoringMetrics' => [
[
'name' => 'dau',
'type' => 'user'
]
]
]),
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"
payload := strings.NewReader("{\n \"name\": \"a_verbose_gate\",\n \"idType\": \"userID\",\n \"isEnabled\": false,\n \"description\": \"helpful summary of what this gate does\",\n \"lastModifierName\": \"CONSOLE API\",\n \"lastModifierID\": \"5rfuqoxLIYTscuSaaCOlB8\",\n \"targetApps\": [\n \"my_app\"\n ],\n \"team\": \"team\",\n \"rules\": [\n {\n \"name\": \"All Conditions\",\n \"passPercentage\": 10,\n \"conditions\": [\n {\n \"type\": \"public\"\n },\n {\n \"type\": \"user_id\",\n \"targetValue\": [\n \"111\",\n \"222\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"email\",\n \"targetValue\": [\n \"@outlook.com\",\n \"@gmail.com\"\n ],\n \"operator\": \"str_contains_any\"\n },\n {\n \"type\": \"custom_field\",\n \"targetValue\": 31,\n \"operator\": \"gt\",\n \"field\": \"age\"\n },\n {\n \"type\": \"app_version\",\n \"targetValue\": \"1.1.1\",\n \"operator\": \"version_gt\"\n },\n {\n \"type\": \"browser_name\",\n \"targetValue\": [\n \"Android\",\n \"Chrome\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"browser_version\",\n \"targetValue\": [\n \"94.0.4606.81\",\n \"94.0.4606.92\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"os_name\",\n \"targetValue\": [\n \"Android\",\n \"Windows\"\n ],\n \"operator\": \"none\"\n },\n {\n \"type\": \"os_version\",\n \"targetValue\": \"11.0.0\",\n \"operator\": \"version_lte\"\n },\n {\n \"type\": \"country\",\n \"targetValue\": [\n \"NZ\",\n \"US\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"passes_gate\",\n \"targetValue\": \"my_gate_2\"\n },\n {\n \"type\": \"fails_gate\",\n \"targetValue\": \"my_gate_2\"\n },\n {\n \"type\": \"time\",\n \"targetValue\": 1643070357193,\n \"operator\": \"after\"\n },\n {\n \"type\": \"environment_tier\",\n \"targetValue\": [\n \"production\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"passes_segment\",\n \"targetValue\": \"growth_org\"\n },\n {\n \"type\": \"fails_segment\",\n \"targetValue\": \"growth_org\"\n },\n {\n \"type\": \"ip_address\",\n \"targetValue\": [\n \"1.1.1.1\",\n \"8.8.8.8\"\n ],\n \"operator\": \"any\"\n }\n ],\n \"environment\": null\n }\n ],\n \"checksPerHour\": 0,\n \"tags\": [],\n \"monitoringMetrics\": [\n {\n \"name\": \"dau\",\n \"type\": \"user\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", 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.post("https://statsigapi.net/console/v1/gates")
.header("STATSIG-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"a_verbose_gate\",\n \"idType\": \"userID\",\n \"isEnabled\": false,\n \"description\": \"helpful summary of what this gate does\",\n \"lastModifierName\": \"CONSOLE API\",\n \"lastModifierID\": \"5rfuqoxLIYTscuSaaCOlB8\",\n \"targetApps\": [\n \"my_app\"\n ],\n \"team\": \"team\",\n \"rules\": [\n {\n \"name\": \"All Conditions\",\n \"passPercentage\": 10,\n \"conditions\": [\n {\n \"type\": \"public\"\n },\n {\n \"type\": \"user_id\",\n \"targetValue\": [\n \"111\",\n \"222\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"email\",\n \"targetValue\": [\n \"@outlook.com\",\n \"@gmail.com\"\n ],\n \"operator\": \"str_contains_any\"\n },\n {\n \"type\": \"custom_field\",\n \"targetValue\": 31,\n \"operator\": \"gt\",\n \"field\": \"age\"\n },\n {\n \"type\": \"app_version\",\n \"targetValue\": \"1.1.1\",\n \"operator\": \"version_gt\"\n },\n {\n \"type\": \"browser_name\",\n \"targetValue\": [\n \"Android\",\n \"Chrome\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"browser_version\",\n \"targetValue\": [\n \"94.0.4606.81\",\n \"94.0.4606.92\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"os_name\",\n \"targetValue\": [\n \"Android\",\n \"Windows\"\n ],\n \"operator\": \"none\"\n },\n {\n \"type\": \"os_version\",\n \"targetValue\": \"11.0.0\",\n \"operator\": \"version_lte\"\n },\n {\n \"type\": \"country\",\n \"targetValue\": [\n \"NZ\",\n \"US\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"passes_gate\",\n \"targetValue\": \"my_gate_2\"\n },\n {\n \"type\": \"fails_gate\",\n \"targetValue\": \"my_gate_2\"\n },\n {\n \"type\": \"time\",\n \"targetValue\": 1643070357193,\n \"operator\": \"after\"\n },\n {\n \"type\": \"environment_tier\",\n \"targetValue\": [\n \"production\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"passes_segment\",\n \"targetValue\": \"growth_org\"\n },\n {\n \"type\": \"fails_segment\",\n \"targetValue\": \"growth_org\"\n },\n {\n \"type\": \"ip_address\",\n \"targetValue\": [\n \"1.1.1.1\",\n \"8.8.8.8\"\n ],\n \"operator\": \"any\"\n }\n ],\n \"environment\": null\n }\n ],\n \"checksPerHour\": 0,\n \"tags\": [],\n \"monitoringMetrics\": [\n {\n \"name\": \"dau\",\n \"type\": \"user\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://statsigapi.net/console/v1/gates")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["STATSIG-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"a_verbose_gate\",\n \"idType\": \"userID\",\n \"isEnabled\": false,\n \"description\": \"helpful summary of what this gate does\",\n \"lastModifierName\": \"CONSOLE API\",\n \"lastModifierID\": \"5rfuqoxLIYTscuSaaCOlB8\",\n \"targetApps\": [\n \"my_app\"\n ],\n \"team\": \"team\",\n \"rules\": [\n {\n \"name\": \"All Conditions\",\n \"passPercentage\": 10,\n \"conditions\": [\n {\n \"type\": \"public\"\n },\n {\n \"type\": \"user_id\",\n \"targetValue\": [\n \"111\",\n \"222\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"email\",\n \"targetValue\": [\n \"@outlook.com\",\n \"@gmail.com\"\n ],\n \"operator\": \"str_contains_any\"\n },\n {\n \"type\": \"custom_field\",\n \"targetValue\": 31,\n \"operator\": \"gt\",\n \"field\": \"age\"\n },\n {\n \"type\": \"app_version\",\n \"targetValue\": \"1.1.1\",\n \"operator\": \"version_gt\"\n },\n {\n \"type\": \"browser_name\",\n \"targetValue\": [\n \"Android\",\n \"Chrome\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"browser_version\",\n \"targetValue\": [\n \"94.0.4606.81\",\n \"94.0.4606.92\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"os_name\",\n \"targetValue\": [\n \"Android\",\n \"Windows\"\n ],\n \"operator\": \"none\"\n },\n {\n \"type\": \"os_version\",\n \"targetValue\": \"11.0.0\",\n \"operator\": \"version_lte\"\n },\n {\n \"type\": \"country\",\n \"targetValue\": [\n \"NZ\",\n \"US\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"passes_gate\",\n \"targetValue\": \"my_gate_2\"\n },\n {\n \"type\": \"fails_gate\",\n \"targetValue\": \"my_gate_2\"\n },\n {\n \"type\": \"time\",\n \"targetValue\": 1643070357193,\n \"operator\": \"after\"\n },\n {\n \"type\": \"environment_tier\",\n \"targetValue\": [\n \"production\"\n ],\n \"operator\": \"any\"\n },\n {\n \"type\": \"passes_segment\",\n \"targetValue\": \"growth_org\"\n },\n {\n \"type\": \"fails_segment\",\n \"targetValue\": \"growth_org\"\n },\n {\n \"type\": \"ip_address\",\n \"targetValue\": [\n \"1.1.1.1\",\n \"8.8.8.8\"\n ],\n \"operator\": \"any\"\n }\n ],\n \"environment\": null\n }\n ],\n \"checksPerHour\": 0,\n \"tags\": [],\n \"monitoringMetrics\": [\n {\n \"name\": \"dau\",\n \"type\": \"user\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"message": "Gate created successfully.",
"data": {
"id": "a_gate",
"name": "A Gate",
"description": "description",
"idType": "userID",
"lastModifierID": "1vaQaBoLlkauH9iiuOSBP2",
"lastModifiedTime": 1704929983827,
"lastModifierName": "CONSOLE API",
"lastModifierEmail": null,
"creatorID": "1vaQaBoLlkauH9iiuOSBP2",
"createdTime": 1704929979761,
"creatorName": "CONSOLE API",
"creatorEmail": null,
"targetApps": [],
"holdoutIDs": [],
"tags": [],
"isEnabled": true,
"status": "In Progress",
"rules": [],
"checksPerHour": 0,
"type": "PERMANENT",
"typeReason": "NONE",
"team": null,
"reviewSettings": {
"requiredReview": false,
"allowedReviewers": []
},
"measureMetricLifts": true,
"owner": {
"ownerID": "user123",
"ownerName": "CONSOLE API",
"ownerType": "SDK_KEY",
"ownerEmail": ""
},
"monitoringMetrics": [],
"version": 1
}
}Authorizations
Headers
Optional header to respect review settings for mutation endpoints.
Body
application/json
Create a new gate
Maximum string length:
1000Show child attributes
Show child attributes
Available options:
PERMANENT, TEMPORARY Show child attributes
Show child attributes
Whether reviews are required for this gate. If a gate has reviews required due to a project-level or team-level setting, setting this will have no effect.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Required string length:
3 - 100Pattern:
^[a-zA-Z0-9_\-. ]*$Required string length:
3 - 100Pattern:
^[a-zA-Z0-9_\-.]*$⌘I

