Aggregate entities
aggregate_entitiesCount, sum, or group records of any weclapp entity server-side, returning only the aggregate — the tool for "how many …", "revenue per month", "top customers", and any report-style question. Never page raw rows through search_entities to compute a total.
Args: entity: weclapp entity name (same allowlist as search_entities). metrics: List of "count" (default) and/or ":" with op sum/avg/min/max over a top-level numeric field, e.g. ["count", "sum:grossAmount"]. Amounts return as decimal strings. Prefer the "*InCompanyCurrency" amount fields — sums over plain amount fields are split per currency. filters: Same typed conditions as search_entities ({"field", "op", "value"}; ISO dates auto-convert). group_by: Optional top-level field to group by, e.g. "customerId", "status", or a date field like "invoiceDate". Line items: a dotted "." folds nested items server-side, e.g. entity="salesInvoice", group_by="salesInvoiceItems.articleId", metrics=["sum:salesInvoiceItems.quantity"] (also orderItems, quotationItems, purchaseOrderItems, purchaseInvoiceItems). warehouseStockMovement accepts group_by="warehouseId". date_bucket: "month", "quarter", or "year" — required bucketing when group_by is a date field ("2026-03", "2026-Q1", "2026"). top: Max groups returned (default 20, cap 1,000), sorted by the first metric descending.
Returns: Ungrouped: {"total_matching", "metrics": {...}}. Grouped: {"total_matching", "groups": [{"key", "label"?, ...metrics, "currency"?}], "groups_total", "sorted_by"}. Plus "scanned_rows", "complete", and "skipped_non_numeric" (non-numeric rows, never folded into a sum).
More than 50,000 matching rows aborts with an error before any scan — narrow the filters (e.g. aggregate per year) and re-run. counts alone (metrics=["count"], no group_by) are a single cheap /count call with no row scan at any size.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| top | No | ||
| entity | Yes | ||
| filters | No | ||
| metrics | No | ||
| group_by | No | ||
| date_bucket | No | ||
| correlation_id | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||