---
schema_version: "1"
id: bcce4605349ec67b66006cdb0645594363e6132f3e3cbed59b4d062aada138f5
title: Allow Experience Cloud App Users to Initiate Deletion of Their Data
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/branded_apps_account_deactivate.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.branded_apps_account_deactivate.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 55d23dcba6120e829b6efbce070d77f374a668bdd06178f56a4c996e8bece751
description: The App Store Review Guideline 5.1.1 (v) requires that all apps must allow users to initiate deletion of their account from within the app. Apple can remove your app from its App Store if your app doesn't meet this requirement.
products:
  - Experiences
  - Mobile App
  - Cross Cloud
release: "264"
---
# Allow Experience Cloud App Users to Initiate Deletion of Their Data

The App Store Review Guideline 5.1.1 (v) requires that all apps must allow users to initiate deletion of their account from within the app. Apple can remove your app from its App Store if your app doesn't meet this requirement.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Setup for Mobile Publisher available in: Lightning Experience</td></tr></tbody><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Setup for Mobile Publisher available in: production only (not sandbox)</td></tr></tbody><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in Lightning Experience in: <strong>Enterprise</strong>, <strong>Performance</strong>, and <strong>Unlimited</strong> Editions</td></tr></tbody></table>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d25784e87">User Permissions
              Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d25784e87 ">To enable external user deactivation option:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d25784e87 ">Customize Application</td>

          </tr>
        </tbody>
      </table>

This requirement affects your iOS Mobile Publisher for Experience Cloud app if its associated Experience Cloud site allows guest users to self-register. To meet this requirement, first allow your users to deactivate their accounts from the site, and then manually delete their information from the org.

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-branded_apps_exp_cloud-264-0-0-production-enus/cf85363c-215e-4784-bb6a-c5c83c4e7140/images/icon_note.png)

Note The ability of users to initiate deletion of their account from within the app is available for only Aura sites.

1. From Setup, enter user management settings in the Quick Find box, then select **User Management Settings**.
2. Enable the **User Self Deactivate** setting to allow your site users to deactivate their account.
3. For the site you'd like to allow user self-deactivation, open the site’s Experience Builder User Settings (My Settings) page.
4. Select the **Customizable User Settings** component on the User Settings (My Settings) page. Configure the component’s Account Details properties.
    
    ![Account Details properties of the component](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-branded_apps_exp_cloud-264-0-0-production-enus/cf85363c-215e-4784-bb6a-c5c83c4e7140/branded_apps_exp_cloud/images/account_details.png)
    
    Make sure to deselect the **Hide the Deactivate Account section** checkbox, so that your users see the Deactivate My Account button.
    
    Customize the Deactivate Account Button label, and other Deactivate Account user settings, to use the term Delete rather than Deactivate. This customization, and subsequent deletion of user data from the org, ensures that you meet Apple’s Account Deletion requirements.
    
    ![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-branded_apps_exp_cloud-264-0-0-production-enus/cf85363c-215e-4784-bb6a-c5c83c4e7140/images/icon_note.png)
    
    Note You may not want to use the Customizable User Settings component to initiate the deletion of user data. For example, if you have special branding requirements. Instead, you can build your own custom component or use a Flow component. See the example for details on using a Flow component for this purpose.
5. Create a notification that informs you when a user has deactivated their account and initiated the deletion of their data.
    
    For example, use a custom or Flow component, or an Apex trigger for notification.
