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

# Deals performance by referral source

> Pipeline metrics (won, lost, new, open $ and counts) grouped by deal referral source for the period. Empty sources are reported as "Unknown".



## OpenAPI

````yaml /api-reference/cx/swagger.json post /deals/reporting/_by_source
openapi: 3.0.0
info:
  description: CX API.
  title: CX API
  contact:
    name: API Support
    url: https://stax.ai
    email: support@stax.ai
  version: '1.0'
servers:
  - url: https://api.cx.stax.ai
security: []
paths:
  /deals/reporting/_by_source:
    post:
      tags:
        - deals
      summary: Deals performance by referral source
      description: >-
        Pipeline metrics (won, lost, new, open $ and counts) grouped by deal
        referral source for the period. Empty sources are reported as "Unknown".
      requestBody:
        $ref: '#/components/requestBodies/pkg_routes_deals_reporting.ReportingRequest'
      responses:
        '200':
          description: Per-source performance
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/pkg_routes_deals_reporting.BySourceResponse
        '400':
          description: Bad request - invalid request body
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '403':
          description: Forbidden - deals analytics not enabled
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
      security:
        - ApiKeyAuth: []
components:
  requestBodies:
    pkg_routes_deals_reporting.ReportingRequest:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/pkg_routes_deals_reporting.ReportingRequest'
      description: Reporting request
      required: true
  schemas:
    pkg_routes_deals_reporting.BySourceResponse:
      type: object
      properties:
        end_date:
          type: string
        sources:
          type: array
          items:
            $ref: '#/components/schemas/pkg_routes_deals_reporting.SourceRow'
        start_date:
          type: string
    pkg_routes_deals_reporting.ReportingRequest:
      type: object
      properties:
        assignee:
          description: empty = all reps per settings
          type: array
          items:
            type: string
        bucket_unit:
          description: 'timeseries only: day | week | month (default: by range length)'
          type: string
        compare_previous:
          type: boolean
        end_date:
          type: string
        funnel:
          description: nil = all funnels
          type: string
        start_date:
          type: string
        timezone:
          type: string
    pkg_routes_deals_reporting.SourceRow:
      type: object
      properties:
        lost_count:
          type: integer
        lost_total:
          type: number
        new_count:
          type: integer
        new_total:
          type: number
        open_count:
          type: integer
        open_total:
          type: number
        source:
          type: string
        won_count:
          type: integer
        won_total:
          type: number
  securitySchemes:
    ApiKeyAuth:
      description: CX API key. Create one in CX under Settings → Advanced → API Keys.
      in: header
      name: x-api-key
      type: apiKey

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.