Discussions
How to update/refresh a segment contact count using API?

So we've been trying to automate the process of fetching contacts count in segments via API.
We're able to fetch the count of a segment without any problem using GET.
But the count never gets refreshed unless someone manually goes in the segment and either clicks on the Refresh icon, or Saves the segment to recalculate the count.
I've looked everywhere in the REST API but there's no endpoints allowing us to recalculate the Count of contacts in a segment. I've tried to update on the segment endpoint (using PUT), but all it does is just add the criteria/filters to a segment without recalculating it.
Has anyone done something not out of the box to recalculate/refresh the count in some way in segments via API?
Thanks so much!
Best Answer
-
Jeremy, while you will not find this in the current API documentation, we used the following REST endpoint many years ago to accomplish this task (POST):
"/assets/contact/segment/queue/{yourSegmentId}"
I just checked, and this endpoint still works--using REST 2.0--again, it is probably not officially supported, as it is no longer in the documentation.
- Tom Shaheen, Net Portfolio, Inc., [email protected]
Answers
-
Hi Tom, thanks you're the best!
I've just tried it (with POST) and it worked! The count was refreshed automatically once I did my GET right after.
I will keep this in mind, for sure as it's no longer supported there will be risks of data discrepancies but this is better than having to manually refresh it all the time.
Cheers and stay safe!
-
I don't see the segment count updating after sending the POST to "/assets/contact/segment/queue/{yourSegmentId}".
I get this response:
{
"type": "QueueInfo",
"queuedAt": "{dateTime}",
"segmentId": "{yourSegmentId}"
}
Then when I do the GET again the count is still old and has not been updated. Is there any other steps required?