
SaaS Background Exports: Clear Status, Safe Downloads, and Predictable Expiry
Design large data exports as traceable jobs with scoped permissions, meaningful progress, bounded retries, and secure delivery.
MVPs & SaaS Projects
Design paginated APIs with stable ordering, opaque continuation tokens, repeated authorization, explicit consistency rules, and recoverable client behavior.

LET’S BUILD SOMETHING USEFUL
Talk to Ataraxy Developers about your website, app, or custom software.
Pagination becomes a product issue when customers cannot tell whether they have retrieved all their records. A list that works with a few test items may skip or repeat results once users add data while an integration is paging through it. Filters, sorting, permissions, and retries all influence what the next page actually means.
For a SaaS MVP, define this contract before external customers build integrations around the endpoint. A small, consistent API is easier to support than a convenient first version whose assumptions become permanent dependencies. The goal is to make continuation predictable while being honest about how a changing collection affects the result.
Start with the resource being listed and the boundary around it. A fictional project-management SaaS might expose a workspace’s tasks, filtered by status and ordered by creation time. The server must know which workspace is in scope and which tasks the caller may read. A page size parameter does not replace that definition.
Document the supported filters and default ordering. Keep the first version focused on combinations the database and authorization model can support reliably. Avoid promising arbitrary sorting over every property just because a generic query builder makes it easy to accept parameters. Each supported order creates expectations about consistency, performance, and what happens when the underlying property changes.
A sort field alone may not uniquely order records. Several tasks can share the same creation timestamp. Add a stable tie-breaker, such as a unique task identifier, so the continuation point is unambiguous. Apply the same ordering rules to every page. Test records with identical primary sort values rather than relying on naturally varied sample data.
If the order uses a mutable field, such as last activity time, explain the consequences. A task can move between pages while a client is reading the list. Decide whether that live behavior is acceptable or whether the operation needs a stable snapshot. A cursor is a way to continue a query; it does not automatically freeze the underlying data or guarantee a complete historical view.
Google’s AIP-158 pagination guidance describes page-size and continuation-token fields, an explicit next-page token, and opaque tokens that clients should not parse. It also states that a short page does not necessarily mean the collection has ended and that authorization must still be performed on requests carrying a page token. These are useful reference points when designing your own API contract.
For the task API, define the default and maximum page size, how invalid values are handled, and the exact signal for completion. A client should continue according to the documented token field rather than guessing from the number of records returned. Keep examples consistent with the actual implementation, including an empty result page if your query strategy can legitimately produce one before completion.
A continuation token should preserve the context necessary to resume the same query. That may include the ordering, filter version, boundary value, and snapshot reference. Keep implementation details hidden from consumers and protect the token against unsupported alteration. Encoding plain internal data in a different alphabet does not by itself make it secret or trustworthy.
Define what happens if a client changes the status filter while reusing an earlier token. A clear validation error is usually easier to understand than silently continuing a different query. If changing page size is supported, state that separately. Avoid including sensitive customer data in a token when an internal reference or minimal protected state is sufficient. Tokens also appear in logs and diagnostic tools.
The server should apply current authentication and access rules on every request. A token is a continuation reference, not a grant to read records forever. Recheck workspace membership and resource visibility as required by the product. A user removed from a workspace should not retain access simply because they saved a page token from yesterday.
Test attempts to reuse a token with another account or workspace. Verify that caches include the relevant authorization context and do not share private results across callers. If permissions change during pagination, document the resulting behavior. The API may return fewer visible records or reject continuation, depending on its contract, but it must not expose data to preserve an artificial page length.
An interactive task list may be allowed to reflect live changes. A complete accounting export or migration feed may need a stronger snapshot or dedicated export workflow. Name the guarantee for each endpoint. If live pagination can repeat or omit items when records change, explain that limitation and provide the appropriate alternative for clients needing a stable full dataset.
For the fictional SaaS, a background export could establish a defined cutoff and produce a versioned result, while the ordinary list remains current for navigation. Avoid making the list endpoint carry every consistency requirement. Give customers an explicit choice based on their task. Test the promised behavior with concurrent inserts, updates, and deletions so the documentation describes observed results rather than an architectural hope.
Continuation state may have a limited lifetime. When a token can no longer be used, return a specific error and explain the supported restart path. A generic server failure encourages unbounded retries. If restarting can repeat previously processed records, clients should have stable resource identifiers and a documented strategy for reconciling them.
List operations should avoid side effects that turn a retry into duplicate work. An integration that receives a timeout needs to be able to request the same continuation safely within the stated consistency model. Provide request identifiers for diagnosis and avoid logging full sensitive result bodies. Record enough information to distinguish an expired token, changed filter, access denial, and genuine infrastructure failure.
Create a controlled collection with tied timestamps, records on both sides of a filter, and permissions that differ between callers. Page through it with several sizes, including the default and maximum. Insert or remove a record between requests and compare the outcome with the documented consistency rule. Include a token from a previous query and a token altered by one character.
Check that the client stops on the defined completion signal and does not loop forever after an empty page. Test a delayed retry and access removal between pages. Measure the endpoint with a realistically sized dataset before publishing broad limits. A working example with six tasks says little about a customer workspace with years of history and several active integrations.
An AI feature that summarizes a task list needs to know whether it received the full relevant dataset or only one page. Pass the filter, retrieval time, and completeness state with the records. A summary based on the first page should not claim to describe every task in the workspace. This is especially important when the default order favors recent activity.
AI can help draft client examples or identify missing edge cases in the contract, but verify those examples against the live implementation. Do not let generated code infer token structure or bypass the normal authorization path. Keep explanatory text tied to the same API version and error behavior that customers actually receive.
Reliable pagination requires a defined collection, deterministic order, clear continuation rules, and authorization on every request. State the consistency guarantee, handle expiry and retries explicitly, and test changing data. Those decisions give SaaS customers a dependable way to retrieve records without mistaking a convenient cursor for a promise the system does not make.
LET’S BUILD SOMETHING USEFUL
Talk to Ataraxy Developers about your website, app, or custom software.