Segments
Segments allow you to group and filter specific data based on Feedback Query Language (FQL) rules. On this page, we'll dive into the different segment endpoints you can use to manage segments programmatically, including listing, creating, updating, and deleting segments.
The segment model
The segment model contains information about your segments, including their name, FQL rules, and related links. Segments help you filter data for specific teams or use cases.
Properties
- Name
id
- Type
- integer
- Description
Unique identifier for the segment.
- Name
team_id
- Type
- integer
- Description
The unique identifier of the team that owns the segment.
- Name
name
- Type
- string
- Description
The name of the segment.
- Name
description
- Type
- string
- Description
A short description of the segment.
- Name
fql
- Type
- string
- Description
The Feedback Query Language (FQL) rules applied to the segment.
- Name
is_default
- Type
- boolean
- Description
Make this segment as default when they visit the platform for the assigned user.
- Name
editable_by
- Type
- string
- Description
People that can edit this segment. Can be
admin
orassigned
.
- Name
links
- Type
- array
- Description
A list of associated links and relationships.
- Name
created_at
- Type
- timestamp
- Description
Timestamp of when the segment was created.
- Name
updated_at
- Type
- timestamp
- Description
Timestamp of when the segment was last updated.
List all segments
This endpoint allows you to retrieve a paginated list of all your segments. By default, a maximum of ten segments are shown per page.
Optional attributes
- Name
filter
- Type
- string
- Description
Filter segments by name.
- Name
include
- Type
- string
- Description
Include relationships:
links
,links.linkable
.
- Name
page
- Type
- integer
- Description
Number of the page to display.
Request
curl -G https://api.bx.feedier.com/v3/segments \
-H "Authorization: Bearer {token}"
Response
{
"data": [
{
"id": 715,
"team_id": 2,
"name": "Recommended",
"assigned_to": "admin",
"is_default": false,
"fql": "[{\"Form\": {\"$in\": [2986, 2987]}}]",
"created_at": "2024-07-22T12:23:53.000000Z",
"updated_at": "2024-11-22T06:49:39.000000Z"
}
],
"links": {
"first": "https://api.bx.feedier.com/v3/segments?page=1",
"last": null,
"prev": null,
"next": null
}
}
Create a segment
This endpoint allows you to create a new segment.
Required attributes
- Name
team_id
- Type
- integer
- Description
The unique identifier of the team owning the segment.
- Name
name
- Type
- string
- Description
The name of the segment.
- Name
fql
- Type
- json
- Description
The FQL rules to apply for the segment.
Optional attributes
- Name
description
- Type
- string
- Description
A short description of the segment.
- Name
is_default
- Type
- boolean
- Description
Make this segment as default when they visit the platform for the assigned user. By default:
false
- Name
editable_by
- Type
- string
- Description
People that can edit this segment. Can be
admin
orassigned
. By default:admin
Request
curl https://api.bx.feedier.com/v3/segments \
-H "Authorization: Bearer {token}" \
-d team_id=2 \
-d name="Recommended" \
-d fql="[{'Form': {'$in': [2986, 2987]}}]"
Response
{
"id": 716,
"team_id": 2,
"name": "Recommended",
"description": null,
"assigned_to": "admin",
"is_default": false,
"fql": "[{'Form': {'$in': [2986, 2987]}}]",
"created_at": "2024-07-22T12:23:53.000000Z",
"updated_at": "2024-07-22T12:23:53.000000Z"
}
Retrieve a segment
This endpoint allows you to retrieve a specific segment by providing its unique identifier.
Request
curl https://api.bx.feedier.com/v3/segments/715 \
-H "Authorization: Bearer {token}"
Response
{
"id": 715,
"team_id": 2,
"name": "Recommended",
"fql": "[{'Form': {'$in': [2986, 2987]}}]",
"created_at": "2024-07-22T12:23:53.000000Z",
"updated_at": "2024-11-22T06:49:39.000000Z"
}
Update a segment
This endpoint allows you to update an existing segment.
Optional attributes
- Name
name
- Type
- string
- Description
Update the segment name.
- Name
description
- Type
- string
- Description
Update the segment description.
- Name
fql
- Type
- json
- Description
Update the FQL rules.
- Name
is_default
- Type
- boolean
- Description
Make this segment as default when they visit the platform for the assigned user. By default:
false
- Name
editable_by
- Type
- string
- Description
People that can edit this segment. Can be
admin
orassigned
. By default:admin
Request
curl -X PUT https://api.bx.feedier.com/v3/segments/715 \
-H "Authorization: Bearer {token}" \
-d name="Updated Segment"
Response
{
"id": 715,
"name": "Updated Segment",
"updated_at": "2024-11-22T06:49:39.000000Z"
}
Delete a segment
This endpoint allows you to delete a specific segment by its ID.
Request
curl -X DELETE https://api.bx.feedier.com/v3/segments/715 \
-H "Authorization: Bearer {token}"
Attach a link to a segment
This endpoint allows you to attach a link to a segment. A link can reference either a team or a user.
Required attributes
- Name
type
- Type
- string
- Description
The type of link to attach. Allowed values:
team
oruser
.
- Name
id
- Type
- integer
- Description
The unique identifier of the linked team or user.
The validation rules depend on the value of the type
field:
- If
type
isteam
, the ID must be a valid Team entity and belong to the organization. - If
type
isuser
, the ID must a valid User entity.
Request
curl -X POST https://api.bx.feedier.com/v3/segments/715/links \
-H "Authorization: Bearer {token}" \
-d type="team" \
-d id=2
Response
{
"id": 715,
"team_id": 2,
"name": "Recommended",
"fql": "[{\"Form\": {\"$in\": [2986, 2987]}}]",
"links": [
{
"id": 195,
"linkable_type": "App\\Models\\Team",
"linkable_id": 2,
"linkable": {
"id": 2,
"name": "Primary team",
"created_at": "2020-01-28T13:50:20.000000Z",
"updated_at": "2020-01-28T13:50:23.000000Z"
},
"created_at": "2024-11-05T09:52:27.000000Z",
"updated_at": "2024-11-05T09:52:27.000000Z"
}
],
"created_at": "2024-07-22T12:23:53.000000Z",
"updated_at": "2024-11-05T09:52:27.000000Z"
}
Detach a link from a segment
This endpoint allows you to detach a specific link from a segment.
You must provide both:
- The segment ID to identify the parent segment.
- The link ID to specify the link to be removed.
If the link does not belong to the provided segment, a 404 Not Found
error will be returned.
Request
curl -X DELETE https://api.bx.feedier.com/v3/segments/715/links/195 \
-H "Authorization: Bearer {token}"
Response
null