Metering & Billing

Enterprise only

Capture department and project as billing dimensionsv3.14+

This example enriches usage events with department and project dimensions pulled from request headers. These attributes are included in the event data payload and can be used to apply tiered pricing rules, enforce per-department usage budgets, or produce internal chargeback reports.

For example, a request with x-department: engineering and x-project: search produces an event containing "department": "engineering" and "project": "search" in its data. If a header is absent on a given request, that attribute is omitted from that event.

To aggregate usage and generate invoices, you need either Konnect Metering & Billing or a self-hosted OpenMeter instance.

Prerequisites

  • Your API clients must pass x-department and x-project headers on requests you want to track by dimension.

  • An authentication plugin (for example, Key Auth or JWT) is configured on the same Gateway Service or Route so that a Consumer is present on each request.

  • A Konnect system account token (spat_) or OpenMeter API key to use as the auth_token.

Environment variables

  • AUTH_TOKEN: A Konnect system account token (spat_) or OpenMeter API key.

Set up the plugin

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!