Overview
API-triggered campaigns let you configure message templates and targeting rules in the Clix console, then trigger delivery from your backend via API. This approach separates campaign logic from your application code, making it easier for non-technical team members to manage messaging while developers maintain simple API calls. See Campaign Types for a comparison with scheduled and event-triggered campaigns.When to Use
API-triggered campaigns work well when you need:- Transactional notifications: Order confirmations, password resets, payment alerts
- Workflow notifications: Task assignments, approval requests, status updates
- System alerts: Moderation queues, support tickets, server events
- Programmatic sends: Any scenario where your backend knows when to send but non-technical users should control the content and targeting
Example Scenario
Your retail app allows customers to place online orders for pickup at different store locations. When a new order is placed, you want to notify staff at that specific store. Without API-triggered campaigns, you’d need to:- Query your database for staff members at the store location
- Build the notification payload with order details
- Call a send API for each recipient
- Configure a campaign once in the console with targeting rules and message template
- Call the trigger endpoint with just the store location and order details
- Clix handles filtering, personalization, and delivery
Setting Up a Campaign
1. Create the Campaign
In the Clix console:- Go to Campaigns > Create Campaign
- Choose your message channel and configure the content
- In the Schedule & Launch step, select API-Triggered
2. Configure Dynamic Audience Filters
API-triggered campaigns support dynamic audience filtering, where filter values come from your API request instead of being hardcoded. Use thetrigger.* namespace in your audience conditions to reference API payload data:
"store_location": "San Francisco", Clix will only send to users where:
user_roleequals"store_staff"(static condition)store_locationequals"San Francisco"(dynamic condition from API payload)
Supported Operators
For dynamic filters, you can use:- Equals (
==) - Not equals (
!=) - Exists
- Not exists
- In
- Not in
Filter Limitations
To ensure performance when filtering on-demand:- Maximum 3 attributes per audience definition
- Attributes can be combined with AND or OR operators
- Groups are supported within these constraints
3. Add Dynamic Content
Use Personalization syntax to insert dynamic values in your message content. Thetrigger.* namespace contains properties from your API request:
Message title:
4. Save and Get Campaign ID
After saving your campaign, you’ll see:- Campaign ID: Use this to trigger the campaign via API
- Sample API request: Example code snippets
- Go to Campaigns
- Click on your campaign
- The campaign ID appears in the URL:
console.clix.so/campaigns/{campaign_id}
Triggering from Your Backend
Call the trigger endpoint when you want to send the campaign:properties object contains data for both:
- Audience filtering: Values referenced in
{{ trigger.* }}conditions - Message personalization: Values inserted in message templates
Full Example
Let’s build an order notification system for retail stores.Console Configuration
Campaign name: New Order Alerts Audience:- Title:
New pickup order - Body:
Order #{{ trigger.order_id }} from {{ trigger.customer_name }}. {{ trigger.item_count }} items ready by {{ trigger.pickup_time }}. - Deep link:
myapp://orders/{{ trigger.order_id }}
019aa002-1d0e-7407-a0c5-5bfa8dd2be30
Backend Implementation
When a customer places an order:Result
For an order placed at the San Francisco store:- Clix filters audience to staff where
store_location == "San Francisco" - Each staff member receives a notification with the order details
- Title: “New pickup order”
- Body: “Order #ORD-12345 from Sarah Johnson. 3 items ready by 2:30 PM.”
"store_location": "New York". No new campaign needed.
Best Practices
- Keep filter logic simple: Use 3 or fewer attributes. Move complex logic to your backend.
- Pre-format data: Send
"$29.99"instead of2999if you want to display formatted prices. - Use meaningful property names:
facility_nameis clearer thanfnorname1. - Test with sample data: Use the campaign preview feature to verify personalization before going live.
- Handle missing data: Use the
defaultfilter for optional properties:{{ trigger.discount | default: "10%" }}
Limitations
- Audience attributes: Maximum 3 attributes in filter conditions
- Filter operators: Limited to equals, not equals, exists, not exists, in, not in
- Campaign edits: Changing audience or message requires creating a new campaign or updating the existing one (campaign ID remains the same)
- Rate limits: See API Rate Limits for request quotas