OfficeGest
Sales/Reports/Top customers

Get top customers by net sales

Returns the customers with the highest net sales (credit notes subtracted, VAT excluded) for the requested year, optionally narrowed to a single month. The number of customers is controlled by limit (defaults to 5, max 25) and each row carries its share of the returned set as a percentage. Sortable by total or customer_name through order/sorder.

GET
/sales/reports/top-customers
AuthorizationBearer <token>

In: header

Query Parameters

year?integer

Calendar year to aggregate. Defaults to the current year when omitted.

month?integer

Month (1-12) to narrow the aggregation. Omit to aggregate the whole year.

limit?integer

Number of customers to return (1-25). Defaults to 5.

order?string

Sort field. Allowed: total, customer_name. Defaults to total.

Value in"total" | "customer_name"
sorder?string

Sort direction (ASC, DESC). Defaults to DESC.

Value in"ASC" | "DESC"

Response Body

curl -X GET "https://og-tenant1.test:8003/api/v2/sales/reports/top-customers?year=0&month=0&limit=0&order=total&sorder=ASC"
{
  "data": {
    "year": 0,
    "month": 0,
    "customers": [
      {
        "customer_id": 0,
        "customer_name": "string",
        "total": 0,
        "percentage": 0
      }
    ],
    "total": 0
  }
}
{
  "data": {
    "code": "VALIDATION_FAILED",
    "message": "The given data was invalid.",
    "errors": {
      "email": [
        "The email field is required."
      ]
    }
  },
  "meta": {
    "trace_id": "9f86d081884c7d659a2feaa0c55ad01568f3a1c2b4d5e"
  }
}
{
  "data": {
    "code": "VALIDATION_FAILED",
    "message": "The given data was invalid.",
    "errors": {
      "email": [
        "The email field is required."
      ]
    }
  },
  "meta": {
    "trace_id": "9f86d081884c7d659a2feaa0c55ad01568f3a1c2b4d5e"
  }
}
{
  "data": {
    "code": "VALIDATION_FAILED",
    "message": "The given data was invalid.",
    "errors": {
      "email": [
        "The email field is required."
      ]
    }
  },
  "meta": {
    "trace_id": "9f86d081884c7d659a2feaa0c55ad01568f3a1c2b4d5e"
  }
}
{
  "data": {
    "code": "VALIDATION_FAILED",
    "message": "The given data was invalid.",
    "errors": {
      "email": [
        "The email field is required."
      ]
    }
  },
  "meta": {
    "trace_id": "9f86d081884c7d659a2feaa0c55ad01568f3a1c2b4d5e"
  }
}