> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # RevertBalanceChange # Package: benefitPrograms # Namespace: BalanceService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/benefit-programs/balances/revert-balance-change.md ## Permission Scopes: Manage benefit programs: SCOPE.BENEFIT_PROGRAMS.MANAGE ## Introduction Reverts a transaction created by calling Change Balance. For example, if a transaction increased a balance's available credits by 5, calling Revert Balance Change with the transaction's ID will decrease the balance's available credit by 5. > **Note:** If the Change Balance call set the balance, Revert Transaction reverts the amount the balance changed by, ensuring subsequent balance changes are still reflected after the reversion. --- ## REST API ### Schema ``` Method: revertBalanceChange Description: Reverts a transaction created by calling Change Balance. For example, if a transaction increased a balance's available credits by 5, calling Revert Balance Change with the transaction's GUID will decrease the balance's available credit by 5. > **Note:** If the Change Balance call set the balance, Revert Transaction reverts the amount the balance changed by, ensuring subsequent balance changes are still reflected after the reversion. URL: https://www.wixapis.com/benefit-programs/v1/balances/changes/{transactionId}/revert Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: idempotencyKey Method parameters: param name: idempotencyKey | type: idempotencyKey | description: Ignored value, kept for backward compatibility. Idempotency is now handled by the system. | required: true param name: instructingParty | type: IdentificationData - ONE-OF: - name: anonymousVisitorId | type: string | description: GUID of a site visitor that hasn't logged in to the site. - name: memberId | type: string | description: GUID of a site member. - name: wixUserId | type: string | description: GUID of a Wix user. Return type: RevertBalanceChangeResponse - name: transactionId | type: string | description: GUID of the transaction associated with the balance reversion. Possible Errors: HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: TRANSACTION_NOT_FOUND | Description: Transaction not found HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: NOT_ENOUGH_BALANCE | Description: Insufficient credits to complete balance reversion. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CHANGE_ALREADY_REVERTED | Description: Transaction was already reverted. ``` ### Examples ### RevertBalanceChange ```curl ~~~cURL curl https://www.wixapis.com/benefit-programs/v1/balances/changes/9fc6cade-d8b9-46c0-8255-4703afc01ce0/revert \ -H 'Content-type: application/json' \ -H 'Authorization: ' --data '{ "idempotency_key": "31fc503c-4008-42a8-9699-362c69564aaa", "transaction_id": "9fc6cade-d8b9-46c0-8255-4703afc01ce0" }' ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.benefitPrograms.BalanceService.revertBalanceChange(transactionId, idempotencyKey, options) Description: Reverts a transaction created by calling Change Balance. For example, if a transaction increased a balance's available credits by 5, calling Revert Balance Change with the transaction's GUID will decrease the balance's available credit by 5. > **Note:** If the Change Balance call set the balance, Revert Transaction reverts the amount the balance changed by, ensuring subsequent balance changes are still reflected after the reversion. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: transactionId, idempotencyKey Method parameters: param name: idempotencyKey | type: string | description: Ignored value, kept for backward compatibility. Idempotency is now handled by the system. | required: true param name: options | type: RevertBalanceChangeOptions none - name: instructingParty | type: IdentificationData | description: Identity reverting the balance change. - ONE-OF: - name: anonymousVisitorId | type: string | description: GUID of a site visitor that hasn't logged in to the site. - name: memberId | type: string | description: GUID of a site member. - name: wixUserId | type: string | description: GUID of a Wix user. param name: transactionId | type: string | description: GUID of the transaction associated with the balance change to revert. | required: true Return type: PROMISE - name: transactionId | type: string | description: GUID of the transaction associated with the balance reversion. Possible Errors: HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: TRANSACTION_NOT_FOUND | Description: Transaction not found HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: NOT_ENOUGH_BALANCE | Description: Insufficient credits to complete balance reversion. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CHANGE_ALREADY_REVERTED | Description: Transaction was already reverted. ``` ### Examples ### revertBalanceChange ```javascript import { balances } from '@wix/benefit-programs'; async function revertBalanceChange(transactionId,idempotencyKey,options) { const response = await balances.revertBalanceChange(transactionId,idempotencyKey,options); }; ``` ### revertBalanceChange (with elevated permissions) ```javascript import { balances } from '@wix/benefit-programs'; import { auth } from '@wix/essentials'; async function myRevertBalanceChangeMethod(transactionId,idempotencyKey,options) { const elevatedRevertBalanceChange = auth.elevate(balances.revertBalanceChange); const response = await elevatedRevertBalanceChange(transactionId,idempotencyKey,options); } ``` ### revertBalanceChange (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { balances } from '@wix/benefit-programs'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { balances }, // Include the auth strategy and host as relevant }); async function revertBalanceChange(transactionId,idempotencyKey,options) { const response = await myWixClient.balances.revertBalanceChange(transactionId,idempotencyKey,options); }; ``` ---