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

# Meta Usage & Cost Monitor

> Estimate WhatsApp delivered-template usage and Meta spend from Switchbord messaging data.

# Meta Usage & Cost Monitor

Switchbord now exposes two related Meta usage surfaces:

* **Insights → Billing** (`/insights`, Billing tab) — reads Meta WABA `pricing_analytics` and `analytics` into local daily rollup tables, then shows messages sent/delivered, delivered-by-category, free vs paid splits, and approximate total charges in the WABA currency.
* **Settings → Usage** (`/settings/usage`) — an operational estimate view based on Switchbord messaging data and campaign attribution.

<Info>
  Meta usage totals are operational estimates. Meta invoices, billing exports, and account-level Meta billing tools remain the source of truth for settlement.
</Info>

## What Insights → Billing shows

* **Messages sent / delivered** — from the WABA `analytics` field.
* **Delivered by category** — from `pricing_analytics` category rows such as `MARKETING`, `UTILITY`, `AUTHENTICATION`, and `SERVICE`.
* **Free vs paid** — splits `FREE_CUSTOMER_SERVICE`, `FREE_ENTRY_POINT`, and paid `REGULAR` rows.
* **Approximate total charges** — summed from `pricing_analytics.cost` in the WABA currency.

## What Settings → Usage shows

* **Estimated Meta cost** — calculated from delivered template messages and the configured rate table.
* **Delivered templates** — chargeable template deliveries for marketing, utility, and authentication categories.
* **Read rate** — read events divided by delivered template messages for the selected window.
* **Free messages** — inbound freeform and service-window traffic counted separately from paid template delivery.
* **Spend trend** — daily estimated cost alongside delivered template volume.
* **Cost by category** — marketing, utility, authentication, and service buckets.
* **Campaign attribution** — delivered template volume, read rate, and estimated cost per campaign.

## Windows

The dashboard supports three windows:

* `7d` — last seven days.
* `30d` — last thirty days.
* `MTD` — current month to date.

Switchbord fetches each window separately server-side so the tab labels do not relabel the same dataset.

## Data sources

The monitor reads workspace-scoped data from:

* `messaging_events` when events already include status, category, country, and campaign metadata.
* `messages`, `templates`, `contacts`, and `campaign_recipients` as a fallback so existing workspaces can still estimate usage while richer messaging event payloads roll out.

Every query is scoped by `workspace_id` resolved from the authenticated operator session.

## Pricing model

Switchbord follows Meta's post-July-2025 delivered-template pricing shape:

* Delivered template messages can be chargeable.
* Freeform service-window traffic is counted separately.
* Rates vary by template category and recipient country/calling-code region.

<Warning>
  The initial implementation includes an operational rate table for estimates. Keep the rate table versioned and reconcile with Meta billing exports before using the numbers for invoicing or customer pass-through billing.
</Warning>

## Campaign attribution

Campaign rows are derived from `campaign_recipients.message_id` and message delivery state. Use this view to identify which tourism campaign, re-engagement flow, or booking reminder is driving current Meta spend.

## Follow-ups

* Import a complete versioned Meta rate table by country/calling-code and effective date.
* Add explicit billing export reconciliation against Meta invoices.
* Store richer status payloads at the messaging-event write path so fallback joins can be reduced over time.
* Add CSV export for finance and customer success reviews.
