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

# Users leads KPI analytics

> GET /api/v1/leads/analytics/users-leads-kpi

Compares all users by leads brought in, ranked by total leads created.

Query params (optional):
  period=today|this_week|this_month|this_year
  start_date=YYYY-MM-DD
  end_date=YYYY-MM-DD



## OpenAPI

````yaml /openapi/commercial.yaml get /api/v1/leads/analytics/users-leads-kpi
openapi: 3.0.3
info:
  title: Commercial Service API
  version: 1.0.0
  description: |2-

        **Commercial Service API** - Lead management and campaign workflow system.

        ## Versioning
        The API uses URL path versioning (e.g., `/api/v1/`, `/api/v2/`).
        Current version: **v1**
        
servers:
  - url: https://api.capedigital.co.ke/commercial
    description: Production
  - url: http://localhost:8000
    description: Local
security: []
paths:
  /api/v1/leads/analytics/users-leads-kpi:
    get:
      tags:
        - Lead Analytics
      summary: Users leads KPI analytics
      description: |-
        GET /api/v1/leads/analytics/users-leads-kpi

        Compares all users by leads brought in, ranked by total leads created.

        Query params (optional):
          period=today|this_week|this_month|this_year
          start_date=YYYY-MM-DD
          end_date=YYYY-MM-DD
      operationId: leads_analytics_users_kpi
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Lead'
              examples:
                LeadResponse:
                  value:
                    id: 3fa85f64-5717-4562-b3fc-2c963f66afa6
                    reference: LD-2024-001
                    name: ABC Corporation
                    contact_person: Jane Smith
                    contact_phone: '+254700000000'
                    contact_email: jane@abc.co.ke
                    lead_type: corporate
                    gender: F
                    lead_category:
                      id: 3fa85f64-5717-4562-b3fc-2c963f66afa6
                      name: New Business
                    source:
                      id: 3fa85f64-5717-4562-b3fc-2c963f66afa6
                      name: Cold Call
                    partner: null
                    products:
                      - id: 3fa85f64-5717-4562-b3fc-2c963f66afa6
                        name: TV Spot 30s
                    status: New Lead
                    node: capture
                    created_at: '2024-01-15T08:00:00Z'
                    updated_at: '2024-01-15T08:00:00Z'
                  summary: Lead response
          description: ''
      security:
        - bearerAuth: []
components:
  schemas:
    Lead:
      type: object
      description: Lead Serializer
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        reference:
          type: string
          nullable: true
          description: Generated reference string
          maxLength: 30
        name:
          type: string
          description: Lead company name
          maxLength: 100
        contact_person:
          type: string
          description: Contact person name
          maxLength: 100
        contact_phone:
          type: string
          description: Contact phone number
          maxLength: 30
        contact_email:
          type: string
          format: email
          description: Contact email address
          maxLength: 50
        lead_type:
          enum:
            - individual
            - company
          type: string
          x-spec-enum-id: e09fc541d8e40a52
          description: |-
            Lead classification: individual or company

            * `individual` - Individual
            * `company` - Company
        gender:
          enum:
            - male
            - female
            - ''
            - null
          type: string
          x-spec-enum-id: d6713b157e7b4bdf
          nullable: true
          description: >-
            Gender of individual lead (only applicable when lead_type is
            individual)


            * `male` - Male

            * `female` - Female
        lead_category:
          type: string
          format: uuid
        source:
          type: string
          format: uuid
        partner:
          type: string
          format: uuid
        products:
          type: array
          items:
            type: string
            format: uuid
        status:
          type: string
          readOnly: true
          description: Lead status
        node:
          type: string
          readOnly: true
          description: Workflow Node
        created_at:
          type: string
          format: date-time
          readOnly: true
        updated_at:
          type: string
          format: date-time
          readOnly: true
      required:
        - contact_email
        - contact_person
        - contact_phone
        - created_at
        - id
        - lead_category
        - name
        - node
        - products
        - source
        - status
        - updated_at
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Enter your JWT token in the format: Bearer <token>'

````