Docly Developers
Function API only Updated 22 Oct 2026

publishFolder(path, domain, [options])

Publishes a folder inside the site on one of the subscription's domains — for example a customer website the script has created under #/Websites/. Only available in API mode (.js endpoints), and only when the subscription has SaaS enabled. The script publishes as the user who published the site, with the same checks as the Publish dialog.

Parameters

pathstringrequired

The folder, relative to the site root, like the other docly.* functions — e.g. "#/Websites/ola". It must lie below the site's own folder: the site itself, folders elsewhere in the workspace and the template's files are refused with "path not found in the site".

domainstringrequired

The domain name, as getDomains returns it (not case-sensitive). Must be a verified domain on the workspace's subscription.

optionsobjectoptional
Specify any of the following options parameters:
aliasstring

The path under the domain, e.g. "ola" gives https://customers.example.com/ola/. Omitted: the folder name, with spaces replaced by "-". "/" publishes on the domain root. Numeric aliases and aliases starting with app/ or api/ are not allowed.

templatestring

The app (template folder) the published site runs: short guid, the same with the F prefix, or a regular guid. Omitted: no template.

authModenumber

Omitted: a public site. 2 = sign-in by redirect, 3 = sign-in in a popup.

Returns

The new publication, in the same shape as a row from getPublications: url, guid, type, templateGuid, public, authMode, folderPath, folderGuid, name, isDocument. Keep the guid if you want to unpublish later.

Errors (fixed texts — except "already published", which names the address that is taken):

  • SaaS not on the subscription: "Publishing folders and documents from scripts is not enabled on your subscription." (code 16)
  • path outside the site or not found: "publishFolder failed, path not found in the site"
  • path is the site itself: "publishFolder failed, the site itself cannot be published from a script"
  • domain missing, unverified or on another subscription
  • the address is already published

An existing publication cannot be changed: call unpublish and publishFolder again.

Example

Mixed HTML (or any text file) with inline JavaScript between hash signs.
// #/API/signup.js — a new customer gets a website
export default function (slug, html) {
  let path = "#/Websites/" + slug;
  docly.createFolder(path);
  docly.saveFile(path + "/index.html", html);

  let domain = docly.getDomains()[0].domain;
  let pub = docly.publishFolder(path, { domain: domain, alias: slug });
  return { url: pub.url, guid: pub.guid };   // "https://customers.example.com/ola/"
}

// With an app and sign-in:
docly.publishFolder("#/Websites/kari", { domain: "customers.example.com", alias: "kari", template: "F4xS2k9aQ0uYb1cDeFgHiJw", authMode: 2 });