Control Content Visibility Based on User's Favorite Venue with APIs
Overview
This guide provides answers to common questions about managing venue segments and content assignments via the TRIFFT API. It explains how to retrieve segments, identify venue segments, and manage content visibility dynamically based on user preferences.
How Do I Retrieve a List of Segments?
You can retrieve all available segments, including venue segments, using the GET /segments
API endpoint.
API Request
curl -X GET "https://api.trifft.io/segments" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"
Example Response
[
{
"id": "d8bd9e5f-11c4-44af-9a88-93cbfa535f76",
"name": "Odido Aleje Jerozolimskie Warszawa nr 007",
"type": "VENUE",
"slug": "venue-odido-aleje-jerozolimskie-warszawa-nr-007-248159",
"description": "Venue segment for: faf04a6e-a507-4be3-aa5d-64b56f7e7e09",
"members": 0,
"is_global": false,
"is_internal": false,
"is_visible": false,
"created_at": 1740040298,
"updated_at": 1740040298
}
]
API Reference: Get a List of Segments
How Can I Identify Venue Segments?
A venue segment can be identified using the type
field, which should be VENUE
. Additionally, the slug
and name
fields provide clues about the venue's identity.
- Type:
VENUE
– Confirms that the segment is related to a venue. - Slug: Contains the venue name in a standardized format.
- Name: Matches the venue’s official name.
How Do I Get the Initial Sync of Venue Slug and Segment Slug?
To establish the link between venue IDs and segment IDs, follow these steps:
- When a new venue is created, store its venue slug.
- Venue slugs always follow the same format as segment slugs but are prefixed with
venue-
. - To identify the correct segment for a venue, retrieve the list of segments via API.
- Extract the venue's segment by matching the segment’s slug (which should match the venue slug with
venue-
as a prefix). - Alternatively, you can find the relevant segment using the description field, which includes the segment ID reference.
- If venues are created manually, ensure the sync is maintained by periodically fetching the list of venues and matching their slugs with segment slugs.
This method ensures that content can be assigned to the correct venue segment efficiently and consistently.
API Reference: Get a List of Venues
How Do I Assign a Segment to Content?
To associate a segment with content (such as a coupon or deal), use the POST /segments/{segment_id}/content
endpoint. The segment_id
can be either the UUID or the slug of the segment.
API Request
curl -X POST "https://api.trifft.io/segments/{segment_id}/content" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content_type": "coupon",
"content_id": "5a4b8f6e-3b1c-4d5f-9a88-12c7fa535b45"
}'
API Reference: Assign Segment to Content
How Do I Remove a Segment from Content?
To remove a segment from content, use the POST /segments/{segment_id}/remove-content
endpoint. The segment_id
can be either the UUID or the slug.
API Request
curl -X POST "https://api.trifft.io/segments/{segment_id}/remove-content" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content_type": "coupon",
"content_id": "5a4b8f6e-3b1c-4d5f-9a88-12c7fa535b45"
}'
API Reference: Remove Segment from Content
How Do I Dynamically Manage Content Visibility for Users?
- Retrieve the venue segment associated with a user's selected favorite venue.
- Assign relevant content (e.g., a coupon or deal) to the venue segment using
POST /segments/{segment_id}/content
. - If a segment should no longer be linked to a content item, remove it using
POST /segments/{segment_id}/remove-content
. - Users who are part of the venue segment will automatically see assigned content in their app.
Summary of Key Endpoints
Action | Endpoint |
---|---|
Get list of segments | GET /segments |
Get list of venues | GET /venues |
Assign segment to content | POST /segments/{segment_id}/content |
Remove segment from content | POST /segments/{segment_id}/remove-content |
Related API References
- Get a List of Segments
- Get a List of Venues
- Assign Segment to Content
- Remove Segment from Content
- Getting Started with TRIFFT API
This article provides a structured approach to API-based venue segment management. Let me know if you need modifications before we proceed to the administrator guide.
Updated 1 day ago