Pagination
When fetching large sets of data (such as clusters, email addresses, campaigns, etc.), Luella uses pagination to return results in manageable chunks.
Pagination ensures fast response times and protects against timeouts when querying large datasets.
How it works
All List*
endpoints in Luella support two optional parameters:
maxItems
: (integer) The number of results you want returned in a single response.nextToken
: (string) A continuation token returned by the previous response if more data is available.
If more items are available after the current response, Luella includes a nextToken
field in the response payload. You can pass that token into your next request to retrieve the next "page" of results.
Example
1. First Request
{
"userId": "user_123",
"workspaceId": "workspace_456",
"maxItems": 2
}
Response:
{
"clusters": [
{ "clusterId": "cluster_001", "clusterName": "Alpha" },
{ "clusterId": "cluster_002", "clusterName": "Beta" }
],
"nextToken": "eyJwYWdlIjoyfQ==.LUELLA-V0.3qxtJHVdAynhXjeGl9"
}
This tells you there are more items to fetch.
2. Follow-Up Request
{
"userId": "user_123",
"workspaceId": "workspace_456",
"maxItems": 2,
"nextToken": "eyJwYWdlIjoyfQ==.LUELLA-V0.3qxtJHVdAynhXjeGl9"
}
Response:
{
"clusters": [
{ "clusterId": "cluster_003", "clusterName": "Gamma" }
],
"nextToken": null
}
In this case, nextToken
is null
, meaning you’ve reached the end of the dataset.
Notes
- Always check the
nextToken
field in responses to know if more data is available. - You are not required to use
nextToken
, but without it, only the firstmaxItems
results will be returned. maxItems
defaults to a system-defined value if not provided.
Pagination helps you build efficient, responsive UI and backend integrations when querying lists of dynamic resources across Luella.