Lists of clients and contacts come a page at a time, 50 to a page unless you ask for up to 200 with limit. When there are more, the answer has a next_cursor. Send it back as cursor to get the next page. When next_cursor is null, you have them all.
let cursor = null;
do {
const url = new URL('https://api.torlie.com/desk/clients');
url.searchParams.set('limit', '200');
if (cursor) url.searchParams.set('cursor', cursor);
const res = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.TORLIE_KEY}` }
});
const page = await res.json();
for (const client of page.clients) console.log(client.reference, client.name);
cursor = page.next_cursor;
} while (cursor);Matters
Matters come in one list of up to 500 (100 unless you ask for more with limit). If more matched, the answer says more: true. Narrow it with the filters, such as one client, one work stream or one owner, rather than paging.