How to iterate paginated Contacts search results | Community
Skip to main content
Question

How to iterate paginated Contacts search results

  • Jan 7, 2022 12:18 PM UTC
  • 3 replies
  • 470 views

Request

POST https://api.intercom.io/contacts/search Accept:application/json Content-Type: application/json Intercom-Version: 2.4 Authorization: Bearer token   { "query": { "operator": "AND", "value": [ { "field": "email", "operator": "~", "value": "timur+1" } ] } }

results in

{ "type": "list", "data": [...], "total_count": 78, "pages": { "type": "pages", "next": { "page": 2, "starting_after": "Wy0xLCI1ZjIyYzQzZjkxMjU5NmY1MDNiMjA4ZWUiLDJd" }, "page": 1, "per_page": 50, "total_pages": 2 } }

But next request

POST https://api.intercom.io/contacts/search?starting_after=Wy0xLCI1ZjIyYzQzZjkxMjU5NmY1MDNiMjA4ZWUiLDJd Accept:application/json Content-Type: application/json Intercom-Version: 2.4 Authorization: Bearer token   { "query": { "operator": "AND", "value": [ { "field": "email", "operator": "~", "value": "timur+1" } ] } }

returns first page again. How to retrieve second page?

3 replies

  • Author
  • Connector
  • Jan 7, 2022 12:29 PM UTC

  • Author
  • Connector
  • Jan 7, 2022 12:47 PM UTC

And why pagination interface can't be unique throughout the API?


Racheal
Intercom Team
Forum|alt.badge.img+7
  • Customer Support Engineer
  • Sep 19, 2022 5:53 PM UTC

Hey @timur​ 

 

Pagination has it's own section within our API, and we link to pagination in our list contacts endpoint, as this is where the pagination would occur. Definitely understand it can be tricky navigating around the API docs! As we mention here when listing any Contact objects, we will instead use a cursor-based approach, our Search resources will instead use a POST-based approach.