The sort_by parameter controls the order of your search results. You can sort by any field in ascending or descending order, and combine up to three fields for multi-level sorting.

Quick start

Here’s how to sort transactions by creation date in descending order (newest first):
curl -X POST "http://YOUR_BLNK_INSTANCE_URL/search/transactions" \
  -H "X-Blnk-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "*",
    "sort_by": "created_at:desc"
  }'

Sort syntax

Basic sorting

Sort by a single field using the format field:direction:
# Sort by amount (lowest to highest)
"sort_by": "amount:asc"

# Sort by creation date (newest to oldest)
"sort_by": "created_at:desc"

Sort directions

DirectionDescriptionExample
ascAscending order (A-Z, 0-9, oldest to newest)amount:asc
descDescending order (Z-A, 9-0, newest to oldest)created_at:desc

Multi-field sorting

Combine up to three fields separated by commas. Fields are applied in order: the first field is primary, second breaks ties, third breaks remaining ties:
curl -X POST "http://YOUR_BLNK_INSTANCE_URL/search/transactions" \
  -H "X-Blnk-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "*",
    "sort_by": "status:asc,created_at:desc,amount:desc"
  }'
This sorts by:
  1. Status (ascending) - groups by status first
  2. Created date (descending) - within each status, newest first
  3. Amount (descending) - for same status and date, highest amount first

Common sorting patterns

1

Sort by creation date

Show the most recent records first, useful for transaction monitoring.
curl -X POST "http://YOUR_BLNK_INSTANCE_URL/search/transactions" \
  -H "X-Blnk-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "*",
    "sort_by": "created_at:desc"
  }'
2

Sort by amount

Find the largest transactions first for financial analysis.
curl -X POST "http://YOUR_BLNK_INSTANCE_URL/search/transactions" \
  -H "X-Blnk-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "*",
    "sort_by": "amount:desc"
  }'
3

Sort balances by amount

Identify accounts with the highest balances.
curl -X POST "http://YOUR_BLNK_INSTANCE_URL/search/balances" \
  -H "X-Blnk-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "*",
    "sort_by": "balance:desc"
  }'
4

Multi-level transaction sorting

Group by status, then show newest transactions first within each status.
curl -X POST "http://YOUR_BLNK_INSTANCE_URL/search/transactions" \
  -H "X-Blnk-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "*",
    "sort_by": "status:asc,created_at:desc"
  }'

Best practices

  • Default to newest first: Use created_at:desc for time-sensitive data like transactions.
  • Combine with filtering: Sort filtered results for more targeted analysis.
  • Limit multi-field sorting: Use 2-3 fields maximum to avoid complexity.


Need help?

We are very happy to help you make the most of Blnk, regardless of whether it is your first time or you are switching from another tool. To ask questions or discuss issues, please contact us or join our Discord community.