Solved

Is there any way, via the API, to find which list is the trigger for a flow?

  • 16 January 2024
  • 5 replies
  • 92 views

Badge +1
  • Contributor I
  • 3 replies

I don’t see any way of dereferencing the list (or segment) on which a flow is triggered, via any of the flow api calls (or list api calls).  It does appear in the internal klaviyo API but I assume that is not for customers to use.

 

I haven’t seen it in any of the flow-action calls nested in here either.

https://a.klaviyo.com/api/flows/abc123/

{
"data": {
"type": "flow",
"id": "abc123",
"attributes": {
"name": "Test flow name",
"status": "live",
"archived": false,
"created": "2024-01-05T15:41:40+00:00",
"updated": "2024-01-05T15:41:47+00:00",
"trigger_type": "Added to List"
},
"relationships": {
"flow-actions": {
"links": {
"self": "https://a.klaviyo.com/api/flows/abc123/relationships/flow-actions/",
"related": "https://a.klaviyo.com/api/flows/abc123/flow-actions/"
}
},
"tags": {
"links": {
"self": "https://a.klaviyo.com/api/flows/abc123/relationships/tags/",
"related": "https://a.klaviyo.com/api/flows/abc123/tags/"
}
}
},
"links": {
"self": "https://a.klaviyo.com/api/flows/abc123/"
}
}
}


Observing the ajax call to get the flow data from the flow builder, I see the flow.trigger_id contains the list ID that the flow is configured to trigger (on subscribe).  It is also in the trigger_group.id field


https://www.klaviyo.com/ajax/flow/abc123?beta=true

{
"data": {
"flow": {
"id": "abc123",
"company_id": "MycmpnY",
"name": "Test flow name",
"folder_id": null,
"trigger_type": 1,
"trigger_id": "321cba",
"trigger_filter": null,
"customer_filter": null,
"start_path": 33536647,
"created": "2024-01-05T15:41:40Z",
"updated": "2024-01-05T15:41:47Z",
"deleted": null,
"archived": false,
"status": 2,
"is_ignoring_holdout_group": false,
"is_relative_timing": true,
"ajax_actions_statistics_url": "/ajax/flow/abc123/actions/statistics",
"ajax_trigger_filters_url": "/ajax/flow/abc123/trigger-filters",
"ajax_customer_filters_url": "/ajax/flow/abc123/customer-filters",
"ajax_details_url": "/ajax/flow/abc123/details",
"transactional": {
"is_eligible_for_transactional_email": false,
"is_eligible_for_transactional_sms": false
},
"trigger_group": {
"id": "321cba",
"company_id": "MycmpnY",
"name": "Test flow name",
"type": 0,
"subtype": 0,
"email_engagement_score": null,
"definition": null,
"deleted": null,
"deactivated_at": null,
"search_task_id": null,
"has_found_members": false,
"members_last_updated": null,
"segment_task_id": null,
"is_flagged": false,
"sort_order": 0,
"is_double_optin": false,
"is_autoupdating": true,
"is_tracking_stats": false,
"is_global_unsubscribe": false,
"is_cutover_to_sip": false,
"last_used": "2024-01-04T17:09:42Z",
"is_external_trigger": false,
"allow_flow_triggers": true,
"contact_name": null,
"contact_email": null,
"folder_id": null,
"recipe_id": null,
"is_email_profiles": false,
"is_email_autoresponder": false,
"found_percent_complete": null,
"start_date": null,
"language": "",
"created": "2024-01-04T17:09:34Z",
"updated": "2024-01-04T17:09:42Z",
"url": "/list/321cba"
},
"extra":"..."
}
}
}

Is there anywhere on the customer-facing APis where this relationship can be found?

I tried some undocumented approaches like: adding ?fields[flow]=trigger_id and ?include=trigger_group but seems that this api is fairly limited.

icon

Best answer by saulblum 17 January 2024, 03:06

View original

5 replies

Userlevel 5
Badge +7

There are plans in the works to expose more flows properties in the public APIs, but for now, details about the specific list that triggers a flow isn’t available.

What’s the use case to know the list ID through the flows API? Are you trying toi access it, say, in a webhook action?

Badge +1

The use case is that we have dedicated lists for a given flow - those lists are associated with marketing campaigns (users are subscribed to a campaign-specific list when they arrive via a specific channel) and we use the flow analytics to measure the flow-attributed purchases and general performance.  Currently this is done by a custom report which is labor-intensive.
 

We are trying to use the new metrics-aggregate api to calculate flow-attributed purchases, opens etc (which is great) but there is no relationship between the flow and the list that drove the metrics.


The simple addition of trigger_id to the flow “attributes” object (when present), or “trigger” in the relationships (accessible via ?include, as it is structured in the internal ajax api) would be great, since trigger_type on it’s own is not overly useful.  It would also be nice to filter based on that field in addition to the other fields ['archived', 'created', 'id', 'name', 'status', 'trigger_type', 'updated']


For context, we have thousands of flows, each with it’s own respective list.  

Userlevel 5
Badge +7

There’s not currently a way to get the list ID of the list that triggered the flow, but it’s in the works, along with more flow-related API calls.

You’d have to keep an external mapping of flow ID to list ID.

Badge +1

Is it slated for release any time soon? Is there any way we can put some priority behind this via our Klaviyo One account?

 

Thanks -

Userlevel 5
Badge +7

Is it slated for release any time soon?

It’s still in development with no public availability date yet, along with enhanced segment APIs.

There’s an AJAX call the main flows page calls, e.g. https://www.klaviyo.com/ajax/flows/list/?archived=false&order_asc=false&order_by=updated&page=1&timeframe_end=2023-5-17&timeframe_key=last_7_days&timeframe_start=2023-4-17

It returns a JSON block of all the flows. If you see "trigger_type": 1 that’s a list-or-segment-triggered flow, and there’s a trigger_id property that shows the list ID, e.g.

"trigger_id": "ABC123",

"trigger_type": 1,

It’d be manual work but this would be a somewhat faster way to build a mapping of flow IDs to list IDs.

Reply