Examples

How to perform Metrics API queries on the return resource

Breakdown

The following request performs a breakdown query on the return resource:

curl -g -X POST \
  'https://{{your_domain}}.commercelayer.io/metrics/returns/breakdown' \
  -H 'Accept: application/vnd.api.v1+json' \
  -H 'Content-Type: application/vnd.api+json' \
  -H 'Authorization: Bearer {{your_access_token}}' \
  -d '{
    "breakdown": {
        "by": "organization.id",
        "field": "return.id",
        "operator": "value_count",
        "sort": "desc",
        "limit": 5,
        "breakdown": {
            "by": "market.id",
            "field": "customer.id",
            "operator": "value_count",
            "sort": "asc",
            "limit": 10
        }
    },
    "filter": {
        "return": {
            "date_from": "2021-05-30T00:00:00Z",
            "date_to": "2022-05-30T23:59:00Z",
            "date_field": "created_at"
        },
        "market": {
          "names": {
            "in": ["USA"]
          }
        }
    }
}'

Date breakdown

The following request performs a date breakdown query on the return resource:

Stats

The following request performs a stats query on the return resource:

The following request performs a search query on the return resource:

Last updated