A materialized segment is a segment that loads its list of units from your BigQuery instance using a SQL query.
Materialized segments are only available for BigQuery.
Create a Materialized Segment
To create a materialized segment:
curl -X POST "https://api.confidence.dev/v1/materializedSegments?materializationId=my-mat-segment" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"materializedSegment": {
"displayName": "My Materialized Segment"
}
}'
Create a Load Job
After creating the segment, create a load job to populate it with data from your SQL query:
curl -X POST "https://api.confidence.dev/v1/materializedSegments/my-mat-segment/loadJobs" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"materializedSegmentJob": {
"entityIdColumn": "user_id",
"sql": "SELECT user_id FROM your_dataset.your_table WHERE your_criteria"
}
}'
The entityIdColumn specifies which column in your query results contains the entity IDs to include in the segment.
Get a Materialized Segment
To retrieve a materialized segment’s configuration:
curl -X GET "https://api.confidence.dev/v1/materializedSegments/my-mat-segment" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
List Load Jobs
To see the load jobs for a materialized segment:
curl -X GET "https://api.confidence.dev/v1/materializedSegments/my-mat-segment/loadJobs" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Delete a Materialized Segment
To delete a materialized segment:
curl -X DELETE "https://api.confidence.dev/v1/materializedSegments/my-mat-segment" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Next Steps
After creating materialized segments:
- Use the segment in flag rules to target specific users
- Set up coordination to make segments mutually exclusive