6. After a user deactivates their account, delete all of the user’s data stored in the Salesforce platform. Follow your local data protection and privacy regulations. For information on deleting user data from the Salesforce platform, refer to [Data Deletion for Experience Cloud Sites](https://help.salesforce.com/s/articleView?id=xcloud.data_deletion_communities.htm&type=5&language=en_US), [Data Deletion for the Salesforce Platform](https://help.salesforce.com/s/articleView?id=data_deletion_platform.htm&type=5&language=en_US), and [Let Users Scramble Their User Data](https://help.salesforce.com/s/articleView?id=platform.users_scramble_user_setting.htm&type=5&language=en_US).
    
    Using an Apex query, you can programmatically revoke the app user’s OAuth access token and delete their ThirdPartyAccountLink (TPAL). Apex queries that return multiple tokens and TPALs, can result in performance issues and rapidly reach the transaction limit. You can get around this limit by performing queries in a [batch job.](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm) Here are some examples.

#### See Also

- [_Apple App Store Review Guidelines 5.1.1 (v)_: Data Collection and Storage](https://developer.apple.com/app-store/review/guidelines/#5.1.1)
- [_Knowledge Article_: Allowing Mobile Publisher for Experience Cloud App Users to Initiate Deletion of Their Data](https://help.salesforce.com/s/articleView?id=000364042&type=1&language=en_US)
- [_Set Up and Maintain Your Salesforce Organization Help_: Enable User Self-Deactivation](https://help.salesforce.com/s/articleView?id=platform.users_deactivate_external_option.htm&type=5&language=en_US)
- [_Experience Cloud Help_: Customizable User Settings](https://help.salesforce.com/s/articleView?id=experience.rss_user_settings_customizable.htm&type=5&language=en_US)
- [_Experience Cloud Help_: Flow](https://help.salesforce.com/s/articleView?id=experience.rss_flow_component.htm&type=5&language=en_US)
- [_Automate Your Business Process_: Build a Flow](https://help.salesforce.com/s/articleView?id=platform.flow_build.htm&type=5&language=en_US)
- [_Apple App Store Review Guidelines 5.11_: Data Collection and Storage](https://developer.apple.com/app-store/review/guidelines/#5.1.1)

## Example 1: Use a Flow Component to Allow Users to Deactivate Their Account

You may want to use a Flow component instead of the Customizable User Settings component to allow users to deactivate account.

1. Assign the **Run Flows** user permission to your site users using their profile or a permission set.
2. Build the new flow.
3. From Setup, enter flow in the Quick Find box, then select **Flows**.
4. Click **New Flow**.
5. Choose **Screen Flow** for the flow type, and then click **Create**.
6. Add the **Update Records** element to the canvas.
7. In the New Update Records window, specify the following information.
    
    - Label: Deactivate User Account
    - API Name: Deactivate\_User\_Account
    - Select **Specify conditions to identify records, and set fields individually**
    - Object: **User**
        - Filter User Records
            - Field: **Id**
            - Operator: **Equals**
            - Value: {$User.Id}
        - Set Field Values for the User Records
            - Field: **isActive**
            - Value: {!$GlobalConstant.False}
8. Click **Done**.
9. Click **Save**.
10. In the Save the flow window, specify the following information and then click **Save**.
    
    - Flow Label: User Self-Deactivation
    - Flow API Name: User\_Self\_Deactivation
11. Click **Activate**.
12. Using Experience Builder, add the Flow component to your site.
    
    ![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-branded_apps_exp_cloud-264-0-0-production-enus/cf85363c-215e-4784-bb6a-c5c83c4e7140/images/icon_note.png)
    
    Note For this example, it's recommended that you don't directly add the Flow component to the User Settings page. Instead, update the flow to add at least a start screen, so that user account deactivation doesn't occur as soon as the page is displayed or the flow launched. Then add the Flow component to a new page and link to that page from the User Settings page.
13. Select the Flow component.
14. In the component's property editor, select **Use Self-Deactivation** from the Flow dropdown menu.
15. If you're using audience targeting, make sure that the user identified to test the app has access to the page containing the Flow component.
16. Publish the site.

## Example 2: Use a Flow Component for Notification that a User has Deactivated Their Account and Initiated the Deletion of their Data

You must know if a user has deactivated their account and initiated the deletion of their data, so that you can then delete their data from the org. One way to accomplish this is by modifying the flow created in the previous example.

1. Using Flow Builder, select the **User Self-Deactivation** flow.
2. On the canvas, add the **Action** element below the Update Records element.
3. In the New Action window, specify the following information.
    
    - Action: **Send Email**
    - Label: Send Email
    - API Name: Send\_Email
    - Body: This user has self-deactivated their account: {!$User.Id} and would like to delete their account information
    - Subject: New deactivated user
    - Email Addresses (comma-separated): Enter the email recipient, for example the org admin's email.
4. Click **Done**.
5. Click **Save** and then **Activate**.

## Example 3: Use Apex to Revoke User’s OAuth Access Token

Query the [OauthToken](https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_oauthtoken.htm) object with the `userId` of the user who wants to initiate deletion of their account. You can filter the query by appName to return the app tokens you want. If you’re using flows, keep in mind that flows don’tallow create, update, or delete actions to be taken in the same transaction (which is a single method in Apex) as a lookup or callout.

public void revokeToken(String userId){ //Look up OauthTokens for the user List< OauthToken > tokens = \[SELECT ID, DeleteToken FROM OauthToken WHERE userid =: userId AND AppName = '<AppName>'; //Contruct the url to hit the revoke token endpoint with desired token String baseUrl = '<base myDomain>'; String revokeEndpoint = '/services/oauth2/revoke?token='; String tokenEncoded = EncodingUtil.URLENCODE(tokens\[0\].DeleteToken,'UTF-8'); baseUrl += revokeEndpoint += tokenEncoded; //Http request to actualy hit the endpoint HttpRequest req = new HttpRequest(); req.setEndpoint(URL); req.setHeader('Content-Type','application/x-www-form-urlencoded'); req.setMethod('GET'); Http http = new Http(); HttpResponse res = http.send(req); system.debug('Response was: '+res); }

## Example 4: Use Apex to Delete the ThirdPartyAccountLink (TPAL)

Use the `userId` of the user who wants to initiate deletion of their account to query for all associated [TPALs](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_UserManagement.htm). The query then deletes each returned TPAL.

List<ThirdPartyAccountLink> tpals = \[select Id, UserId, SsoProviderId, Provider, RemoteIdentifier from ThirdPartyAccountLink where UserId = '005xx00000#####'\]; for (ThirdPartyAccountLink tpal : tpals) { Auth.AuthToken.revokeAccess(tpal.SsoProviderId, tpal.Provider, tpal.UserId, tpal.RemoteIdentifier); }

A few things to note:

- The database table has an index on the `OrganizationId`, `SsoProviderId`, `Provider`, and `userId` (parentId) fields. Since the query includes these fields in the `where` clause (`OrganizationId` is used automatically), the index can be used for optimization.
- Make sure you have the ManageUsers user permission (otherwise, you’re calling your own `userId`).
- The org must have the EditThirdPartyAccountLink org permission.