OfficeGest
Sales/Reports/Top debtors

List the customers who owe the most

Returns the customers whose current account balance is still in debt, aggregated per customer (sum of debits minus sum of credits) and truncated to limit (default 25, max 100). Mirrors the legacy dashboard widget: customers flagged as litigious are excluded and only balances above 0.01 are reported, so every row is a real debt. Ordered by balance descending by default, and sortable by balance, customer_name or customer_id through order/sorder. Unlike the customer invoices due report, the rows are not restricted by billing series, because the legacy query this replaces has no such gate.

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

In: header

Query Parameters

limit?integer

Number of debtors to return (1-100). Defaults to 25.

order?string

Sort field. Allowed: balance, customer_name, customer_id. Defaults to balance.

Value in"balance" | "customer_name" | "customer_id"
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-debtors?limit=0&order=balance&sorder=ASC"
{
  "data": [
    {
      "customer_id": 0,
      "customer_name": "string",
      "customer_tax_id": "string",
      "balance": 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"
  }
}