Skip to main content
Copy-paste patterns for deducting credits from subscribers.
These patterns assume a credits plan. A pay-as-you-go plan holds no credit balance — each request is charged directly — so a successful settle there returns creditsRedeemed: "0" and remainingBalance: "0", with the charge referenced by orderTx (fiat rails) or transaction (crypto rails). The settle response always carries billingModel (credits | pay-as-you-go); read it before either credit field. Gating on creditsRedeemed > 0 alone reports a real pay-as-you-go charge as a decline, and on a card rail that invites a retry of a payment that already succeeded.

Automatic Credit Deduction

With the x402 flow, verification checks permissions without burning credits. After processing, settlement burns the credits:

Variable Credit Charges

For operations with variable costs, use the x402 flow:

Credit Tracking Middleware

Track credits used per request:

Tiered Pricing

Charge different amounts based on usage tiers:

Pre-Authorization Pattern

For long-running operations, pre-authorize credits before starting:

Credit Response Headers

Include credit information in response headers:

Next Steps

Subscription Access

Time-based access patterns

Dynamic Pricing

Variable pricing strategies