165a6d16a9a0

latestOpenAPI 3.1.02026-08-069158174.8 KB
CRM Service Calls
CRM Aggregate

Aggregate Deals

Aggregate deals/opportunities by group-by fields — ideal for dashboards, charts, and analytics.

Use this endpoint to build pipeline visualizations, revenue forecasts, and deal-stage funnels. Grouping by stage with aggregate_field: "value_of_sale" gives you a weighted pipeline view suitable for bar/funnel charts.

Request Body (AggregateRequest): Same as leads/aggregate.

Examples:

  • Pipeline by stage: {"group_by_fields": ["stage"]}
  • Pipeline value by stage: {"group_by_fields": ["stage"], "aggregate_field": "value_of_sale"}
  • Deals by source: {"group_by_fields": ["marketing_source"]}
post/crm/deals/aggregate

Request body

group_by_fieldsstring[] required

Fields to group by, e.g. ["lead_status"], ["stage", "marketing_source"]

aggregate_fieldstring nullable

Numeric field to aggregate, e.g. "value_of_sale", "estimated_budget"

match_filter_dictstring nullable

JSON-stringified MongoDB filter to narrow the dataset before aggregation

sort_dictstring nullable

JSON-stringified sort criteria, e.g. {"count": -1}

page_sizeinteger

Maximum number of groups to return

page_numinteger

Page number (1-indexed)

Response

Successful Response

total_groupsinteger

Total number of groups returned

aggregate_fieldstring nullable

The numeric field that was aggregated

group_by_fieldsstring[]

Fields that were grouped by