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

# Get Messages

> Returns an organization's WhatsApp message analytics: summary cards at the top and a time series below.

The source is ClickHouse with no caching, so every request returns the most up-to-date data. Scope it org-wide (all apps) or to selected apps, and bucket it by a date range and a granularity.

**Invariants.** `Σ series[].sentMessages == summary.sentMessages`, and the same holds for `templateMessages` and `receivedMessages`. `templateMessages` never exceeds `sentMessages`.



## OpenAPI

````yaml /public-openapi.json get /wa/analytics/messages
openapi: 3.0.3
info:
  title: Connexease Public API
  version: 1.0.0
  description: >-
    Panel-independent API for managing WhatsApp Business operations from your
    own servers.


    Every endpoint is scoped to the organization resolved from your secret key.
    Read endpoints are uncached and proxy straight to the source.


    **On-premises installations** are served from your own domain with an extra
    `/public` segment: `https://{your_domain}/public/api/v1/...`.
    Authentication, bodies, responses, and error codes are identical.
servers:
  - url: https://public-api.gateway.connexease.com/api/v1
    description: Production
security:
  - secretKey: []
tags:
  - name: Analytics
    description: Organization-wide message volume.
  - name: Application
    description: The WhatsApp business profile linked to an application.
  - name: Template
    description: >-
      The full template lifecycle: create, list, inspect, update, delete, and
      measure.
  - name: Media
    description: >-
      Uploads that produce the single-use handle for template headers and the
      profile picture.
  - name: Developers
    description: Webhook configuration and API keys.
paths:
  /wa/analytics/messages:
    get:
      tags:
        - Analytics
      summary: Get Messages
      description: >-
        Returns an organization's WhatsApp message analytics: summary cards at
        the top and a time series below.


        The source is ClickHouse with no caching, so every request returns the
        most up-to-date data. Scope it org-wide (all apps) or to selected apps,
        and bucket it by a date range and a granularity.


        **Invariants.** `Σ series[].sentMessages == summary.sentMessages`, and
        the same holds for `templateMessages` and `receivedMessages`.
        `templateMessages` never exceeds `sentMessages`.
      operationId: getMessageAnalytics
      parameters:
        - name: appId
          in: query
          required: false
          description: >-
            Repeatable. Omit to include every app in the organization, or repeat
            it (`?appId=app_AAA&appId=app_BBB`) to scope to specific apps. An ID
            that does not belong to the organization returns `404`.
          schema:
            type: array
            items:
              type: string
          style: form
          explode: true
        - name: startDate
          in: query
          required: false
          description: >-
            ISO-8601 datetime. Start of the range. Defaults to today 00:00:00
            UTC.
          schema:
            type: string
            format: date-time
            example: '2026-06-01T00:00:00'
        - name: endDate
          in: query
          required: false
          description: >-
            ISO-8601 datetime. End of the range; must be greater than
            `startDate`. Defaults to today 23:59:59 UTC.
          schema:
            type: string
            format: date-time
            example: '2026-06-08T00:00:00'
        - name: granularity
          in: query
          required: false
          description: How the `series` is bucketed. Any other value returns `422`.
          schema:
            type: string
            enum:
              - hourly
              - daily
              - weekly
              - monthly
            default: daily
      responses:
        '200':
          description: Summary totals plus the bucketed series.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      summary:
                        $ref: '#/components/schemas/MessageCounts'
                      series:
                        type: array
                        items:
                          allOf:
                            - type: object
                              properties:
                                timestamp:
                                  type: string
                                  description: >-
                                    Bucket start time in ISO format; resolution
                                    reflects `granularity`.
                            - $ref: '#/components/schemas/MessageCounts'
                  isSuccess:
                    type: boolean
                    enum:
                      - true
              example:
                data:
                  summary:
                    totalMessages: 845
                    sentMessages: 600
                    receivedMessages: 245
                    templateMessages: 410
                  series:
                    - timestamp: '2026-06-01T00:00:00'
                      totalMessages: 300
                      sentMessages: 210
                      receivedMessages: 90
                      templateMessages: 150
                    - timestamp: '2026-06-02T00:00:00'
                      totalMessages: 280
                      sentMessages: 200
                      receivedMessages: 80
                      templateMessages: 140
                isSuccess: true
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: >-
            One or more `appId` values do not belong to the organization
            (`APPLICATION_004`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '422':
          description: >-
            `endDate` is not after `startDate` (`VAL_019`), or an invalid
            `granularity` or unparseable date was sent.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
              example:
                errors:
                  code: VAL_019
                  group: VALIDATION
                  description: Invalid date range.
                isSuccess: false
        '502':
          description: ClickHouse unreachable or query error (`SYS_001`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
components:
  schemas:
    MessageCounts:
      type: object
      properties:
        totalMessages:
          type: integer
          description: '`sentMessages` + `receivedMessages`.'
        sentMessages:
          type: integer
          description: Outbound messages.
        receivedMessages:
          type: integer
          description: Inbound messages.
        templateMessages:
          type: integer
          description: >-
            Outbound messages that used a template. Never exceeds
            `sentMessages`.
    ErrorEnvelope:
      type: object
      description: >-
        Every failure shares this shape. `description` already has any `params`
        interpolated into it.
      properties:
        isSuccess:
          type: boolean
          enum:
            - false
        errors:
          type: object
          properties:
            code:
              type: string
              description: >-
                `VAL_*`, `WA_*`, `META_*`, `APPLICATION_*`,
                `ORGANIZATION_SECRET_*`, `REQ_001`, or `SYS_001`.
              example: META_075
            group:
              type: string
              enum:
                - VALIDATION
                - NOT_FOUND
                - CONFLICT
                - AUTHENTICATION
                - NOT_ALLOWED
                - LIMIT_EXCEEDED
                - SERVICE_UNAVAILABLE
                - SYSTEM
            description:
              type: string
              example: Template with 0000000000 not found in Meta.
            params:
              type: object
              additionalProperties: true
              description: >-
                Raw values interpolated into `description`. Present only on
                parametric messages.
            fields:
              type: object
              description: >-
                Field-level validation errors only. Field name (dot-joined for
                nested fields, list indices omitted) to its own `code` /
                `description` / `params`.
              additionalProperties:
                type: object
                properties:
                  code:
                    type: string
                  description:
                    type: string
                  params:
                    type: object
                    additionalProperties: true
          required:
            - code
            - group
            - description
      required:
        - isSuccess
        - errors
  responses:
    Unauthorized:
      description: >-
        Secret key missing (`ORGANIZATION_SECRET_010`) or invalid
        (`ORGANIZATION_SECRET_011`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
  securitySchemes:
    secretKey:
      type: http
      scheme: bearer
      description: >-
        Secret key in `Bearer sk_...` format. Server-to-server only — never
        embed it in a browser or mobile client. The organization is resolved
        from the key, so `organization_id` is never passed explicitly.

````