Skip to content
Codelia SMSDocs
Guides: Paging through results

Paging through results

A list endpoint answers in one of three ways: a page and a cursor for the next, a page by limit and offset, or the whole list at once.

Cursor

These answer with entries and nextCursor:

ListEndpointlimit
MessagesGET /organizations/{accountId}/messagesUp to 200, 50 if left out
CampaignsGET /organizations/{accountId}/messages/campaignsUp to 100, 25 if left out
A campaign's messagesGET /organizations/{accountId}/messages/campaigns/{campaignId}/messagesUp to 500, 100 if left out
Recurring campaignsGET /organizations/{accountId}/messages/recurringUp to 100, 25 if left out
ContactsGET /organizations/{accountId}/contactsUp to 200, 50 if left out
ActivityGET /organizations/{accountId}/activityUp to 100, 50 if left out

Ask for the first page:

curl "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/messages?limit=20" \
  -H "Authorization: Bearer $CODELIA_API_KEY"

Then pass the answer's nextCursor back as cursor, with the same filters, and repeat until nextCursor is null. A cursor belongs to the list it came from. On the campaign list, a cursor from another view is refused with 400 and invalid_cursor.

Offset

These answer with an array, and page by limit and offset:

ListEndpointlimit
Opt-outsGET /organizations/{accountId}/opt-outsUp to 1,000, 200 if left out
A list's membersGET /organizations/{accountId}/contact-lists/{listId}/membersUp to 500, 200 if left out

offset is how many to skip, and 0 if you leave it out. This asks for the second page of 100:

curl "https://api.sms.codelia.studio/v1/organizations/$CODELIA_ACCOUNT_ID/opt-outs?limit=100&offset=100" \
  -H "Authorization: Bearer $CODELIA_API_KEY"

Add limit to offset for the next page. A page with fewer entries than limit is the last.

The whole list

These come back whole, with no paging:

  • your lists, GET /organizations/{accountId}/contact-lists;
  • your sender names, GET /organizations/{accountId}/sender-ids;
  • your webhook endpoints, GET /organizations/{accountId}/webhook-endpoints.

An endpoint's deliveries, GET /organizations/{accountId}/webhook-endpoints/{endpointId}/deliveries, are the most recent ones, newest first: up to limit, which is up to 500, and 50 if you leave it out. There's no next page.

With the TypeScript SDK

list() gets one page, and iterate() gets every page for you. See TypeScript SDK.