> ## Documentation Index
> Fetch the complete documentation index at: https://dench.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate report

> Generate a CRM report.



## OpenAPI

````yaml /api-reference/openapi.json post /crm/reports
openapi: 3.1.0
info:
  title: Dench API
  version: 1.0.0
  description: >-
    Versioned Dench workspace API. The operation registry is shared with the
    Dench CLI parity layer, so every CLI command maps to an endpoint here.
servers:
  - url: https://www.dench.com/api/v1
security: []
tags:
  - name: agent-config
    description: Agent Config operations.
  - name: approvals
    description: Approvals operations.
  - name: apps
    description: Apps operations.
  - name: auth
    description: Auth operations.
  - name: billing
    description: Billing operations.
  - name: browser
    description: Browser operations.
  - name: chat
    description: Chat operations.
  - name: crm
    description: Crm operations.
  - name: email
    description: Email operations.
  - name: files
    description: Files operations.
  - name: gateway
    description: Gateway operations.
  - name: local
    description: Local operations.
  - name: memory
    description: Memory operations.
  - name: meta
    description: Meta operations.
  - name: routines
    description: Routines operations.
  - name: workspace
    description: Workspace operations.
paths:
  /crm/reports:
    post:
      tags:
        - crm
      summary: Generate report
      description: Generate a CRM report.
      operationId: crm_reports_generate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                objectName:
                  type: string
                type:
                  type: string
                  enum:
                    - pie
                    - bar
                    - line
                    - table
                  description: Chart type for the generated report.
                groupByField:
                  type: string
                metric:
                  type: string
                  enum:
                    - count
                    - sum
                    - avg
                    - min
                    - max
                  description: Aggregation metric. Defaults to `count`.
                metricField:
                  type: string
              required:
                - objectName
                - type
                - groupByField
            example:
              objectName: string
              type: pie
              groupByField: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  spec:
                    type: object
                    properties:
                      objectName:
                        type: string
                      type:
                        type: string
                        enum:
                          - pie
                          - bar
                          - line
                          - table
                        description: Chart type for the generated report.
                      groupByField:
                        type: string
                      metric:
                        type: string
                        enum:
                          - count
                          - sum
                          - avg
                          - min
                          - max
                        description: Aggregation metric. Defaults to `count`.
                      metricField:
                        type: string
                    required:
                      - objectName
                      - type
                      - groupByField
                      - metric
                    additionalProperties: false
                  buckets:
                    type: array
                    items:
                      type: object
                      properties:
                        key:
                          type: string
                        label:
                          type: string
                        count:
                          type: number
                        sum:
                          type: number
                        avg:
                          type: number
                      required:
                        - key
                        - label
                        - count
                      additionalProperties: false
                  totalCount:
                    type: number
                required:
                  - spec
                  - buckets
                  - totalCount
                additionalProperties: false
              example:
                spec:
                  objectName: lead
                  type: bar
                  groupByField: Status
                  metric: count
                buckets:
                  - key: New
                    label: New
                    count: 12
                    sum: 0
                    avg: 0
                  - key: Qualified
                    label: Qualified
                    count: 8
                    sum: 640
                    avg: 80
                totalCount: 20
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - DenchApiKey: []
        - AgentSession: []
components:
  responses:
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    Unauthorized:
      description: Missing or invalid authentication
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    NotFound:
      description: Operation or resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    InternalError:
      description: Server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
  schemas:
    ApiError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
            - type
            - code
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type: string
            details: {}
  securitySchemes:
    DenchApiKey:
      type: http
      scheme: bearer
      bearerFormat: DENCH_API_KEY
      description: >-
        Workspace-scoped Dench API key from workspace settings. This is the same
        key used by DENCH_API_KEY in sandboxes.
    AgentSession:
      type: http
      scheme: bearer
      bearerFormat: dch_agent_*
      description: >-
        Agent session token created by `dench signin`. Gateway-backed routes
        exchange this token for the workspace gateway key.

````