Create Segment
Create a custom user segment based on filter rules. Available on all plans, limited by your plan’s maxCustomSegments quota.
After creation, segment membership is computed asynchronously. The segment will be available immediately but member counts may take a few moments to populate.
curl --request POST \
--url https://www.greenflash.ai/api/v1/segments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "High-Intent Enterprise Users",
"description": "Users with high commercial intent from the enterprise plan",
"icon": "Users",
"filters": {
"rules": [
{
"type": "analysis",
"field": "commercialIntent",
"operator": "gte",
"value": 0.6
},
{
"type": "property",
"key": "plan",
"operator": "eq",
"value": "enterprise"
}
]
}
}
'import os
from greenflash import Greenflash
client = Greenflash(
api_key=os.environ.get("GREENFLASH_API_KEY"), # This is the default and can be omitted
)
create_segment_response = client.segments.create(
filters={
"rules": [{
"type": "analysis",
"field": "commercialIntent",
"operator": "gte",
"value": 0.6,
}, {
"type": "property",
"key": "plan",
"operator": "eq",
"value": "enterprise",
}]
},
description="Users with high commercial intent from the enterprise plan",
icon="Users",
name="High-Intent Enterprise Users",
)
print(create_segment_response.id)import Greenflash from 'greenflash';
const client = new Greenflash({
apiKey: process.env['GREENFLASH_API_KEY'], // This is the default and can be omitted
});
const createSegmentResponse = await client.segments.create({
filters: {
rules: [
{
type: 'analysis',
field: 'commercialIntent',
operator: 'gte',
value: 0.6,
},
{
type: 'property',
key: 'plan',
operator: 'eq',
value: 'enterprise',
},
],
},
description: 'Users with high commercial intent from the enterprise plan',
icon: 'Users',
name: 'High-Intent Enterprise Users',
});
console.log(createSegmentResponse.id);package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.greenflash.ai/api/v1/segments"
payload := strings.NewReader("{\n \"name\": \"High-Intent Enterprise Users\",\n \"description\": \"Users with high commercial intent from the enterprise plan\",\n \"icon\": \"Users\",\n \"filters\": {\n \"rules\": [\n {\n \"type\": \"analysis\",\n \"field\": \"commercialIntent\",\n \"operator\": \"gte\",\n \"value\": 0.6\n },\n {\n \"type\": \"property\",\n \"key\": \"plan\",\n \"operator\": \"eq\",\n \"value\": \"enterprise\"\n }\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://www.greenflash.ai/api/v1/segments")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"High-Intent Enterprise Users\",\n \"description\": \"Users with high commercial intent from the enterprise plan\",\n \"icon\": \"Users\",\n \"filters\": {\n \"rules\": [\n {\n \"type\": \"analysis\",\n \"field\": \"commercialIntent\",\n \"operator\": \"gte\",\n \"value\": 0.6\n },\n {\n \"type\": \"property\",\n \"key\": \"plan\",\n \"operator\": \"eq\",\n \"value\": \"enterprise\"\n }\n ]\n }\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.greenflash.ai/api/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' => 'High-Intent Enterprise Users',
'description' => 'Users with high commercial intent from the enterprise plan',
'icon' => 'Users',
'filters' => [
'rules' => [
[
'type' => 'analysis',
'field' => 'commercialIntent',
'operator' => 'gte',
'value' => 0.6
],
[
'type' => 'property',
'key' => 'plan',
'operator' => 'eq',
'value' => 'enterprise'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"id": "423e4567-e89b-12d3-a456-426614174003",
"name": "High-Intent Enterprise Users",
"type": "custom",
"description": "Users with high commercial intent from the enterprise plan",
"icon": "Users",
"filters": {
"rules": [
{
"type": "analysis",
"field": "commercialIntent",
"operator": "gte",
"value": 0.6
},
{
"type": "property",
"key": "plan",
"operator": "eq",
"value": "enterprise"
}
]
},
"createdAt": "2026-03-25T14:30:00.000Z",
"updatedAt": "2026-03-25T14:30:00.000Z"
}{
"success": false,
"error": "Validation error: filters.rules must contain at least 1 element(s)"
}{
"success": false,
"error": "Your plan allows up to 5 custom segments (currently using 5). Please upgrade to create more, or contact [email protected]."
}{
"success": true,
"error": "<string>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Filter configuration defining segment membership.
Show child attributes
Show child attributes
Segment name. If omitted, an auto-generated name will be assigned.
255A description of the segment purpose.
Icon identifier for the segment (e.g. "Users", "Tag").
50Response
Segment created successfully
The created segment ID.
The segment name.
Always "custom" for API-created segments.
custom Segment description.
Icon identifier.
The filter configuration.
Show child attributes
Show child attributes
When the segment was created.
When the segment was last updated.
Was this page helpful?
curl --request POST \
--url https://www.greenflash.ai/api/v1/segments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "High-Intent Enterprise Users",
"description": "Users with high commercial intent from the enterprise plan",
"icon": "Users",
"filters": {
"rules": [
{
"type": "analysis",
"field": "commercialIntent",
"operator": "gte",
"value": 0.6
},
{
"type": "property",
"key": "plan",
"operator": "eq",
"value": "enterprise"
}
]
}
}
'import os
from greenflash import Greenflash
client = Greenflash(
api_key=os.environ.get("GREENFLASH_API_KEY"), # This is the default and can be omitted
)
create_segment_response = client.segments.create(
filters={
"rules": [{
"type": "analysis",
"field": "commercialIntent",
"operator": "gte",
"value": 0.6,
}, {
"type": "property",
"key": "plan",
"operator": "eq",
"value": "enterprise",
}]
},
description="Users with high commercial intent from the enterprise plan",
icon="Users",
name="High-Intent Enterprise Users",
)
print(create_segment_response.id)import Greenflash from 'greenflash';
const client = new Greenflash({
apiKey: process.env['GREENFLASH_API_KEY'], // This is the default and can be omitted
});
const createSegmentResponse = await client.segments.create({
filters: {
rules: [
{
type: 'analysis',
field: 'commercialIntent',
operator: 'gte',
value: 0.6,
},
{
type: 'property',
key: 'plan',
operator: 'eq',
value: 'enterprise',
},
],
},
description: 'Users with high commercial intent from the enterprise plan',
icon: 'Users',
name: 'High-Intent Enterprise Users',
});
console.log(createSegmentResponse.id);package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.greenflash.ai/api/v1/segments"
payload := strings.NewReader("{\n \"name\": \"High-Intent Enterprise Users\",\n \"description\": \"Users with high commercial intent from the enterprise plan\",\n \"icon\": \"Users\",\n \"filters\": {\n \"rules\": [\n {\n \"type\": \"analysis\",\n \"field\": \"commercialIntent\",\n \"operator\": \"gte\",\n \"value\": 0.6\n },\n {\n \"type\": \"property\",\n \"key\": \"plan\",\n \"operator\": \"eq\",\n \"value\": \"enterprise\"\n }\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://www.greenflash.ai/api/v1/segments")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"High-Intent Enterprise Users\",\n \"description\": \"Users with high commercial intent from the enterprise plan\",\n \"icon\": \"Users\",\n \"filters\": {\n \"rules\": [\n {\n \"type\": \"analysis\",\n \"field\": \"commercialIntent\",\n \"operator\": \"gte\",\n \"value\": 0.6\n },\n {\n \"type\": \"property\",\n \"key\": \"plan\",\n \"operator\": \"eq\",\n \"value\": \"enterprise\"\n }\n ]\n }\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.greenflash.ai/api/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' => 'High-Intent Enterprise Users',
'description' => 'Users with high commercial intent from the enterprise plan',
'icon' => 'Users',
'filters' => [
'rules' => [
[
'type' => 'analysis',
'field' => 'commercialIntent',
'operator' => 'gte',
'value' => 0.6
],
[
'type' => 'property',
'key' => 'plan',
'operator' => 'eq',
'value' => 'enterprise'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"id": "423e4567-e89b-12d3-a456-426614174003",
"name": "High-Intent Enterprise Users",
"type": "custom",
"description": "Users with high commercial intent from the enterprise plan",
"icon": "Users",
"filters": {
"rules": [
{
"type": "analysis",
"field": "commercialIntent",
"operator": "gte",
"value": 0.6
},
{
"type": "property",
"key": "plan",
"operator": "eq",
"value": "enterprise"
}
]
},
"createdAt": "2026-03-25T14:30:00.000Z",
"updatedAt": "2026-03-25T14:30:00.000Z"
}{
"success": false,
"error": "Validation error: filters.rules must contain at least 1 element(s)"
}{
"success": false,
"error": "Your plan allows up to 5 custom segments (currently using 5). Please upgrade to create more, or contact [email protected]."
}{
"success": true,
"error": "<string>"
}
