Docly Developers
Function API only Updated 23 Oct 2026

downloadEmbedded(file, embeddedId, [filename])

Downloads an embedded file from a document. The response is always sent as application/octet-stream with Content-Disposition attachment.

Parameters

filestringrequired

Absolute path to document.

embeddedIdstringrequired

Id of the embedded file — the value of the document's file field.

filenamestringoptional

File name the browser saves the file as. Defaults to the embedded id.

Returns

Starts the file download and stops the script. Returns null when file or embeddedId is missing, and the text Load failed for … when the document or the embedded file does not exist. Throws error -700 when the document is in an encrypted folder that has not been unlocked with unlockFolder.

Example

Normal JavaScript, running in the browser or on the Docly™ server.
// Downloads the file stored in the field "File1" of a document
let doc = docly.getFile("somefile");
docly.downloadEmbedded("somefile", doc.File1, "My file.pdf");