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

# Statystyki kampanii

> Zwraca statystyki połączeń kampanii: jeden wiersz na połączenie oraz liczniki kolejki.



## OpenAPI

````yaml /api-reference/openapi.pl.json get /api/v1/campaigns/{campaign_id}/analytics
openapi: 3.1.0
info:
  title: Brosbots API
  description: >
    Publiczne REST API Brosbots. Buduj i zarządzaj agentami głosowymi,

    uruchamiaj kampanie wychodzące, odczytuj rozmowy i zużycie oraz zarządzaj

    numerami telefonów, narzędziami, bazami wiedzy i integracjami.


    ## Uwierzytelnianie


    Każde żądanie musi zawierać klucz API organizacji w nagłówku `X-API-Key`:


    ```

    X-API-Key: bb_live_...

    ```


    Klucze tworzysz i unieważniasz w panelu: kliknij swoje konto w lewym dolnym
    rogu paska bocznego, a potem **Brosbots API**.


    ## Adres bazowy


    ```

    https://app.brosbots.com/api/v1

    ```


    ## Konwencje


    - Ciała żądań i odpowiedzi są w JSON (`Content-Type: application/json`).

    - Znaczniki czasu w ISO 8601 ze strefą czasową.

    - Listy stronicowane parametrami `page` / `limit`; odpowiedź zawiera
      `total_count` / `total_pages`.
    - Błędy używają standardowych kodów HTTP z ciałem JSON:
      `{"detail": "czytelny powód błędu"}`.
    - `{agent_id}` przyjmuje publiczne ID agenta (`agent_...`) albo jego numer.


    ## Limity


    API nie ma dziś stałego limitu liczby zapytań na klucz. Kod `429` zwracają

    endpointy dzwoniące (`POST /agents/{agent_id}/calls` i

    `POST /triggers/{trigger_id}/calls`), gdy wszystkie kanały wychodzące są
    zajęte; nagłówek `Retry-After` podaje, ile sekund odczekać.

    Obsługuj `429` ogólnie: czekaj tyle, ile mówi `Retry-After`, a gdy go nie ma
    -

    ponawiaj z wykładniczym odstępem. Limit zapytań może zostać wprowadzony.
  version: 1.0.0
servers: []
security:
  - ApiKeyAuth: []
paths:
  /api/v1/campaigns/{campaign_id}/analytics:
    get:
      tags:
        - Kampanie
      summary: Statystyki kampanii
      description: >-
        Zwraca statystyki połączeń kampanii: jeden wiersz na połączenie oraz
        liczniki kolejki.
      operationId: get_campaigns_campaign_id_analytics
      parameters:
        - name: campaign_id
          in: path
          required: true
          schema:
            type: integer
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
        - name: X-API-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
      responses:
        '200':
          description: Pomyślna odpowiedź
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CampaignAnalyticsResponse'
        '404':
          description: Nie znaleziono
        '422':
          description: Błąd walidacji
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    CampaignAnalyticsResponse:
      properties:
        campaign_id:
          type: integer
        state:
          type: string
        total_rows:
          anyOf:
            - type: integer
            - type: 'null'
        processed_rows:
          type: integer
          default: 0
        failed_rows:
          type: integer
          default: 0
        started_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        completed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        queue:
          $ref: '#/components/schemas/CampaignQueueStats'
        runs:
          items:
            $ref: '#/components/schemas/CampaignCallStat'
          type: array
      type: object
      required:
        - campaign_id
        - state
        - queue
        - runs
      title: CampaignAnalyticsResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
      type: object
      title: HTTPValidationError
    CampaignQueueStats:
      properties:
        queued:
          type: integer
          default: 0
        processed:
          type: integer
          default: 0
        failed:
          type: integer
          default: 0
        retries:
          type: integer
          default: 0
        retry_reasons:
          additionalProperties:
            type: integer
          type: object
        pending_retries:
          type: integer
          default: 0
      type: object
      title: CampaignQueueStats
    CampaignCallStat:
      properties:
        id:
          type: integer
        workflow_id:
          type: integer
        created_at:
          anyOf:
            - type: string
            - type: 'null'
        is_completed:
          type: boolean
          default: false
        state:
          anyOf:
            - type: string
            - type: 'null'
        credit_usage:
          type: number
          default: 0
        call_duration_seconds:
          type: integer
          default: 0
        charge_usd:
          anyOf:
            - type: number
            - type: 'null'
        phone_number:
          anyOf:
            - type: string
            - type: 'null'
        disposition:
          anyOf:
            - type: string
            - type: 'null'
        recording_url:
          anyOf:
            - type: string
            - type: 'null'
        gathered_context:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
      type: object
      required:
        - id
        - workflow_id
      title: CampaignCallStat
      description: Jedno połączenie kampanii z polami używanymi w statystykach.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
        msg:
          type: string
        type:
          type: string
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: Klucz API organizacji (konto w lewym dolnym rogu panelu → Brosbots API).

````

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