Skip to main content
The Penbox API provides pagination and sorting capabilities on all list endpoints to help you manage large datasets and control the order of results.

Pagination

All list endpoints support pagination to manage large result sets efficiently.

Basic Usage

Pagination Parameters

The maximum page[size] is 100. If you need to retrieve more results, use multiple paginated requests.

Response Format

All paginated endpoints return results in the same format:
Response Fields:

Pagination Examples

Iterating Through Pages

Loading a Specific Page

Pagination with Filters

Sorting

Control the order of results with the sort parameter. Sorting works with both direct parameters and JSON filters.

Basic Usage

Sort Format

Prefix the field name with a minus sign (-) for descending order.

Common Sort Fields by Endpoint

Cases (/v1/cases)

  • created_at - Creation timestamp
  • updated_at - Last update timestamp
  • title - Case title
  • status - Custom status value
  • parent_status - Parent status
  • waiting_for - Who the case is waiting for
  • reference - Custom reference number
  • archived_at - Archive timestamp

Case Templates (/v1/case_templates)

  • created_at - Creation timestamp
  • updated_at - Last update timestamp
  • title - Template title
  • reference - Custom reference
  • archived_at - Archive timestamp

Forms (/v1/forms)

  • created_at - Creation timestamp
  • updated_at - Last update timestamp
  • Various custom fields based on form template

Form Templates (/v1/form_templates)

  • created_at - Creation timestamp
  • updated_at - Last update timestamp

Sorting Examples

Sort by Date

Sort by Title

Sort with JSON Filter

Dynamic Sorting

Combining Pagination and Sorting

Pagination and sorting work together seamlessly:

Best Practices

  • Use larger page sizes (50-100) for batch processing
  • Use smaller page sizes (10-25) for UI display
  • Consider network latency and processing time
Never assume a dataset is small. Always implement pagination to avoid:
  • API timeouts
  • Memory issues
  • Poor user experience
Sorting by created_at or updated_at is typically faster than custom fields. Use these when possible for better performance.
If sorting by the same field repeatedly, consider caching the results to reduce API calls.
Always check if the data array is empty:
Show users how many total results exist:

Complete Example: Data Table

Here’s a complete example of implementing a paginated, sortable data table:

Next Steps

Advanced Filters

Learn how to filter results with operators

List Cases

Apply pagination to the Cases endpoint

List Forms

Paginate and sort forms

OpenAPI Spec

See all available sort fields