Filtering & Sorting

Filtering

Rackbeat APIs provide filtering capabilities to help you retrieve specific subsets of data from collection endpoints. Filtering allows you to narrow down results based on specific criteria, reducing the amount of data transferred and improving response times.

Filtering is implemented through query parameters in GET requests to collection endpoints.


Basic Search Filtering

The most common filtering method is the search parameter, which allows you to filter results using a text-based search.

Examples

GET /bank-accounts?search=mybank
GET /delivery-addresses?search=strandvej
GET /fields?search=invoice

Advanced Filtering

Some endpoints support additional filtering parameters beyond basic search.

Entity Range Filtering

This allows you to filter records between specific entity boundaries using parameters like customer_from/customer_to, employee_from/employee_to, and item_group_from/item_group_to, enabling precise targeting of data within defined organizational hierarchies.

Examples

# Get invoices for customers between ID 1000-2000
GET /api/customer-invoices?customer_from=1000&customer_to=2000

# Get invoices handled by employees 50-75
GET /api/customer-invoices?employee_from=50&employee_to=75

# Get invoices for items in groups 10-20
GET /api/customer-invoices?item_group_from=10&item_group_to=20

Temporal Filtering

This provides comprehensive date-based filtering with multiple time dimension options including date_from/date_to for general date ranges, invoice_date_from/invoice_date_to for invoice-specific dates, and updated_at_from/updated_at_to for tracking recent changes.

Examples

# Get invoices created in the last 30 days
GET /api/customer-invoices?date_from=2025-06-15 00:00:00&date_to=2025-07-15 23:59:59

# Get invoices with specific invoice dates
GET /api/customer-invoices?invoice_date_from=2025-07-01 00:00:00&invoice_date_to=2025-07-31 23:59:59

# Get recently updated invoices
GET /api/customer-invoices?updated_at_from=2025-07-14 00:00:00

Simple Filter Operations

The simple_filter[field_name] pattern supports all comparison operators on timestamp fields like created_at and updated_at, allowing for complex temporal queries.

General syntax:

GET api/[endpoint]?simple_filter[field_name]=[filter_operator],[filter_value]

Filter Operators

  • eq --> '=' (EQUALS)
  • neq --> '!=' (DOES NOT EQUAL)
  • gt --> '>' (GREATER THAN)
  • lt --> '<' (LESS THAN)
  • gte --> '>=' (GREATER THAN OR EQUAL)
  • lte --> '<=' (LESS THAN OR EQUAL)
  • like --> 'LIKE'

Examples

# Get invoices created after a specific timestamp
GET /api/customer-invoices?simple_filter[created_at]=lt,2025-07-01 00:00:00

# Get invoices updated before a specific date
GET /api/customer-invoices?simple_filter[updated_at]=gte,2022-11-02 00:00:00

State-Based Boolean Filtering

This enables filtering by operational status using parameters such as is_archived, is_booked, is_shipped, and is_creditnote, making it easy to segment data by business process states.

Examples

# Get all shipped but unbooked invoices
GET /api/customer-invoices?is_shipped=true&is_booked=false

# Get archived credit notes
GET /api/customer-invoices?is_archived=true&is_creditnote=true

🤓

Combine Filtering Options

All these filtering patterns can be combined to create highly specific queries, such as finding all invoices for customers within a specific range that were created within the last month and have been shipped but not yet booked.


Filter Behavior

  • Filters are case-insensitive
  • Search typically matches partial text across relevant fields
  • Multiple filters can be combined using the & operator
  • Empty search values return unfiltered results
  • Filters work in conjunction with pagination

Response Structure

Filtered responses maintain the same structure as unfiltered requests, including pagination metadata. The total count reflects the number of records matching your filter criteria, not the entire dataset.


Implementation Notes

When implementing filtering in your application, make sure you have accounted for:

  • URL Encode Parameters: Ensure special characters in filter values are properly encoded
  • Handle Empty Results: Be prepared for cases where filters return no matching records
  • Test Filter Combinations: Verify that multiple filters work as expected together

Filtering provides an efficient way to retrieve only the data you need from Rackbeat APIs, reducing bandwidth usage and improving application performance.




Sorting

By default, API responses are sorted descendingly (Z-A) by the entity primary key. For orders, invoices, products, customers and more, that would be the number. So it would for example list products by their number, greatest to lowest.

It is possible to change the direction, and the field, by adding query parameters to the API request.

Order Direction

By appending ?order_direction=[DIRECTION] to the request, you can change how the response is sorted. As mentioned above, by default the behavior is descending (desc), but you can change it to ascending by setting order_direction to asc.

  • Ascending: ?order_direction=asc
  • Descending: ?order_direction=desc

Order by Field

Similarly to direction, which field is sorted by can also be modified. In many cases, all fields returned by the API can be sorted. You can do this by using ?order_by=[FIELD].

Example:

GET api/customer-invoices?order_by=invoice_date