Economy v2 is now Generally Available. For support and feedback, go to the PlayFab Forum.
Prerequisites
- A PlayFab developer account.
- A title created in Game Manager.
- At least one published catalog item and one virtual currency.
How it works
When you include anIdempotencyId in an inventory write request, PlayFab stores that ID for 14 days. If another request arrives with the same IdempotencyId, PlayFab returns the result of the original request without processing the operation again.
Supported APIs
IdempotencyId is supported on all inventory write APIs:
- AddInventoryItems
- SubtractInventoryItems
- PurchaseInventoryItems
- TransferInventoryItems
- DeleteInventoryItems
- UpdateInventoryItems
- ExecuteInventoryOperations
Example: Safe purchase with retry
In this scenario, a player buys a Laser Sword. The client generates a uniqueIdempotencyId (for example, a GUID) before sending the request:
IdempotencyId. PlayFab recognizes the duplicate and returns the original result. The player is charged only once.
Best practices
- Generate a unique ID per logical operation—Use a GUID or UUID. Don’t reuse the same ID for different operations.
- Generate the ID client-side before the first attempt—This practice ensures all retries use the same ID.
- Don’t change the request body between retries—Using the same
IdempotencyIdwith a different request body causes a conflict error. - IDs expire after 14 days—After that, the same ID can be used again for a new operation.
Redeem APIs are automatically idempotent
The marketplace redeem APIs (RedeemAppleAppStoreInventoryItems, RedeemGooglePlayInventoryItems, RedeemMicrosoftStoreInventoryItems, RedeemSteamInventoryItems) don’t require an IdempotencyId. They’re inherently idempotent. Each marketplace receipt or token can only be redeemed once. A second call with the same receipt returns success but grants nothing.
