I don’t know what I’m missing but this seems to either be a documentation error or something that I’m not getting right.
When looking in the documentation there is a “order_by” property ( Keap REST API ) which description talk about values for both order by and direction, but I can’t understand how to apply the direction parameter value, does it have a dedicated undocumented key or does this needs to be combined with the order_by value in some way ? I’ve tried a few combos but without any success.
Also, when paginating trough the list of the contacts, I’m right to suppose that in the beginning I shouldn’t provide a “page_token” but then pass one trough to all the following sub-sequent request to move the pages ?
Thank you for your help!
Managed to find the answer myself in the postman collection Keap Rest v2 Examples - you need to put a space or “%20d” between the value and direction, like: order_by=create_time%20desc
Would love some clarification on the left aspect of how to use the page_token to properly paginate.
Hey Andrei, you got the order_by part exactly right, it should include both the field and the direction in a single string, separated by a space (or %20 when URL-encoded), for example order_by=create_time desc.
As for pagination, the Keap REST v2 API uses cursor-based pagination, meaning you don’t send any page_token in your initial request; instead, the response will return a next_page_token value if there are more records available. You then include that token in your next request to fetch the following page. This process repeats until the response no longer includes a next_page_token, which indicates you’ve reached the end of the results.
Note that when making paginated requests, you’ll want to include all the parameters you originally sent, like fields, filter, order_by, or page_size, to keep your results consistent.
1 Like