Consume Feature usage
Spend units once per action, with retries that do not double-charge.
https://i.nuxie.ai/feature/consumeSpend units from a customer’s allowance. Give each action an operationId and reuse it on retries so the action is counted once. Start the paid work only after the response says accepted: true.
Request body
apiKeybodystringrequiredPublishable key for the app platform. A pk_test_ key selects test data; a pk_live_ key selects live data. Copy it from Connect your app.
customerIdbodystringrequiredThe identified or anonymous customer ID your app supplies to the SDK, rather than Nuxie’s internal customer record ID. See Customer identifiers.
featureIdbodystringrequiredPublished Feature key, such as exports.
operationIdbodystringrequiredStable identifier for this action. Reuse it when retrying the same action.
quantitybodyintegerrequiredUnits to consume, or the cumulative total in set_usage mode. Accepts 1 to 9,007,199,254,740,991.
modebodystringconsume (default) adds the quantity to usage. set_usage consumes only the increase from the previously used total.
entityIdbodystringIdentifier for an entity-scoped allowance.
purchasebodyobjectStore evidence to apply a purchase and spend its first units together. Cannot be combined with set_usage.
Purchase fields
typebodystringrequiredappstore or playstore.
signedTransactionbodystringRequired for appstore: the signed StoreKit transaction, up to 2 MiB.
purchaseTokenbodystringRequired for playstore: the Google Play purchase token, up to 16,384 characters.
productIdbodystringGoogle Play Product identifier, when relevant.
basePlanIdbodystringGoogle Play subscription base plan, when relevant.
purchaseOptionIdbodystringGoogle Play one-time purchase option, when relevant.
offerIdbodystringGoogle Play selected offer, when relevant.
productTypebodystringGoogle Play subscription or one_time, when relevant.
The customer, Feature, operation, and entity identifiers must be non-empty, trimmed, and at most 256 characters. Unknown fields return 400.
For example, after 7 units have been used, set_usage with a quantity of 10 consumes 3 more units. An equal or lower total consumes nothing; it does not restore spent units.
Response
operationIdstringrequiredIdentifier for this usage action.
customerIdstringrequiredCustomer identity supplied in the request.
featureIdstringrequiredPublished Feature key.
acceptedbooleanrequiredWhether the usage succeeded, including when it spent the last unit.
typestringrequiredFeature type returned by the usage decision.
codestringrequiredResult or denial reason, such as consumed.
quantityintegerrequiredQuantity submitted in the request. In set_usage mode, this is the cumulative total, not the number of newly spent units.
balancenumberrequiredRemaining units, or null for unlimited access.
unlimitedbooleanrequiredWhether usage is unlimited.
activebooleanrequiredWhether the access is active after this decision.
occurredAtMsnumberrequiredUnix timestamp in milliseconds, or null if no decision time is available.
idempotentReplaybooleanrequiredWhether this response repeats the saved decision for the operation.
entityIdstringReturned for entity-scoped commands.
Retries and denied usage
A replay returns the saved decision with idempotentReplay: true. Reusing an operation ID for different input can return 409 with code: "operation_conflict".
A denied command can return 200 with accepted: false and a reason in code. Purchase-backed commands with insufficient balance can return 402. Neither authorizes the paid work.
Purchase evidence here uses camelCase fields, unlike Synchronize a purchase. The purchase and consumption refer to the same customer and Feature. The SDK’s Feature-use methods handle evidence and retries automatically.