> ## 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.

# Stalled deals — open leads sitting too long in their current stage

> Powers the **Stalled deals** panel on the **Leads & pipeline** screen — the operational counterpart to pipeline velocity. Velocity gives average time-in-stage; this lists the specific open deals that have exceeded the threshold and need working now.

Current-state query: a deal's time-in-stage is measured from its most recent workflow transition to now, so it takes a `threshold_days` cut-off, not a period.

| Field | Meaning |
|---|---|
| `total_stalled` | Open deals past the threshold |
| `stages[].count` / `value` | Stalled deals and their open value per stage |
| `deals[]` | The stalled deals (capped), worst first by days-in-stage |



## OpenAPI

````yaml /openapi/commercial.yaml get /api/v1/analytics/sales/stalled-deals
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/analytics/sales/stalled-deals:
    get:
      tags:
        - Pipeline
      summary: Stalled deals — open leads sitting too long in their current stage
      description: >-
        Powers the **Stalled deals** panel on the **Leads & pipeline** screen —
        the operational counterpart to pipeline velocity. Velocity gives average
        time-in-stage; this lists the specific open deals that have exceeded the
        threshold and need working now.


        Current-state query: a deal's time-in-stage is measured from its most
        recent workflow transition to now, so it takes a `threshold_days`
        cut-off, not a period.


        | Field | Meaning |

        |---|---|

        | `total_stalled` | Open deals past the threshold |

        | `stages[].count` / `value` | Stalled deals and their open value per
        stage |

        | `deals[]` | The stalled deals (capped), worst first by days-in-stage |
      operationId: analytics_sales_stalled_deals_retrieve
      parameters:
        - in: query
          name: threshold_days
          schema:
            type: integer
          description: >-
            Days in current stage before a deal counts as stalled. Defaults to
            14.
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StalledDeals'
              examples:
                14-dayThreshold:
                  value:
                    threshold_days: 14
                    total_stalled: 7
                    stages:
                      - key: proposal
                        label: Proposal
                        count: 4
                        value: '5200000.00'
                      - key: contract
                        label: Contract
                        count: 3
                        value: '3100000.00'
                    deals:
                      - lead_id: 3f6c1e2a-0000-0000-0000-000000000001
                        stage: proposal
                        days_in_stage: '41.2'
                        value: '1800000.00'
                  summary: 14-day threshold
          description: ''
      security:
        - bearerAuth: []
components:
  schemas:
    StalledDeals:
      type: object
      properties:
        threshold_days:
          type: integer
        total_stalled:
          type: integer
        stages:
          type: array
          items:
            $ref: '#/components/schemas/StalledStage'
        deals:
          type: array
          items:
            $ref: '#/components/schemas/StalledDeal'
      required:
        - deals
        - stages
        - threshold_days
        - total_stalled
    StalledStage:
      type: object
      properties:
        key:
          type: string
        label:
          type: string
        count:
          type: integer
        value:
          type: string
          format: decimal
          pattern: ^-?\d{0,13}(?:\.\d{0,2})?$
      required:
        - count
        - key
        - label
        - value
    StalledDeal:
      type: object
      properties:
        lead_id:
          type: string
        stage:
          type: string
        days_in_stage:
          type: string
          format: decimal
          pattern: ^-?\d{0,9}(?:\.\d{0,1})?$
        value:
          type: string
          format: decimal
          pattern: ^-?\d{0,13}(?:\.\d{0,2})?$
      required:
        - days_in_stage
        - lead_id
        - stage
        - value
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Enter your JWT token in the format: Bearer <token>'

````