DocsGuides

Pagination

Cursor-based pagination and incremental sync with updated_since.

List endpoints return results in pages using stable, cursor-based pagination. Cursors are opaque; treat them as tokens and do not construct or parse them yourself.

Request parameters

Parameter Type Description
limit integer Page size. Default 50, maximum 100.
cursor string Opaque cursor from a previous response's next_cursor.

Response shape

{
  "data": [ /* … up to `limit` items … */ ],
  "has_more": true,
  "next_cursor": "eyJpZCI6InJlc185RnEyYzgifQ"
}
Field Description
data The array of items for this page.
has_more true if more items exist beyond this page.
next_cursor Pass as cursor to fetch the next page. null when has_more is false.

Paging through all results

Keep requesting with the returned next_cursor until has_more is false.

# First page
curl "https://coastly.surf/api/v1/reservations?limit=100" \
  -H "Authorization: Bearer $COASTLY_KEY"

# Next page
curl "https://coastly.surf/api/v1/reservations?limit=100&cursor=eyJpZCI6InJlc185RnEyYzgifQ" \
  -H "Authorization: Bearer $COASTLY_KEY"
async function listAll(path) {
  const items = [];
  let cursor = null;
  do {
    const url = new URL(`https://coastly.surf/api/v1/${path}`);
    url.searchParams.set("limit", "100");
    if (cursor) url.searchParams.set("cursor", cursor);
    const res = await fetch(url, {
      headers: { Authorization: `Bearer ${process.env.COASTLY_KEY}` },
    });
    const page = await res.json();
    items.push(...page.data);
    cursor = page.has_more ? page.next_cursor : null;
  } while (cursor);
  return items;
}

Incremental sync with updated_since

Many list endpoints, including /reservations, /orders, /properties, /room-types, and /invoices, accept an updated_since parameter (ISO 8601 timestamp). Only records created or modified at or after that time are returned. Combine it with cursor pagination to pull just what changed since your last sync.

curl "https://coastly.surf/api/v1/reservations?updated_since=2026-06-30T00:00:00Z&limit=100" \
  -H "Authorization: Bearer $COASTLY_KEY"

Store the timestamp of your last successful sync and pass it as updated_since on the next run. This keeps polling cheap and avoids re-fetching unchanged records.