Latest archived orders

POST https://{{subdomain}}.commercelayer.io/metrics/orders/search

The problem

You want to get the latest 100 orders that have been recently archived, over a selected date and time range, chronologically ordered by date of archival.

The solution

Query

You need to perform a search query setting the required query keys as follows and adding the optional ones based on your needs:

KeyValue
limit10
sort_byorder.archived_at

If you want to focus on some specific information about the carts you're searching for, just fill in the fields array with the list of attributes you want to get in the response.

Filter

Make sure to set the desired date and time range using the date_from and date_to keys in the filter or as your environment variables

Add an additional filter on the line items field to restrict the related search on carts that contain the selected SKU only:

AttributeOperator
archivedtrue

In this example, since we use archived_at as the date_field, you'll get in the response all the orders that were archived within the selected date and time range (read more about this).

Request Body

{"search"=>{"limit"=>100, "sort"=>"desc", "sort_by"=>"order.archived_at", "fields"=>["order.id", "order.number", "order.archived_at"]}, "filter"=>{"order"=>{"date_from"=>"{{date_from}}", "date_to"=>"{{date_to}}", "date_field"=>"archived_at", "archived"=>true}}}

HEADERS

KeyDatatypeRequiredDescription
Acceptstring
Content-Typestring