Answered

Default sorting in GET request for "List All Contacts"

  • 20 December 2023
  • 2 replies
  • 78 views

Hello Intercom Community,

I’m relatively new to interacting with APIs. I’m trying to extract the list of all contacts following the instructions from the API documentation.

My ultimate goal is to run this GET request every let’s say 1 hour and then from the resulting set to get the data I need for the contacts who have an “updated_at” value later than a <fixed threshold_time> (ie. the most recently updated items). If I understood correctly it is not possible to provide sorting parameters for this GET request (eg. based on descending “updated_at”).

So my question is: What is the default sorting method that defines the order of items in the resulting list of contacts. I’m not not if that’s “updated_at” or “last_seen_at” or any other field. If I know for instance that contacts are by default sorted based on descending “updated_at” then I can paginate through the results, and get the data from each page, until I reach a page with “updated_at” values earlier than my <fixed threshold_time>. But if that’s not the case then is there any alternative to achieve my goal?

I saw that I could instead use a POST request to https://api.intercom.io/conversations/search.instead to define a more complex query (update_at > “fixed_threshold_time”), and I’m wondering if there is any reason or concern against using that approach (my general understanding is that GET requests are mostly used for retrieving data and POST requests for modifying data).

Many thanks,

GiMeo

icon

Best answer by Jacob Cox 6 January 2024, 23:34

View original

2 replies

Userlevel 4
Badge +5

Hi @GiMeo !

What you are looking to do sounds to me like you are trying to search through all of your Contacts and find those who have an “updated_at” value after a specific date and time. You’ll want to use that “Search Contacts” endpoint that you referenced above to do this. The method you use here is a POST because it requires you to send a request body in the call which outlines the parameters of your search query, like in the screenshot below. GET requests don’t include a body in their calls so that method wouldn’t work here.

 

Hope that helps!

 

Many thanks for the reply @Jacob Cox !

 

Reply