Best Practices for Handling status callback with same doc keys

I am integrating ONLYOFFICE into my system to embed it in a React app. For backend operations, I am handling the status callback as per the documentation (Callback Handler) and have S3 configured as the document cache.

Here’s the challenge:

  1. When receiving a status 2 callback, I need to update the document with the modified one provided in the url parameter. Ideally, I should create a new version of the document and pass ONLYOFFICE a new document key for subsequent editing sessions.
  2. Currently, we are not handling document versions in our system. Instead, we overwrite the existing document and reuse the same document key. This causes problems when returning to the editor.

To work around this, I attempted to clear the S3 document cache (deleting the file from S3) upon receiving status 2. However, this approach results in the following error when reopening the document for a second editing session: “An error has occurred while opening the file.”

Questions:

  1. What is the recommended way to handle document keys in this scenario?
  2. Is there a proper way to manage overwriting documents without changing the document key or implementing full version control?
  3. If clearing the S3 cache is the correct approach, what additional steps are needed to avoid the error when reopening the document?

I would appreciate any guidance or best practices for solving this issue, thanks!