Skill: Create Site

Create a new site for your organization from HTML, CSS, JavaScript and extra pages. The first version is saved as an unpublished draft unless the person asked to publish now.

Create Site builds a new site for your organization from the HTML, CSS and JavaScript the Web Builder writes. By default the first version is an unpublished draft that a person publishes from Sites.

Parameters

The Web Builder sends every parameter on every call.

ParameterTypeDescription
site_namestringThe site’s slug. It is lowercased, every character outside a-z, 0-9 and - becomes -, runs of - collapse and the ends are trimmed, so “My Site” becomes my-site. At most 63 characters. Refused if no letter or digit is left
descriptionstringOne line describing the site, shown under its name on the Sites list. Required
htmlstringThe full index.html. Required and not empty
cssstringThe full stylesheet, or "" for none
jsstringThe full script, or "" for none
pagesarray or nullExtra pages beyond index.html, each { filename, html }, or null for none. Each filename is lowercased, any character outside a-z, 0-9, ., _ and - becomes -, and it must end in .html
draftbooleantrue saves the first version unpublished. false makes the site live as soon as the call returns. The Web Builder passes true unless the person has explicitly asked to publish now

What it writes

  • index.html, each extra page, styles.css when css isn’t empty, and script.js when js isn’t empty. If a page has no tag loading styles.css or script.js, the skill adds it.
  • One site record owned by the calling organization.
  • The site’s subdomain, which is its site_name.

Response

FieldDescription
successtrue
urlWhere the site is served. On a draft it doesn’t serve anything until a person publishes
site_nameThe slug the site was saved under
subdomainThe site’s subdomain
organizationThe organization’s slug
filesThe files written
descriptionThe description saved
published, status, version, live_version, messageOnly on a draft: false, not_published, 1, null, and a message saying the address doesn’t show the site until someone publishes it
warning, syntax_errors, missing_filesPresent when a script won’t run in the browser, or a page links to a file the site doesn’t have. Up to 10 of each are listed, with totals

When it refuses

SituationResult
The organization already has a site with this site_nameAn error saying to use Update Site. Create Site never overwrites a site
The subdomain is reserved, or another site on Horizon already has itsuccess: false, error SUBDOMAIN_RESERVED or SUBDOMAIN_TAKEN, and suggested_subdomain when one is free. Nothing is created
A required parameter is missing, or draft isn’t true or falseAn error naming the parameter. Nothing is written

Subdomains are unique across every organization on Horizon, so a common name can already be taken even when your organization has no site by that name.


Related skills: Update Site | Edit Site | Import Design | List Sites