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

# Weighted pipeline forecast — probability-adjusted expected revenue

> Powers the **Forecast** KPI on the **Overview** and **Leads & pipeline** screens.

`pipeline_value` is the raw sum of open deals' latest approved contract value — it over-states what will land because it weights an early lead the same as one about to sign. `weighted_forecast` weights each stage's value by its win probability, so it is the number to plan the quarter against.

| Field | Meaning |
|---|---|
| `stages[].value` | Raw open value at the stage |
| `stages[].win_probability` | Probability a deal at this stage commits |
| `stages[].weighted_value` | `value × win_probability` |
| `weighted_forecast` | Sum of `weighted_value` across stages |



## OpenAPI

````yaml /openapi/commercial.yaml get /api/v1/analytics/sales/forecast
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/forecast:
    get:
      tags:
        - Pipeline
      summary: Weighted pipeline forecast — probability-adjusted expected revenue
      description: >-
        Powers the **Forecast** KPI on the **Overview** and **Leads & pipeline**
        screens.


        `pipeline_value` is the raw sum of open deals' latest approved contract
        value — it over-states what will land because it weights an early lead
        the same as one about to sign. `weighted_forecast` weights each stage's
        value by its win probability, so it is the number to plan the quarter
        against.


        | Field | Meaning |

        |---|---|

        | `stages[].value` | Raw open value at the stage |

        | `stages[].win_probability` | Probability a deal at this stage commits
        |

        | `stages[].weighted_value` | `value × win_probability` |

        | `weighted_forecast` | Sum of `weighted_value` across stages |
      operationId: analytics_sales_forecast_retrieve
      parameters:
        - in: query
          name: period
          schema:
            type: string
          description: |-
            Period string. Accepted formats:
            - `2026-05` — calendar month
            - `Q2-2026` — quarter (Q1–Q4)
            - `YTD-2026` — year to date
          required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PipelineForecast'
              examples:
                May2026:
                  value:
                    pipeline_value: '18400000.00'
                    weighted_forecast: '6120000.00'
                    stages:
                      - key: proposal
                        label: Proposal
                        count: 16
                        value: '7200000.00'
                        win_probability: 0.4
                        weighted_value: '2880000.00'
                      - key: deal_closing
                        label: Deal Closing
                        count: 3
                        value: '3400000.00'
                        win_probability: 0.95
                        weighted_value: '3230000.00'
                  summary: May 2026
          description: ''
      security:
        - bearerAuth: []
components:
  schemas:
    PipelineForecast:
      type: object
      properties:
        pipeline_value:
          type: string
          format: decimal
          pattern: ^-?\d{0,13}(?:\.\d{0,2})?$
        weighted_forecast:
          type: string
          format: decimal
          pattern: ^-?\d{0,13}(?:\.\d{0,2})?$
        stages:
          type: array
          items:
            $ref: '#/components/schemas/ForecastStage'
      required:
        - pipeline_value
        - stages
        - weighted_forecast
    ForecastStage:
      type: object
      properties:
        key:
          type: string
        label:
          type: string
        count:
          type: integer
        value:
          type: string
          format: decimal
          pattern: ^-?\d{0,13}(?:\.\d{0,2})?$
        win_probability:
          type: number
          format: double
        weighted_value:
          type: string
          format: decimal
          pattern: ^-?\d{0,13}(?:\.\d{0,2})?$
      required:
        - count
        - key
        - label
        - value
        - weighted_value
        - win_probability
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Enter your JWT token in the format: Bearer <token>'

````