Skip to content
Webhooks and APIs3 min read

By · Editorial policy

Resume API Pagination After a Failed Sync

Advance the saved cursor only after the current page is durably applied. If you cannot commit the writes and checkpoint together, allow the last page to replay and make its per-record writes idempotent.

What is the practical answer?

Advance the saved cursor only after the current page is durably applied. If you cannot commit the writes and checkpoint together, allow the last page to replay and make its per-record writes idempotent. Start a sync with cursor C0 and ask the provider for records and next cursor C1. If you save C1 before applying the page, a worker crash can skip records. If you save it afterward, a crash may repeat the page instead. Upserting source record IDs or keeping a per-record ledger makes the second case recoverable without introducing duplicates. Store the endpoint, filter, sort order, account, and relevant API version alongside the cursor. An opaque token often belongs to the original query. For incremental sync, capture a stable upper boundary when the provider supports it. Mutable collections can shift during offset paging.

Evidence: Stripe cursor pagination · Reddit workflow reliability discussion

  1. Fetch page with saved cursorInput
  2. Upsert all page recordsExternal action
  3. Commit next cursorProcess
  4. Replay last incomplete pageRecovery
The checkpoint advances after the destination writes are durable, so an interrupted page can be replayed.

Treat the checkpoint as a commit marker#

Store the endpoint, filter, sort order, account, and relevant API version alongside the cursor. An opaque token often belongs to the original query. For incremental sync, capture a stable upper boundary when the provider supports it. Mutable collections can shift during offset paging. A checkpoint preserves your progress, while the upstream API’s ordering and visibility determine what you can enumerate reliably.

What you findWhat to do
Page partially committedreplay using stable item IDs.
Checkpoint committed and page writes confirmedcontinue at the next token.
Token rejected after an outageuse the provider’s supported restart or rescan and reconcile a bounded partition.

Plan for invalid or expired cursors#

Follow the provider’s documented reset behavior. Where the endpoint supports a monotonic modification field, restart from a saved watermark with overlap and deduplication. Use a stable tie-breaker for records with identical timestamps if the API supports it. Without a safe incremental restart, rescan the selected partition and reconcile rows by durable ID.

Save cursor checkpoints you can inspect#

An inspectable checkpoint can contain stream ID, account, query digest, committed cursor, last record ID, and the time the destination confirmed the page. Save any record count as additional context. When a cursor is rejected, the query digest tells you whether a client configuration changed or whether the provider rejected a previously valid continuation token.

If the source has no trustworthy update timestamp or documented stable ordering, prefer replaying a bounded source partition or restarting a snapshot export. Record which part of the dataset was rescanned and compare only against that scope. Verify pagination progress by looking for a repeated cursor or page hash, since a client stuck on the same page can still keep reporting successful HTTP requests.

Verify it with a failure drill#

Return records A and B on the first mock page, then interrupt the worker after A is written and before C1 is saved.

  • On restart, verify A is updated idempotently, B is written once, and page two starts only after C1 is committed. Repeat with C1 rejected to exercise the fallback.

Sources and further reading

Official references support technical claims; community discussions are used only as problem signals.