Pagination
Lists come in pages. Follow next_cursor until it is null.
Cursor pages
A list answers { "data": [...], "next_cursor": "..." }. Pass limit, from 1 to 200 and 50 by default, and the cursor of the previous page. The cursor is opaque. Rows added while you page never repeat or skip one.
let cursor = null
do {
const url = new URL("https://api.omnio.sawego.com/v1/contacts")
url.searchParams.set("limit", "200")
if (cursor) url.searchParams.set("cursor", cursor)
const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.OMNIO_API_KEY}` } })
const page = await res.json()
for (const contact of page.data) console.log(contact.customer_id)
cursor = page.next_cursor
} while (cursor)
Sorted lists
A contacts cursor only works with the sort and order it came from. Another sort, or a cursor Omnio did not give, is 400 invalid_cursor.
Messages in a conversation
List messages pages by seq instead. before_seq scrolls back, after_seq catches up, and a page shorter than limit is the last in its direction.
Search
Search returns contacts and messages as two groups, each with its own contacts_cursor or messages_cursor and limit.