Pagination and Sorting

A StackHawk organization may have many applications, which may have many environments, that can group many scan results, that may each report many scan alerts.

Requests made to the StackHawk API for listed resources will return paginated results.

Pagination and Sorting

Paginated requests follow a pattern of taking the following optional path parameters:

  • pageToken: a string incrementing count of pages in the pagination, starting from '0'
  • pageSize: the number of elements to request in the page, defaults to 10
  • sortField: sorts the listed resource by an approved field. defaults to sorting by resource id (creation date)
  • sortDir: either 'asc' or 'desc', defaults descending

The responseBody of these API routes will additionally include two fields:

  • nextPageToken: a string indicating the next pageToken to pass in for the next page of results with this request. Will be an empty string if there are no more resources.
  • totalCount: the total number of resources the query can paginate through

Best Practices

For optimal use of the StackHawk API, request resources with a small pageSize, and make subsequent requests with each nextPageToken as needed. API requests with a larger pageSize may take longer to process.