unlockFolder(path, encryptionKey) Last updated: 31. Mar 2026

API only function

Unlocks an encrypted folder for the duration of the current script execution. After unlocking, all file operations (saveFile, downloadEmbedded, saveEmbeddedFile, etc.) will transparently encrypt and decrypt content in this folder.

Parameters

Name Type Description
path string Path to the encrypted folder
encryptionKey string The encryption key (passphrase) for the folder

Returns

Returns true on success, or throws an error if the folder is not found or not encrypted.

Example

Code example (JS)

JS is normal JavaScript either 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");