Create Segment
curl --request POST \
--url https://statsigapi.net/console/v1/segments \
--header 'Content-Type: application/json' \
--header 'STATSIG-API-KEY: <api-key>' \
--data '
{
"name": "<string>",
"id": "<string>",
"description": "<string>",
"idType": "userID",
"tags": [
"<string>"
],
"creatorID": "<string>",
"creatorEmail": "<string>",
"team": "<string>",
"teamID": "<string>",
"rules": [
{
"name": "<string>",
"passPercentage": 50,
"conditions": [
{
"targetValue": [
"<string>"
],
"operator": "<string>",
"field": "<string>",
"customID": "<string>"
}
],
"environments": [
"<string>"
],
"id": "<string>",
"baseID": "<string>",
"returnValue": {}
}
]
}
'import requests
url = "https://statsigapi.net/console/v1/segments"
payload = {
"name": "<string>",
"id": "<string>",
"description": "<string>",
"idType": "userID",
"tags": ["<string>"],
"creatorID": "<string>",
"creatorEmail": "<string>",
"team": "<string>",
"teamID": "<string>",
"rules": [
{
"name": "<string>",
"passPercentage": 50,
"conditions": [
{
"targetValue": ["<string>"],
"operator": "<string>",
"field": "<string>",
"customID": "<string>"
}
],
"environments": ["<string>"],
"id": "<string>",
"baseID": "<string>",
"returnValue": {}
}
]
}
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: '<string>',
id: '<string>',
description: '<string>',
idType: 'userID',
tags: ['<string>'],
creatorID: '<string>',
creatorEmail: '<string>',
team: '<string>',
teamID: '<string>',
rules: [
{
name: '<string>',
passPercentage: 50,
conditions: [
{
targetValue: ['<string>'],
operator: '<string>',
field: '<string>',
customID: '<string>'
}
],
environments: ['<string>'],
id: '<string>',
baseID: '<string>',
returnValue: {}
}
]
})
};
fetch('https://statsigapi.net/console/v1/segments', 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/segments",
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' => '<string>',
'id' => '<string>',
'description' => '<string>',
'idType' => 'userID',
'tags' => [
'<string>'
],
'creatorID' => '<string>',
'creatorEmail' => '<string>',
'team' => '<string>',
'teamID' => '<string>',
'rules' => [
[
'name' => '<string>',
'passPercentage' => 50,
'conditions' => [
[
'targetValue' => [
'<string>'
],
'operator' => '<string>',
'field' => '<string>',
'customID' => '<string>'
]
],
'environments' => [
'<string>'
],
'id' => '<string>',
'baseID' => '<string>',
'returnValue' => [
]
]
]
]),
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/segments"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"id\": \"<string>\",\n \"description\": \"<string>\",\n \"idType\": \"userID\",\n \"tags\": [\n \"<string>\"\n ],\n \"creatorID\": \"<string>\",\n \"creatorEmail\": \"<string>\",\n \"team\": \"<string>\",\n \"teamID\": \"<string>\",\n \"rules\": [\n {\n \"name\": \"<string>\",\n \"passPercentage\": 50,\n \"conditions\": [\n {\n \"targetValue\": [\n \"<string>\"\n ],\n \"operator\": \"<string>\",\n \"field\": \"<string>\",\n \"customID\": \"<string>\"\n }\n ],\n \"environments\": [\n \"<string>\"\n ],\n \"id\": \"<string>\",\n \"baseID\": \"<string>\",\n \"returnValue\": {}\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/segments")
.header("STATSIG-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"id\": \"<string>\",\n \"description\": \"<string>\",\n \"idType\": \"userID\",\n \"tags\": [\n \"<string>\"\n ],\n \"creatorID\": \"<string>\",\n \"creatorEmail\": \"<string>\",\n \"team\": \"<string>\",\n \"teamID\": \"<string>\",\n \"rules\": [\n {\n \"name\": \"<string>\",\n \"passPercentage\": 50,\n \"conditions\": [\n {\n \"targetValue\": [\n \"<string>\"\n ],\n \"operator\": \"<string>\",\n \"field\": \"<string>\",\n \"customID\": \"<string>\"\n }\n ],\n \"environments\": [\n \"<string>\"\n ],\n \"id\": \"<string>\",\n \"baseID\": \"<string>\",\n \"returnValue\": {}\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://statsigapi.net/console/v1/segments")
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\": \"<string>\",\n \"id\": \"<string>\",\n \"description\": \"<string>\",\n \"idType\": \"userID\",\n \"tags\": [\n \"<string>\"\n ],\n \"creatorID\": \"<string>\",\n \"creatorEmail\": \"<string>\",\n \"team\": \"<string>\",\n \"teamID\": \"<string>\",\n \"rules\": [\n {\n \"name\": \"<string>\",\n \"passPercentage\": 50,\n \"conditions\": [\n {\n \"targetValue\": [\n \"<string>\"\n ],\n \"operator\": \"<string>\",\n \"field\": \"<string>\",\n \"customID\": \"<string>\"\n }\n ],\n \"environments\": [\n \"<string>\"\n ],\n \"id\": \"<string>\",\n \"baseID\": \"<string>\",\n \"returnValue\": {}\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"message": "Segment created successfully.",
"data": {
"id": "an_id_list",
"isEnabled": true,
"description": "helpful summary of what this segment is",
"lastModifierName": "CONSOLE API",
"lastModifierID": "ahKwUoaNauHu9AmJPc2",
"type": "id_list",
"count": 0,
"tags": [
"a tag"
]
}
}Segments
Create Segment
POST
/
console
/
v1
/
segments
Create Segment
curl --request POST \
--url https://statsigapi.net/console/v1/segments \
--header 'Content-Type: application/json' \
--header 'STATSIG-API-KEY: <api-key>' \
--data '
{
"name": "<string>",
"id": "<string>",
"description": "<string>",
"idType": "userID",
"tags": [
"<string>"
],
"creatorID": "<string>",
"creatorEmail": "<string>",
"team": "<string>",
"teamID": "<string>",
"rules": [
{
"name": "<string>",
"passPercentage": 50,
"conditions": [
{
"targetValue": [
"<string>"
],
"operator": "<string>",
"field": "<string>",
"customID": "<string>"
}
],
"environments": [
"<string>"
],
"id": "<string>",
"baseID": "<string>",
"returnValue": {}
}
]
}
'import requests
url = "https://statsigapi.net/console/v1/segments"
payload = {
"name": "<string>",
"id": "<string>",
"description": "<string>",
"idType": "userID",
"tags": ["<string>"],
"creatorID": "<string>",
"creatorEmail": "<string>",
"team": "<string>",
"teamID": "<string>",
"rules": [
{
"name": "<string>",
"passPercentage": 50,
"conditions": [
{
"targetValue": ["<string>"],
"operator": "<string>",
"field": "<string>",
"customID": "<string>"
}
],
"environments": ["<string>"],
"id": "<string>",
"baseID": "<string>",
"returnValue": {}
}
]
}
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: '<string>',
id: '<string>',
description: '<string>',
idType: 'userID',
tags: ['<string>'],
creatorID: '<string>',
creatorEmail: '<string>',
team: '<string>',
teamID: '<string>',
rules: [
{
name: '<string>',
passPercentage: 50,
conditions: [
{
targetValue: ['<string>'],
operator: '<string>',
field: '<string>',
customID: '<string>'
}
],
environments: ['<string>'],
id: '<string>',
baseID: '<string>',
returnValue: {}
}
]
})
};
fetch('https://statsigapi.net/console/v1/segments', 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/segments",
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' => '<string>',
'id' => '<string>',
'description' => '<string>',
'idType' => 'userID',
'tags' => [
'<string>'
],
'creatorID' => '<string>',
'creatorEmail' => '<string>',
'team' => '<string>',
'teamID' => '<string>',
'rules' => [
[
'name' => '<string>',
'passPercentage' => 50,
'conditions' => [
[
'targetValue' => [
'<string>'
],
'operator' => '<string>',
'field' => '<string>',
'customID' => '<string>'
]
],
'environments' => [
'<string>'
],
'id' => '<string>',
'baseID' => '<string>',
'returnValue' => [
]
]
]
]),
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/segments"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"id\": \"<string>\",\n \"description\": \"<string>\",\n \"idType\": \"userID\",\n \"tags\": [\n \"<string>\"\n ],\n \"creatorID\": \"<string>\",\n \"creatorEmail\": \"<string>\",\n \"team\": \"<string>\",\n \"teamID\": \"<string>\",\n \"rules\": [\n {\n \"name\": \"<string>\",\n \"passPercentage\": 50,\n \"conditions\": [\n {\n \"targetValue\": [\n \"<string>\"\n ],\n \"operator\": \"<string>\",\n \"field\": \"<string>\",\n \"customID\": \"<string>\"\n }\n ],\n \"environments\": [\n \"<string>\"\n ],\n \"id\": \"<string>\",\n \"baseID\": \"<string>\",\n \"returnValue\": {}\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/segments")
.header("STATSIG-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"id\": \"<string>\",\n \"description\": \"<string>\",\n \"idType\": \"userID\",\n \"tags\": [\n \"<string>\"\n ],\n \"creatorID\": \"<string>\",\n \"creatorEmail\": \"<string>\",\n \"team\": \"<string>\",\n \"teamID\": \"<string>\",\n \"rules\": [\n {\n \"name\": \"<string>\",\n \"passPercentage\": 50,\n \"conditions\": [\n {\n \"targetValue\": [\n \"<string>\"\n ],\n \"operator\": \"<string>\",\n \"field\": \"<string>\",\n \"customID\": \"<string>\"\n }\n ],\n \"environments\": [\n \"<string>\"\n ],\n \"id\": \"<string>\",\n \"baseID\": \"<string>\",\n \"returnValue\": {}\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://statsigapi.net/console/v1/segments")
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\": \"<string>\",\n \"id\": \"<string>\",\n \"description\": \"<string>\",\n \"idType\": \"userID\",\n \"tags\": [\n \"<string>\"\n ],\n \"creatorID\": \"<string>\",\n \"creatorEmail\": \"<string>\",\n \"team\": \"<string>\",\n \"teamID\": \"<string>\",\n \"rules\": [\n {\n \"name\": \"<string>\",\n \"passPercentage\": 50,\n \"conditions\": [\n {\n \"targetValue\": [\n \"<string>\"\n ],\n \"operator\": \"<string>\",\n \"field\": \"<string>\",\n \"customID\": \"<string>\"\n }\n ],\n \"environments\": [\n \"<string>\"\n ],\n \"id\": \"<string>\",\n \"baseID\": \"<string>\",\n \"returnValue\": {}\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"message": "Segment created successfully.",
"data": {
"id": "an_id_list",
"isEnabled": true,
"description": "helpful summary of what this segment is",
"lastModifierName": "CONSOLE API",
"lastModifierID": "ahKwUoaNauHu9AmJPc2",
"type": "id_list",
"count": 0,
"tags": [
"a tag"
]
}
}Authorizations
Headers
Optional header to respect review settings for mutation endpoints.
Body
application/json
name of the segment
Required string length:
3 - 100Pattern:
^[a-zA-Z0-9_\- ]*$type of the segment
Available options:
id_list, rule_based, analysis_list optional id of the segment (defaults to name)
Required string length:
3 - 100Pattern:
^[a-zA-Z0-9_-]*$description of the segment
Maximum string length:
1000type of id
optional tags for categorization
the Statsig ID of the creator of this experiment
the email of the creator of this experiment
optional name identifier for the responsible team (enterprise only)
optional identifier for the responsible team (enterprise only)
Rule Object
Show child attributes
Show child attributes
⌘I

