Prepaid credits

This feature is currently in Beta and should not be used in a production environment.

Credits are customer-specific value that can be used to pay for charges. They are useful for prepaid plans, promotional balances, migration credits, enterprise commitments, or any workflow where a customer consumes a balance before paying by invoice.

A credit balance is always tied to a customer and a currency. For example, a customer can have a USD credit balance and an EUR credit balance. Charges consume credits from the matching currency balance.

For an end-to-end tutorial on setting up prepaid credits, see Get started with prepaid credits.

How it works

The credit system works as follows:

  • Credit grants add credits to a customer balance. A grant can be promotional, funded through a Metering & Billing invoice, or funded externally.
  • Balances show how much credit the customer has. There is a settled balance from committed ledger movements, and a pending balance that accounts for open charges.
  • Charges consume credits. The settlement mode on the rate card controls whether credits are applied before invoicing or whether the full charge must be covered by credits.
  • Transaction history explains balance changes. Credit transaction history shows customer-facing movements: funded, consumed, and expired.

Core concepts

Credits flow through a lifecycle of funding, consumption, and expiration. The following terms describe the key entities and states involved:

Term

Definition

Reference

Credit A customer-specific monetary value that can be applied to charges to reduce the amount charged on an invoice. Credit grants
Grant The object that adds credits to a customer balance. Credit grants
Priority A numeric field on a grant that controls draw-down order. Grants with lower priority values are consumed first. Credit grants
Settled balance The committed ledger balance at a given point in time. Reflects only finalized movements (funded, consumed, expired). Doesn’t include open charges. Credit balance model
Pending balance A pessimistic balance of available credits. Includes the settled balance minus any open (in-flight) charges that have not yet been finalized. Credit balance model
Movement A record of a credit change. Movements are immutable: when something changes, a new movement is recorded instead of rewriting the old one. The balance is derived from the sum of all movements. Credit transaction history
Funded transaction A positive credit movement recorded when a grant is issued. Appears as a positive amount in transaction history. Credit transaction history
Consumed transaction A negative credit movement recorded when credits are applied to a charge. Appears as a negative amount in transaction history. Credit transaction history
Expiration Removal of unused credits at the grant’s expiration time. Credit consumption and expiration

Movements and transaction history

Credits are not a mutable counter. Metering & Billing records credit movements over time. When something changes, such as usage being corrected or credit expiring, the system records another movement instead of rewriting the old one. The balance is the result of the movements that are visible at the time you query it.

Assume a customer receives 100 USD in credits:

grant 100 USD credits

The customer’s settled credit balance becomes 100 USD. If the customer later uses 30 USD of credits, the balance becomes 70 USD:

grant 100 USD credits
consume 30 USD credits
remaining settled balance: 70 USD

If the original grant expires and 70 USD remains unused, the unused amount expires and the balance becomes 0 USD:

grant 100 USD credits
consume 30 USD credits
expire 70 USD unused credits
remaining settled balance: 0 USD

The customer-facing transaction history shows the same story as signed movements:

Type

Amount

Meaning

funded +100 USD credits were granted
consumed -30 USD credits were used
expired -70 USD unused credits expired

To learn more about movements and transaction history, see Credit transaction history.

Settlement modes

Billing charges apply credits. When a charge is raised against a customer, Metering & Billing uses the settlement mode to determine how to apply credits:

Settlement mode

Behavior

credit_then_invoice Use available credits first. Any charge amount that exceeds the available credit balance is invoiced as a standard charge. This is the prepaid-plus-overage model.
credit_only Credits must cover the full charge. If the credit balance is insufficient, the charge is blocked. No invoice overage is generated.

The customer’s credit balance, the charge’s settlement mode, and the grant’s expiration and priority rules together determine how much credit is consumed.

For details on draw-down order and expiration behavior, see credit consumption and expiration.

For details on how Metering & Billing keeps credit balances correct through a double-entry ledger, immutable movements, and deterministic consumption order, see Correctness guarantees.

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!