Sort Query Parameter

The Sort query parameter is available to specify how the query results are organized in the API response. By default, query results are returned in ascending order based on the ID property.

The Sort query parameter can use any sortable query parameter for the endpoint to organize the query results in ascending or descending order for the property.

The supported query parameters are indicated as (sortable) in the query parameter description.

For example, you can sort the query results of an endpoint by the status instead of the ID or sort by effective_date in descending order so that the most recent results are at the top.

The API request to sort results by the Status query parameter in ascending order would appear like this:

GET /billing-accounts?sort=status.

 

Ascending order means the smallest numbers or values display first. These are the examples of how different types of values are sorted in the ascending order:

  • Numbers or amounts are sorted from the smallest to largest.

  • Letters or words are sorted alphabetically from A to Z.

  • Dates are sorted from oldest (earliest) to most recent.

  • For data with numbers and letters such as address lines, numbers (from smallest to largest) are sorted first, then followed by A-Z.

Descending order means the largest numbers or values list in the order display first. These are the examples of how different types of values are sorted in the ascending order:

  • Numbers or amounts are sorted from largest to smallest.

  • Letters or words are sorted alphabetically from Z to A.

  • Dates are sorted from most recent to oldest (earliest).

  • For data with numbers and letters such as address lines, Z to A is sorted first, then followed by numbers (largest to smallest).

 

Sort the Response Data

In the ascending order, no prefix is required. For example, id sorts results in ascending order by the ID query parameter:

GET /billing-accounts?sort=id.

Billing accounts with smaller ID values display first.

 

In the descending order, insert “-” in front of the query parameter name. For example,
-category_name
value sorts the results in the descending order by the category_name query parameter:

GET /billing-account-categories?sort=-category_name.

Billing account categories display in the reverse alphabetical order.