Advice needed: Best practice and order of API calls to delete a user with all its data

Hi ShareFile,

 

We currently have an API integration to automatically create ShareFile accounts for temporary 30 day usage which works great.

At the end of the usage we want to be able to delete an account along with all its shared data.

 

At this moment we perform following calls

1) Disable the user

PATCH /Users?Id=

 

2) Downgrade employee to client

POST /Users/Employees/Downgrade

=> In the body we provide mandatory ReassignItemsToId + ReassignGroupsToId to a separate "backup account"

 

3) Delete client

POST /Users/Clients/BulkDelete

 

A this moment all Items & Groups get re-assigned which still consumes lots of data. Goal would be in our process the data gets either destroyed first or after they are re-assigned.

Can you please suggest an approach an which API calls we can make to destroy the shared data?

Do we best perform this BEFORE the downgrade & mandatory re-assignment, or should we do it after?

We are looking ShareFile recommended / best practice advice for a future-proof approach.

 

Thank you!

 


  • Hello!

     

    Thanks for reaching out.

     

    Since your goal is to ultimately remove both the user and their associated data, there are a couple of approaches you could take.

     

    One important consideration is that ShareFile requires ownership to be reassigned when a user owns content or groups. As a result, some form of reassignment will need to occur as part of the process.

     

    You could delete content before downgrading the employee user, but this can become more complex because Personal Folders cannot be removed prior to reassignment. In practice, this means performing content cleanup both before and after the reassignment.

     

    For that reason, the simpler approach is typically to perform the required reassignment first and then remove the content afterward. Once ownership has been transferred to your designated "backup" account, you can identify and permanently remove the reassigned content.

     

    A common workflow would be:

     

    1. Retrieve the Account ID using GET /sf/v3/Accounts
    2. Use the returned Account ID (which represents the account's top-level Item) to retrieve the root-level folders GET /sf/v3/Items({AccountId})/Children
    3. Identify the Item IDs of the folders you wish to remove.
    4. Permanently delete those folders using POST /sf/v3/Items/BulkDeletePermanently with a JSON payload containing the Item IDs to be deleted, for example: ["FolderID1","FolderID2", "FolderID3"]

     

    You may also be able to simplify your workflow by eliminating the employee-to-client conversion entirely. Rather than:

     

    1. Disable user
    2. Downgrade employee to client
    3. Delete client

     

    You could delete the employee user directly while still satisfying the ownership reassignment requirements:

     

    • DELETE /sf/v3/Users({id})?completely=true&itemsReassignTo={id}&groupsReassignTo={id}

     

    This performs the reassignment and user deletion in a single operation. You can then perform the content cleanup against the reassignment account using the process described above.

     

    From a long-term maintenance perspective, the "reassign first, then clean up" approach is generally the simplest to automate, as it centralizes ownership transfer into a single step and allows content removal to occur in a predictable, repeatable manner afterward.

     

    Please let us know if you have any questions about implementing either approach.

    Selected as Best
  • Hello!

     

    Thanks for reaching out.

     

    Since your goal is to ultimately remove both the user and their associated data, there are a couple of approaches you could take.

     

    One important consideration is that ShareFile requires ownership to be reassigned when a user owns content or groups. As a result, some form of reassignment will need to occur as part of the process.

     

    You could delete content before downgrading the employee user, but this can become more complex because Personal Folders cannot be removed prior to reassignment. In practice, this means performing content cleanup both before and after the reassignment.

     

    For that reason, the simpler approach is typically to perform the required reassignment first and then remove the content afterward. Once ownership has been transferred to your designated "backup" account, you can identify and permanently remove the reassigned content.

     

    A common workflow would be:

     

    1. Retrieve the Account ID using GET /sf/v3/Accounts
    2. Use the returned Account ID (which represents the account's top-level Item) to retrieve the root-level folders GET /sf/v3/Items({AccountId})/Children
    3. Identify the Item IDs of the folders you wish to remove.
    4. Permanently delete those folders using POST /sf/v3/Items/BulkDeletePermanently with a JSON payload containing the Item IDs to be deleted, for example: ["FolderID1","FolderID2", "FolderID3"]

     

    You may also be able to simplify your workflow by eliminating the employee-to-client conversion entirely. Rather than:

     

    1. Disable user
    2. Downgrade employee to client
    3. Delete client

     

    You could delete the employee user directly while still satisfying the ownership reassignment requirements:

     

    • DELETE /sf/v3/Users({id})?completely=true&itemsReassignTo={id}&groupsReassignTo={id}

     

    This performs the reassignment and user deletion in a single operation. You can then perform the content cleanup against the reassignment account using the process described above.

     

    From a long-term maintenance perspective, the "reassign first, then clean up" approach is generally the simplest to automate, as it centralizes ownership transfer into a single step and allows content removal to occur in a predictable, repeatable manner afterward.

     

    Please let us know if you have any questions about implementing either approach.

    Selected as Best
  • Thank you Kevin for taking the time and even suggesting improvements in our flow. We'll value your input & will take it along in our implementation.