Overview
Several Resend API endpoints support cursor-based pagination to help you efficiently browse through large datasets. You can safely navigate lists with guaranteed stability, even if new objects are created or deleted while you’re still requesting pages. Paginated endpoints responses include:object
: always set tolist
.has_more
: indicates whether there are more elements available.data
: the list of returned items.
limit
: the number of items to return per page.after
: the cursor to use to get the next page of results.before
: the cursor to use to get the previous page of results.
id
of objects as the cursor for pagination. The cursor itself is excluded from the results. For an example, see pagination strategies below.
Currently-supported endpoints
Existing list endpoints can optionally return paginated results:Note that for these endpoints, the
limit
parameter is optional. If you do
not provide a limit
, all items will be returned in a single response.Parameters
All paginated endpoints support the following query parameters:The number of items to return per page. Default is
20
, maximum is 100
, and
minimum is 1
.The cursor after which to start retrieving items. To get the next page, use
the ID of the last item from the current page. This will return the page that
starts after the object with this ID (excluding the passed ID itself).
The cursor before which to start retrieving items. To get the previous page,
use the ID of the first item from the current page. This will return the page
that ends before the object with this ID (excluding the passed ID itself).
You can only use either
after
or before
, not both simultaneously.Response Format
Paginated endpoints return responses in the following format:Response Format
Always set to
list
for paginated responses.Indicates whether there are more items available beyond the current page.
An array containing the actual resources for the current page.
Strategies
Forward Pagination
To paginate forward through results (newer to older items), use theafter
parameter with the ID of the last item from the current page:
Backward Pagination
To paginate backward through results (older to newer items), use thebefore
parameter with the ID of the first item from the current page (or the most recent ID you have in your system):
Best Practices
Use appropriate page sizes
Use appropriate page sizes
Choose a
limit
that balances performance and usability. Smaller pages are good for real-time applications, while larger pages
(hundreds of items) work better for bulk processing.Handle pagination gracefully
Handle pagination gracefully
Always check the
has_more
field before attempting to fetch additional pages.
This prevents unnecessary API calls when you’ve reached the end of the
dataset.Consider rate limits
Consider rate limits
Be mindful of API rate limits when paginating through large datasets.
Implement appropriate delays or batching strategies if processing many
pages.
Error Handling
Pagination requests may return the following validation errors:Error | Description |
---|---|
validation_error | Invalid cursor format or limit out of range (1-100) |
validation_error | Both before and after parameters provided |
Error Response