Monetization
Monetization Programmatic Quotas
Beta Feature
The monetization feature is currently in beta and is subject to change. There may be bugs and issues that are not yet resolved. Use with caution and please report any issues to support.
When adding monetization to your API, you would usually set the number of meters
a request will consume in the settings of the
Monetization Policy. For
example, the policy below specifies that each request will consume 1 requests
meter and 5 computeUnits
meters.
However, in some cases, you may not know up front how many units of a particular
meter will be consumed until after the response is sent. For example, maybe your
backend is responsible for computing the computeUnits
on a request and send
the result in the response in the compute-units
header.
In Zuplo, you can support these dynamic meters by writing a little code. To make
the computeUnits
meter dynamic, first update the policy by setting the
computeUnits
meter to 0
as shown below.
Next you can create a
custom code outbound policy that reads
data from the Response (in this case the compute-units
header) and sets the
meter programmatically.