Allocate usage units and charge them once for a licensed operation.
Plan requirement
Business includes metered licensing. Pro and lower plans receive PLAN_UPGRADE_REQUIRED (403). Enable Usage credits on your software plan and issue a metered license. A stored balance is retained after a platform downgrade, but granting/consuming credits requires an eligible effective subscription.
Credits are whole-number usage units, not euros, bank payments or automatic subscription invoices. Customers can choose a credit pack in the portal and continue to the developer’s connected WooCommerce store. Payments, tax and refunds remain in that store.
Add or adjust credits
Use a license’s Credits screen in the developer dashboard, or POST /api/v1/licenses/{license}/credits from a trusted backend. The management key needs licenses:write, the correct environment and product scope. Never ship it in an app.
{
"type": "grant",
"amount": 100,
"idempotency_key": "allocation-order-123",
"reason": "Initial usage allocation"
}
grant adds positive units; refund requires original_transaction (the consumed ctx_… reference) and returns only units from that operation; adjust allows positive or negative units but cannot take balance below zero. A credit refund returns units only; it does not refund a payment. Values must be safe whole numbers within ±9,007,199,254,740,991, subject to the operation’s sign rules.
Consume before doing work
With an activated license, send POST /api/v1/licenses/consume using its activation bearer token, X-Installation-ID, the current fingerprint, a positive integer amount and an idempotency_key. For floating licenses also send the current session_token.
{
"amount": 1,
"idempotency_key": "export-job-123",
"reason": "Export",
"fingerprint": "<current fingerprint object>",
"session_token": "<only when this license uses shared seats>"
}
Verify the signed receipt in license, including credit_transaction and its amount, resulting balance, request-key hash and license/device binding. Successful responses include transaction_id, consumed, balance and replayed. The last successful consume may leave zero and still authorize that one completed charge; it is not permission for another job.
The debit and ledger row commit together under the license lock. Reusing the same request key and operation returns the original receipt without another debit. Reusing a key for different operation data returns IDEMPOTENCY_CONFLICT (409). The key is 8–190 characters: letters, digits, dot, colon, underscore or hyphen. The API requires a key; persist the same key for every retry of one billable job to make uncertain outcomes recoverable.
Failures and retries
INSUFFICIENT_CREDITS (402) means no charge was made and the job must not run. INVALID_CREDIT_AMOUNT (422), NOT_METERED_LICENSE (409) and CREDIT_LIMIT_EXCEEDED require correcting the request or policy. A lost network response is an uncertain outcome: deliberately retry the same operation with the same key. Do not create a new key, and do not automatically run the job twice because a charge was replayed.
The credit ledger deduplicates the charge, not execution of your application’s job. Keep your own job record/lock to deduplicate the work. Never expose keys, tokens, raw receipts or customer payloads in logs.
Balance and offline behavior
Matching SDKs provide an online signed balance read: Python/Rust get_balance(), Node.js/PHP getBalance(), C# GetBalanceAsync(). It uses validation; there is no separate public balance endpoint to invent. A replayed receipt carries the historical post-charge balance, so read again if you need the current value.
Metered permission and consumption are online-only. METERED_ONLINE_REQUIRED rejects cached/offline permission, even within a regular license grace window. Features never consume credits by themselves. Customers can view their balance and recent transactions in the portal, without granting or spending credits there.
One license, even at zero credits
An active, correctly signed online license opens the app at 0 credits. Included features follow its plan. Only a billable operation can return INSUFFICIENT_CREDITS; it must not run without a verified successful receipt. Expiry, device binding, app access and floating-seat limits still apply. Zero credits do not delete devices or subscriptions.
Create a credit pack
- Open Usage credits → Credit packs in your developer workspace and choose Live or Test.
- Choose the software product and a connected WooCommerce store; enter the name, units and initial store price.
- Save. The connector creates a virtual store product automatically, or links the product / variation ID you provided. Do not reuse a product already mapped to sell a software license.
- The connector syncs in the background; Sync now is available in both dashboards. Enable Edit license settings from this store if store managers should create packs, codes or manual grants there.
- WooCommerce remains the authority for price, tax, coupons and payment mode. Existing checkout intents and paid orders retain their original unit quantity after pack edits.
Customers choose their existing license from My Account → My Licenses → Balance, top-ups & credit codes, or use their already activated app. Knowing an email is not proof of ownership. A license-key login never signs someone into a WooCommerce account or links accounts by email alone.
Gift and promotional codes
- Open Usage credits → Credit codes.
- Choose the software product and enter a name and number of credits.
- Leave Code empty for a private random code, or enter a public promotion such as
KDP100CR. A short public code can be shared and guessed: use small, explicit limits. - Default: one total use, once per license and once per customer. Under the optional settings choose a plan restriction, UTC start/expiry, larger limits, or a batch of up to 100 separate random codes.
- New codes are encrypted for later access and stay masked in the list. Choose Show, Hide or Copy. Your personal Settings → Showing & copying preference controls password confirmation; copying an already authorized code does not ask twice. The full text is fetched only on your explicit request, and shown text is hidden again after a short timeout or when you leave the view.
- The customer redeems through the app, the portal or My Account. The same license receives real units. The balance refreshes after success.
Open Details & history for all recorded uses, with pagination. Each redemption opens the customer’s full credit history, with separate balances for each license. Open a transaction to see its unit change, balance before/after, recorded actor, source code or store purchase. The main list supports combined live search, product, plan, customer, date and state filters over all records. Failed attempts from before this feature were not logged and are not reconstructed. Disable or permanently archive a code to stop new redemptions; history and already-granted credits remain. Units and scope are immutable after creation; create a replacement code instead of changing a distributed promise. A code's expiry controls redemption, not the lifetime of units already granted. Codes require an active credit-enabled license attached to a customer.
Your Settings → Showing & copying preference also applies to license keys and email Copy buttons across your developer account. Turning confirmation off requires your password once; turning it on does not. The preference belongs to your user in this workspace and never changes another developer’s setting. Full keys and codes still start hidden. Email text already displayed on a page stays visible; the preference protects its Copy button.
SDK and API examples
The current APIs below require Python/JavaScript/PHP/C# 2.2.0 or Rust 0.4.0. Historical packages may not include code redemption or store pack discovery.
# A persisted request reference belongs to this redemption, not every button press.
receipt = client.redeem_credits("KDP100CR", saved_redemption_request_id)
print(receipt["added"], receipt["balance"])
packs = client.credit_packs()["packs"]
checkout = client.create_credit_checkout(packs[0]["id"])
# Open checkout["checkout_url"] in the customer's browser.
# After payment and return, fetch client.get_balance() online.
The same operations exist in Python, Node/Electron JavaScript, Rust, PHP and C#; see each SDK README. Browser-only JS still has no local hardware-fingerprint fallback.
All customer requests below are POST JSON, with the activation bearer token, X-Installation-ID, hardware fingerprint and an active session_token for floating licenses:
| Endpoint | Extra fields | Result |
|---|---|---|
/api/v1/credits/packs | None | Eligible packs and server-priced actions |
/api/v1/credits/checkout | pack_id | Short-lived opaque checkout URL |
/api/v1/credits/redeem | code, idempotency_key | Signed grant receipt and current balance |
/api/v1/credits/history | None | Latest 50 transactions |
/api/v1/licenses/consume | action, expected amount, idempotency_key | Signed once-only consumption |
A checkout link adds credits only to its already selected license. It contains no software key, email or activation token, expires after 15 minutes, and is claimed by one store cart. Store login is not granted by the link. No money is charged by the SDK.
Safe spending and recovery
In Usage credits → Settings, define an action such as create_pack and its unit cost. Once server-priced actions exist for a product/environment, arbitrary amount-only consumption is refused. Show the cost before confirming it. A price change returns CREDIT_PRICE_CHANGED without a debit. An already charged request returns its original receipt, even if the price subsequently changes. Valuable work should run on your backend; a desktop binary cannot be made tamper-proof by a credit button.
For a confirmed failed job, use License → Credits → Return usage credits, supplying its original ctx_… transaction. You cannot return more than that transaction consumed. For an uncertain network result, retry the original request; do not invent a refund. Manual additions are grants, not payments.
Refunds and recurring top-ups
- Only a fresh signed WooCommerce order proof can grant purchased units; the thank-you page cannot. Paid callbacks and background retries use the same unique order-item reference.
- Source lots track what remains from each grant. A quantity refund reverses only unused units from that purchase. Previously consumed refunded units appear as a shortfall for review; another purchase's units are not silently removed.
- A monetary-only refund with no item quantity needs review. A paid order moving to failed, cancelled or on-hold is also reviewed. Paid work pauses while a granted purchase is under review; included app features remain available.
- Needs attention shows pending/review purchases. A manager can resolve an already granted purchase with an audited note after reconciling payment and units. Otherwise retry through the store; never ask the customer to pay again to recover a paid order.
- With WooCommerce Subscriptions installed, a linked recurring pack grants units only for a confirmed renewal receipt tied to the original subscription and purchase. Cancellation alone does not erase purchased units. No recurring extension is bundled or claimed to be installed.
- Action Scheduler is used when available, with WP-Cron fallback. A low-traffic store still needs a working scheduler; background delivery is not an instantaneous SLA. The app refreshes on return/focus and periodically, with a manual refresh available.
- Auto-recharge at low balance is intentionally not enabled. It requires a separate consent/mandate and gateway-specific implementation; no card credentials are stored by this feature.
Try a complete app
PHP Sudoku Studio and the Python desktop app demonstrate code redemption, credit packs and replay-safe paid work on the same license. Follow the simple walkthrough. The original License Lab remains available.
Recover an older code
Older codes have only a one-way fingerprint and a masked reference. They cannot be decoded. If you still know the full original, choose Save original code and enter it; confirm your password if your personal protection setting requires it. The server verifies its fingerprint before storing it encrypted. It does not replace the code, change its uses or grant credits. If you lost the original, pause that code and create a replacement.
Email and share a gift
Choose Share / email beside a code. Pick a friendly, thank-you, public-gift or Arabic message, or write your own. Keep {code} in the text; {credits}, {product} and {expiry} fill in automatically. Save reusable message styles under names you choose. The actual code appears only after you explicitly request a preview.
Use Copy message, your device’s share menu, WhatsApp, Telegram or X. Facebook and LinkedIn open with the message copied for you to paste into a new post. Review and send or post inside the selected app; KDPika does not publish to your social account itself. Sharing deliberately gives the code to that app or audience. Anyone who knows a public code can try it within its configured scope and limits; emailing it does not reserve redemption for that email address.
For email, select one recipient who expects your gift, preview the message and confirm Send gift email. The same email request reference prevents a repeated click or lost reply from adding another send. You can also enable Send this code as a gift by email when creating a single code. For a batch, create it first and share codes separately. Email bodies containing a code are encrypted while queued and cleared after provider acceptance. Suppression and unsubscribe preferences apply; limits prevent repeated gift emails.
The code’s Gift email history distinguishes provider acceptance from pending retries or failure. Provider acceptance does not prove delivery to an inbox. A valid code can still be copied if email delivery fails. Avoid sending a second email while the first is pending.