---
title: "Generate report"
method: POST
path: "/crm/reports"
tags: ["crm"]
---

# Generate report

`POST /crm/reports`

## Request

- Base URL: `https://www.dench.com/api/v1`
- URL: `https://www.dench.com/api/v1/crm/reports`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer

Generate a CRM report.

## Request body

- object
  - `objectName` string, required
  - `type` 'pie' | 'bar' | 'line' | 'table', required: Chart type for the generated report.
  - `groupByField` string, required
  - `metric` 'count' | 'sum' | 'avg' | 'min' | 'max': Aggregation metric. Defaults to `count`.
  - `metricField` string: Number field to sum/avg per bucket (e.g. Amount grouped by Stage). Defaults to the group field itself.

## Response `200`

Successful response

- object
  - `spec` object, required
    - `objectName` string, required
    - `type` 'pie' | 'bar' | 'line' | 'table', required: Chart type for the generated report.
    - `groupByField` string, required
    - `metric` 'count' | 'sum' | 'avg' | 'min' | 'max', required: Aggregation metric. Defaults to `count`.
    - `metricField` string
  - `buckets` object[], required
    - `key` string, required
    - `label` string, required
    - `count` number, required
    - `sum` number
    - `avg` number
  - `totalCount` number, required
  - `truncated` boolean: True when a bounded row scan (not the exact pre-aggregates) produced the sums.

## Other responses

- `400`: Invalid request
- `401`: Missing or invalid authentication
- `404`: Operation or resource not found
- `500`: Server error

---

[API](https://skmtc.dev/dench/apis/dench-api.md) - [All operations](https://skmtc.dev/dench/apis/dench-api/llms.txt) - [OpenAPI document](https://skmtc.dev/dench/apis/dench-api/revisions/4a145b38f19c?raw)
