Function API only Updated 21 Oct 2026
unlockFolder(path, encryptionKey)
Unlocks an encrypted folder for the current request. After unlocking, file operations (getFile, saveFile, downloadEmbedded, saveEmbeddedFile, etc.) transparently decrypt and encrypt content in this folder.
The key is not checked when you unlock: a wrong key only shows up when encrypted content is read or written. The unlock lasts for the current request only and has to be repeated in every request. In a scheduled service or a file event (services.json) there is no request: the unlock then lasts for that run of the script.
See also Path traversal
Parameters
pathstringrequiredPath to the encrypted folder
encryptionKeystringrequiredThe encryption key (passphrase) for the folder
Returns
true on success. Throws if the folder is not found (error 4) or is not encrypted (error 5).
Example
Normal JavaScript, running in the browser or on the Docly™ server.
/* Unlock the encrypted folder */
let key = docly.getHeader("X-Encryption-Key");
docly.unlockFolder("#/Secrets", key);
/* Read a document with an embedded certificate */
let doc = docly.getFile("#/Secrets/certificates");
/* Download the embedded file using the ID stored in the document */
docly.downloadEmbedded("#/Secrets/certificates", doc.CertificateFileId, "server.pem");