Skip to content
Docs

Create a segment

PUThttps://api.vercel.com/v1/projects/{projectIdOrName}/feature-flags/segments
Create a new feature flag segment.
https://api.vercel.com/v1/projects/{projectIdOrName}/feature-flags/segments
const response = await fetch('https://api.vercel.com/v1/projects/projectIdOrName/feature-flags/segments?teamId=string&slug=string', {
method: 'PUT',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"slug": "string",
"createdBy": "string",
"label": "string",
"description": "string",
"data": {
"rules": [
{
"id": "icfg_1234567890",
"conditions": [
{
"lhs": {
"type": "value"
},
"cmp": "eq",
"rhs": {
"type": "list/inline",
"items": [
{
"label": "string",
"note": "string",
"value": "123"
}
]
},
"cmpOptions": {
"ignoreCase": "true"
}
}
],
"outcome": {
"type": "value"
}
}
],
"include": "value",
"exclude": "value"
},
"hint": "string"
}),
});
const data = await response.json();
console.log(data);
Response
{
"createdAt": "123",
"createdBy": "string",
"data": {
"exclude": "value",
"include": "value",
"rules": [
{
"conditions": [
{
"cmp": "!contains",
"cmpOptions": {
"ignoreCase": "false"
},
"lhs": {
"type": "segment"
},
"rhs": "string"
}
],
"id": "icfg_1234567890",
"outcome": {
"type": "all"
}
}
]
},
"description": "string",
"hint": "string",
"id": "icfg_1234567890",
"label": "string",
"projectId": "example_id",
"slug": "string",
"typeName": "segment",
"updatedAt": "123",
"usedByFlags": [],
"usedBySegments": []
}
AuthorizationbearerToken

Default authentication mechanism

projectIdOrNamestringRequired
The project id or name
teamIdstringOptional
The Team identifier to perform the request on behalf of.
slugstringOptional
The Team slug to perform the request on behalf of.
application/json
slugstringRequired
createdBystringOptional
The entity who created the segment
labelstringRequired
descriptionstringOptional
dataobjectRequired
The data of the segment
hintstringRequired
201Success
createdAtnumberRequired
createdBystringOptional
dataobjectRequired
descriptionstringOptional
hintstringRequired
idstringRequired
labelstringRequired
projectIdstringRequired
slugstringRequired
typeNamestringRequired
updatedAtnumberRequired
usedByFlagsarrayOptional
usedBySegmentsarrayOptional
400One of the provided values in the request body is invalid. One of the provided values in the request query is invalid.
401The request is not authorized.
402The account is missing a payment so payment method must be updated
403You do not have permission to access this resource.
404Error
409Error
410Error