Skip to main content

Sorting

Many mail2many API endpoints support sorting. Sorting is done via the sorting query parameter. The parameter must be passed as URL-encoded JSON.

Sorting logic

  • Sorting rules are applied in the order they are provided
  • You can combine multiple sorting rules
  • For each field, you must specify asc (ascending) or desc (descending)

Simple sorting

To sort by one field:

sorting=[{"createdAt":"desc"}]

This sorts by createdAt in descending order (newest first).

Multiple sorting

You can combine multiple sorting criteria:

sorting=[{"createdAt":"desc"},{"email":"asc"}]

This sorts first by createdAt descending, then by email ascending.

Available sort directions

ValueDescription
ascAscending (A–Z, 0–9, oldest first)
descDescending (Z–A, 9–0, newest first)

Sorting with filtering

You can combine sorting and filtering:

search=[{"languageIso":"de"}]&sorting=[{"createdAt":"desc"}]