Skip to main content
Version: Next

API Quotas with Header Filters

API Quotas with Header Filters enable precise control over API usage by setting limits based on request headers, rather than just URLs. This allows for more flexible quota management, such as distinguishing between environments or customer tiers, ensuring resources are allocated efficiently and tailored to specific needs.

Group Configuration: Production vs. Staging

This configuration defines two user groups, production and staging, with different quota limits. The production group receives a higher quota than the staging group to reflect the greater resource needs of production environments.

/etc/lunar-proxy/quotas/{fileName}.yaml
quota:
id: LimiterMonth
filter:
url: api.website.com/*
strategy:
fixed_window:
max: 10000000
interval: 1
interval_unit: month
monthly_renewal:
day: 1
hour: 11
minute: 0
second: 0
timezone: UTC

internal_limits:
- id: ProductionQuota
parent_id: LimiterMonth
filter:
headers:
- key: x-lunar-consumer-tag
value: production
strategy:
fixed_window:
max: 10000
interval: 1
interval_unit: day

- id: StagingQuota
parent_id: LimiterMonth
filter:
headers:
- key: x-lunar-consumer-tag
value: staging
strategy:
fixed_window:
max: 2000
interval: 1
interval_unit: day