Metering
Use this page to enforce usage-based limits through assigned license features and the runtime consume route.
Who This Is For
- teams shipping usage-based or credit-based licensing
- developers implementing feature quotas
- operators who need usage evidence for reporting and exports
When To Use This
Use metering when the primary control is consumed usage, not just time or device count.
Metering is layered on top of feature assignments. It is not a billing engine by itself.
How It Works
The metering flow is:
- create a feature on the product
- assign that feature to a license
- optionally set
max_consumptions - call
POST /api/v1/license/consumeat runtime - use
POST /api/v1/licenses/{id}/usage/resetto reset or top up usage
Important rules:
consumeuses runtime license authconsumerequiresIdempotency-Key- usage reset is a management route
- reporting reads and exports are the downstream evidence surface for consumed usage
Example
Assign a metered feature:
bash
curl -X POST https://api.licensekit.dev/api/v1/licenses/lic_123/features \
-H "Authorization: Bearer $LICENSEKIT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"feature_id": "feat_api_calls",
"max_consumptions": 1000
}'Consume one unit:
bash
curl -X POST https://api.licensekit.dev/api/v1/license/consume \
-H "Authorization: License $LICENSE_KEY" \
-H "Idempotency-Key: consume-evt-123" \
-H "Content-Type: application/json" \
-d '{
"fingerprint": "workstation-01",
"feature_code": "api_calls",
"amount": 1,
"event_id": "evt_123"
}'Common Mistakes
- assuming
consumptionlicense type alone creates quotas without feature assignments - forgetting
Idempotency-Keyon the runtime consume route - treating metering as a billing engine instead of entitlement enforcement plus evidence
- using live totals as a substitute for the reporting ledger when period-aware evidence matters