curl -X POST https://api.growthbook.io/api/v1/segments \
-d '{"name":"Annual Subscribers", "datasource":"ds_123abc", "identifierType":"user_id", "type":"SQL", "query":"SELECT plan FROM subscribers WHERE plan = 'annual'"}' \
-u secret_abc123DEF456:{
"segment": {
"id": "<string>",
"owner": "<unknown>",
"datasourceId": "<string>",
"identifierType": "<string>",
"name": "<string>",
"dateCreated": "<string>",
"dateUpdated": "<string>",
"description": "<string>",
"query": "<string>",
"managedBy": "",
"type": "SQL",
"factTableId": "<string>",
"filters": [
"<string>"
],
"projects": [
"<string>"
]
}
}Documentation Index
Fetch the complete documentation index at: https://growthbook-preview.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
If using Bearer auth, pass the Secret Key as the token:
curl https://api.growthbook.io/api/v1 \
-H "Authorization: Bearer secret_abc123DEF456"Name of the segment
ID of the datasource this segment belongs to
Type of identifier (user, anonymous, etc.)
GrowthBook supports two types of Segments, SQL and FACT. SQL segments are defined by a SQL query, and FACT segments are defined by a fact table and filters.
SQL, FACT Description of the segment
List of project IDs for projects that can access this segment
Where this Segment must be managed from. If not set (empty string), it can be managed from anywhere.
, api SQL query that defines the Segment. This is required for SQL segments.
ID of the fact table this segment belongs to. This is required for FACT segments.
Optional array of fact table filter ids that can further define the Fact Table based Segment.
Success
Show child attributes
curl -X POST https://api.growthbook.io/api/v1/segments \
-d '{"name":"Annual Subscribers", "datasource":"ds_123abc", "identifierType":"user_id", "type":"SQL", "query":"SELECT plan FROM subscribers WHERE plan = 'annual'"}' \
-u secret_abc123DEF456:{
"segment": {
"id": "<string>",
"owner": "<unknown>",
"datasourceId": "<string>",
"identifierType": "<string>",
"name": "<string>",
"dateCreated": "<string>",
"dateUpdated": "<string>",
"description": "<string>",
"query": "<string>",
"managedBy": "",
"type": "SQL",
"factTableId": "<string>",
"filters": [
"<string>"
],
"projects": [
"<string>"
]
}
}