Skip to main content

Overview

Use pagination when you need to retrieve large datasets in smaller batches. Dakota supports this through max_num (page size / limit) and offset (starting position) inside the filters object.

How offset and max_num work

Formula: offset = (page_number - 1) * max_num

Response shape

List responses return an envelope:
count_only responses return:

How to Use

  1. Optionally call with count_only: true to get record_count.
  2. Request page 1 with offset: 0 and your chosen max_num.
  3. For the next page, set offset to the previous response’s next_offset (or add max_num to the current offset).
  4. Stop when next_offset is -1 (last page, empty result, or past end). You can also stop when records.length < max_num.

Empty and last-page behavior

Account Examples

First Page of Accounts

Next Page of Accounts

Paginate Accounts with a Filter

Count Accounts Before Paging

Contact Examples

First Page of Contacts

Next Page of Contacts

Paginate Contacts with a Date Filter

Count Contacts Before Paging

Best Practices

  • Prefer next_offset === -1 as the primary stop condition for bulk jobs.
  • Always include order_by so page results stay consistent across requests.
  • Use a max_num between 20 and 50 for reliable bulk pulls.
  • Use count_only first when you need the total record count before paging.
  • Apply the same filter and order_by on every page of a bulk job.
  • max_num works as either a number (50) or a string ("50").
  • Request fields use payload names (for example sfid, lastname); responses may return mapped names (for example account_id / contact_id, last_name).

Token expiry

Access tokens expire after 18,000 seconds (5 hours). When pulling large datasets (for example hundreds of thousands of Account or Contact records), a long-running pagination script can exceed this window. If the token expires mid-run, later page requests will fail with an unauthorized / invalid token response. Recommendations:
  • Track elapsed time while paging.
  • Refresh or re-authenticate and obtain a new token before the 5-hour limit if the job may run longer.
  • Resume from the last successful offset / next_offset after getting a new token so you do not restart from page 1.