Docly Developers
Function API only Updated 17 Oct 2026

getDomains()

Lists the domains the site can publish folders and documents on: the verified domains on the workspace's subscription. Use it to pick the domain for publishFolder and publishDocument. Only available in API mode (.js endpoints), and only when the subscription has SaaS enabled.

Parameters

This function takes no parameters.

Returns

An array with one object per domain, sorted by name:

  • domain: the domain name, e.g. "customers.example.com" — pass it as the domain option to publishFolder/publishDocument
  • https: true if the domain is served over HTTPS

Unverified domains are not listed — they cannot be published on. An empty array means the subscription has no verified domains.

Without SaaS on the subscription it throws "Publishing folders and documents from scripts is not enabled on your subscription." (result code 16).

Example

Mixed HTML (or any text file) with inline JavaScript between hash signs.
let domains = docly.getDomains();
// [ { domain: "customers.example.com", https: true },
//   { domain: "example.com", https: true } ]

if (domains.length == 0) return { error: "No verified domain to publish on." };
return domains[0].domain;