Skip to content
HotLayout Docs

Self-hosted storage

This page is for the team that runs the HotLayout editor inside its own network and keeps the documents on its own servers. In this mode the editor reads and writes JSON through an HTTP API that you provide. The editor makes no request to HotLayout servers or to Google.

Related pages: index · embedding · backend guide · network requirements

What the mode is#

You put the files of the editor on your own host and point it at the address of your API. Everything the editor keeps — drafts, published documents, version snapshots, the theme, images — goes to that API. Your side provides:

  • the API described below, over your database or file storage;
  • the sign-in of your people: the editor uses the token your page hands it through tokenProvider;
  • the admin around the editor: lists of projects and documents, access control, activity log, updates.

Get the editor files#

HotLayout supplies the editor files together with your licence key. The archive holds one static file, hotlayout-builder.js: a JavaScript module with the whole editor and its styles inside. It loads no other parts, fonts or scripts, and nothing in it is generated per request.

This file is a separate build for installations in your own network, not the module that hotlayout.com serves. It contains no code or configuration of the HotLayout cloud: no Firebase or Google addresses, no cloud project identifier, no API keys, no cloud sign-in. The only absolute addresses left in it are XML and JSON Schema namespace identifiers, example addresses shown in hints, and links for people to this documentation; the editor requests none of them. Your security review can confirm it on the file itself, for example grep -icE 'firebase|firestore|googleapis|gstatic|identitytoolkit' hotlayout-builder.js prints 0.

  1. Put hotlayout-builder.js in a folder of your web server, for example /assets/hotlayout/.
  2. Serve it as text/javascript, with a short cache or no cache, so that an update reaches the page.
  3. Import the module from your address, not from the HotLayout one, and register the element:
import { defineHotlayoutBuilder } from 'https://builder.bank.example/assets/hotlayout/hotlayout-builder.js'

defineHotlayoutBuilder()

The page embedding describes the same element and its properties for the hosted case, where the module is loaded from hotlayout.com; in this mode that address is never used. Allow your own origin in the content security policy for scripts, and nothing else for the editor.

An update is a new archive: replace the file, and the next page load uses it.

The documents themselves are the same JSON as everywhere else, so a screen built in this mode is read by the same renderers.

Give the editor your data dictionary#

The editor offers managers only the data paths of a data dictionary and checks every binding against it. In the HotLayout cloud the dictionary is kept in the admin; in this mode there is no such admin, so your page hands it over through the dataContract property of the element (an object, not an attribute):

builder.dataContract = yourDictionary // { paths: {...}, collections: {...} }

Compose the dictionary yourself in the form described in data dictionary (the same shape as the data-contract.json file), and assign it before or after the element is attached; assigning null returns to the built-in demonstration dictionary. A dictionary that does not pass the check is refused with a message in the browser console. Without your dictionary the editor uses the demonstration one: every binding to a field of your system is reported as an unknown path, and publishing stays disabled until the errors are gone.

Connect the editor#

Set the storage-url attribute to the base address of your API, together with the address of the document, and tell the editor who is working:

<hotlayout-builder
  storage-url="https://builder-api.bank.example/hotlayout"
  org-id="your-org-id"
  project-id="your-project-id"
  document-id="your-document-id"
  access="publish"
></hotlayout-builder>
const builder = document.querySelector('hotlayout-builder')
builder.user = { id: 'u-1042', name: 'Olena B.', email: 'olena@bank.example' }
builder.tokenProvider = () => Promise.resolve(currentSessionToken()) // optional: leave it out when your API trusts a session cookie
  • A relative address (/api/hotlayout) is read against the base address of your page.
  • The address is a base path only: no query (?…), no fragment (#…) and no user name or password in it. Every request path is appended to it, so with a query the paths would land in the query, and with a fragment the browser would not send them at all. The editor refuses such an address without sending a single request and says why in the console.
  • The token is whatever your tokenProvider returns. The editor sends it unchanged as Authorization: Bearer <token> and never looks inside. Without a tokenProvider no Authorization header is sent at all, which suits an API that trusts your own session cookie.
  • org-id and project-id are plain identifiers of your choice: they become the first two segments of every request path.
  • The access attribute only decides what the editor draws (view, edit, publish). Enforce the same rule on the API: a page can be changed from the browser console.

If your side prefers to do the requests itself — through an existing client with its own retries and error handling — assign an object to the storage property instead. The property wins when both are set.

interface EditorStorage {
  loadDraft(scope, documentId): Promise<DraftLoadResult>
  saveDraft(scope, document, request): Promise<DraftSaveResult>
  publish(scope, document, options): Promise<SaveResult>
  loadPublished(scope, documentId): Promise<LoadResult>
  publishedUrl(scope, documentId): string | undefined
  listVersions(scope, documentId): Promise<VersionListResult>
  loadVersion(scope, documentId, stamp): Promise<LoadResult>
  listPublications(scope, documentId): Promise<PublicationListResult>
  listDocuments(scope): Promise<DocumentRecordsResult>
  loadTheme(scope): Promise<ThemeLoadResult>
  readThemeVersion(scope): Promise<ThemeVersionAnswer>
  publishTheme(scope, contract, options): Promise<ThemePublishResult>
  listMedia(scope): Promise<readonly MediaItem[]>
  uploadMedia(scope, upload): Promise<UploadResult>
  uploadSvg?(scope, upload): Promise<UploadResult>
  listScenarios?(scope): Promise<ScenarioListResult>
  saveScenario?(scope, scenario, base?): Promise<ScenarioWriteResult>
  deleteScenario?(scope, id, base): Promise<ScenarioWriteResult>
  loadPlacements?(scope): Promise<PlacementsLoadResult>
  createReview?(scope, input): Promise<ReviewCreateResult>
  loadReview?(scope, ref): Promise<ReviewLoadResult>
  listReviews?(scope, documentId): Promise<ReviewListResult>
  setExternalLink?(scope, ref, options?): Promise<ReviewLinkResult>
  readExternalLink?(scope, ref): Promise<ReviewLinkResult>
  revokeExternalLink?(scope, ref): Promise<ReviewLinkResult>
  loadReviewByLink?(linkRef): Promise<ReviewLinkLoadResult>
  decideReview?(scope, ref, input): Promise<ReviewDecideResult>
  readApprovalPolicy?(scope): Promise<ApprovalPolicyResult>
  isMediaUrl(scope, url): boolean
  saveLive?(scope, documentId, token, envelope): Promise<{ ok: true, url } | { ok: false, failure }>
  loadMapLayout?(scope, documentId): Promise<{ ok: true, layout } | { ok: false, failure }>
  saveMapLayout?(scope, documentId, layout): Promise<{ ok: true } | { ok: false, failure }>
}

loadPlacements is optional: it returns the published placement map of the project ({ ok: true, map, version }, or not_found when none was published). The publish confirmation uses it to warn that a placement points to an entry point the new version no longer has. Without the method the editor does not ask about placements at all.

scope is { project: { orgId, projectId }, token: () => Promise<string>, user?: { id, email?, name? } } — user is what the host set in the user property ({ id: 'anonymous' } when it set none). Every method except listMedia answers with a value, never an exception: { ok: true, … } or { ok: false, failure }, where failure.reason is one of not_found, unauthorized, conflict, stale, offline, too_large, unreadable, storage_error, no_token, rejected, timeout. listMedia throws an Error whose message is shown to the person as it is. An object without a required method is refused, with the missing names in the console. The sample server below shows each method in a form your team can copy.

The HTTP API#

Every path starts with the base address you gave in storage-url, followed by /{orgId}/{projectId}/. The table lists the rest of the path. All bodies are JSON in UTF-8 unless noted. Every request carries Authorization: Bearer <token>.

The editor… Request Success Failure
lists the documents of the project (asked when the Design section checks which other documents a change of the theme would affect; the lists people browse are kept by your own admin) GET documents 200 { "documents": [{ "documentId", "name" }] }
opens the draft GET documents/{id}/draft 200, body is the document, header ETag 404 there is no draft
saves the draft PUT documents/{id}/draft, body is the document 200 { "version" }, header ETag 409 { "error": "conflict", "current" }, 409 { "error": "stale" } an older revision of the same session, 413 too large
publishes POST documents/{id}/publish, body is the document 200 { "stamp" } 409 { "error": "stale" }
reads what is published GET documents/{id}/published 200, body is the document 404
lists the versions GET documents/{id}/versions 200 { "versions": [{ "stamp", "bytes"? }] }, newest first
reads one version GET documents/{id}/versions/{stamp} 200, body is the document 404
asks who published GET documents/{id}/publications 200 { "publications": [{ "stamp", "by", "byEmail"?, "at" }] }
reads the theme GET theme 200, body is the theme, header ETag 404 nothing published
asks the theme version HEAD theme 200 with ETag 404
publishes the theme PUT theme, body is the theme 200 { "version" }, header ETag 409 { "error": "stale" }
lists images GET media 200 { "items": [{ "name", "url" }] }
lists the named data scenarios (optional, the four scenario rows go together) GET scenarios 200 { "scenarios": [{ "id", "version", "value" }] }
reads one scenario (optional) GET scenarios/{id} 200, body is the stored record, header ETag 404
saves a scenario (optional) PUT scenarios/{id}, body is { "format", "name", "base", "picksText" } 200 { "version" }, header ETag 409 { "error": "stale" }
deletes a scenario (optional) DELETE scenarios/{id} 200 404 already gone (the editor treats it as done), 409 { "error": "stale" }
uploads an image PUT media/{name}, body is the file, Content-Type of the image 201 { "item": { "name", "url" } } 413, 415, 409 the name is taken
reads the placement map (optional) GET placements 200, body is the placement map object — not the webhook envelope — header ETag 404 no map yet
sends a draft for review (optional, the nine review rows go together) POST documents/{id}/reviews, body { "document", "theme", "dataContract", "documentName"?, "note"? } 201 { "record" } 404 there is no such document, 400 { "error": "invalid" }, 413 { "error": "too_large", "bytes", "limit" }
lists the reviews of a document GET documents/{id}/reviews 200 { "reviews": [record], "latest": { "reviewId", "version" } | null }
opens one review GET documents/{id}/reviews/{reviewId} 200 { "record", "snapshot", "latest" } 404
enables the external link POST documents/{id}/reviews/{reviewId}/link, body { "days" } 200 { "record", "token", "url"? } 400 days is not an integer from 1 to 30, 404
reads the current link GET documents/{id}/reviews/{reviewId}/link 200 { "record", "token", "url"? }, token is null when the link does not work 404
revokes the link DELETE documents/{id}/reviews/{reviewId}/link 200 { "record" }, also when it was already revoked 404
reads the copy behind a link, without signing in GET documents/{id}/review-links/{reviewId}/{token} 200, body is the snapshot 404 whatever the reason
records the decision POST documents/{id}/reviews/{reviewId}/decision, body { "verdict": "approved" | "returned", "comment"? } 200 { "record" } 400 comment_required, 403 own_review, 409 already_decided, 409 not_latest, 404
asks whether the project publishes only what was approved GET approval-policy 200 { "required": true | false }
writes the live copy for the person's phone (optional) PUT documents/{id}/live/{token}, body is the live envelope 200, optionally { "url" } — where the phone reads the copy without signing in 400, 401, 403, 413
reads the layout of the screen map (optional, goes together with the next row) GET documents/{id}/map-layout 200, body is the map layout 404 nobody has arranged the map yet
saves the layout of the screen map PUT documents/{id}/map-layout, body is the map layout 200 400 not a map layout, 413

Rules that apply to all requests:

  • The editor waits 20 seconds for the whole answer to an ordinary request — the status, the headers and the body (120 seconds for an image upload). A request whose answer is not complete in time is cancelled and treated like a lost connection: the editor shows that saving failed and tries again. Answer within the limit, or fail fast with a status code.
  • An answer body is at most 1 MiB. The editor reads it as a stream and stops at the limit: a larger answer is treated as "too large" and is not parsed.
  • No redirects. The editor does not follow 3xx answers: a redirect is a failure (the browser reports it like a lost connection), never a repeat of the request — with the document and the person's name — on another address. Serve the API at the address you put in storage-url.
  • 401 and 403 mean "no access"; the editor shows its access message. 404 means "not there" (for a draft: "not saved yet" — a normal state). Any other error status is shown with its code, so keep codes meaningful.
  • An error body is { "error": "<code>" }. Only the codes named in the table matter to the editor.
  • Identifiers (orgId, projectId, documentId) match ^(?!\.+$)[A-Za-z0-9._-]{1,64}$: letters, digits, ., _ and -, at most 64 of them, and not made of dots only — not . or ... Refuse anything else before it reaches a file path or a query. A path segment that is . or .. — written plainly or as %2e%2e — or that contains an encoded /, \ or NUL is refused with 400 { "error": "bad_path" } before your authentication and before the path is interpreted in any other way. The order matters: a rights check written against the path as it was sent (a gateway rule, a function of yours) sees one place, and a server that folds a/../b into b serves another, so a person allowed to read proj-OTHER could read proj-1. Read the path once, refuse the odd segments, and use that one reading for the rights and for the routing.
  • A document is stored as received. Do not reorder or rewrite it. Its size limit is 1 MiB; answer 413 above it, with the answer { "error": "too_large" } and Connection: close — do not just drop the connection, or the editor sees a lost network instead of "too large". The sample reads and discards the rest of an oversized body (up to a cap) so that the client receives the answer.
  • stamp is the UTC time of the publication with : and . replaced by -, for example 2026-10-14T09-30-00-123Z. Stamps must sort as text in time order. Two publications within one millisecond must still get different stamps.
  • The published document, the theme and the images are read by the apps of your customers, not only by the editor. How you protect those reads is your decision; the sample server leaves them to your authentication hook.

Versions and conflicts#

The editor never compares anything except for equality, so a version is any opaque string your API chooses: a counter, a hash of the content, a row revision.

  • Every successful GET and PUT of a draft or of the theme returns the current version in the ETag header. The editor refuses to open a draft that arrives without it, because without a version nobody could detect a clash.

  • A write names the version it was based on:

    • If-Match: "<version>" — the draft was last seen at this version;
    • If-None-Match: * — the editor believes the file does not exist yet;
    • neither header — no check (import, rollback). "Keep mine" is different: it sends If-Match with the current version from your 409, so a server that checks strictly answers conflict again if somebody wrote once more between the conflict and the click, and the person chooses again.
  • When the stored version differs, do not write. Answer 409 with { "error": "conflict", "current": "<version>" }, where current is the stored version, or null if there is no draft. The editor then offers the person to open the other version or keep theirs.

  • The one exception: the write carries X-Hotlayout-Writer: <random id of this editor session> and X-Hotlayout-Writer-Revision: <integer> — a number that grows with every revision of the document in this session; a retry of the same revision carries the same number. If the stored draft was last written by the same writer, accept the write even when the base is behind, but only forward: nobody else wrote in between, yet an older revision of the same session may arrive after a newer one (a retry after a timeout, a save sent again when the page closes). Store the writer and the revision next to the draft, and when the base is behind and the writer is the same:

    • the revision is greater than the stored one — write;
    • the revision is equal — a repeat: answer 200 with the stored ETag and write nothing if the body is the same, otherwise 409 { "error": "stale" };
    • the revision is smaller, or either number is missing — do not write: 409 { "error": "stale" } for a smaller one, 409 { "error": "conflict", "current" } when there is no number to compare.

    Without the exception a second save that left before the answer to the first one would conflict with itself. The editor treats stale on its own draft write as "a newer revision of mine is already there" and shows no conflict. A storage object receives the same two values as request.writer and request.writerRevision and follows the same rule.

  • When saving fails, the editor shows it and keeps trying: a few quick attempts, then one attempt every 30 seconds, and at once when the browser reports that the network is back. Autosave does not give up, and Save now tries immediately. Plan a maintenance window accordingly: edits made during it are saved when your API answers again, provided the page stays open.

  • A deliberate replacement of the draft adds X-Hotlayout-Replace-Reason: rollback | import | takeTheirs | keepMine and, for a rollback, X-Hotlayout-Replace-From: <stamp>. Record them in your audit log; the sample server does.

  • Publishing takes the same If-Match / If-None-Match, naming the version of the draft the editor saw. If the draft has changed since, answer 409 with { "error": "stale" } and publish nothing: the page is out of date, and publishing from it would roll the apps back.

  • A publication does three things at once, and they must succeed or fail together: the new published document, the version snapshot under its stamp, and the record of who published (by from your token, byEmail if you know it, at as an ISO 8601 time).

  • The theme works like the draft: ETag, If-Match / If-None-Match: *, 409 with { "error": "stale" }. A request with X-Hotlayout-Overwrite: true skips the check — the person has confirmed "publish mine anyway".

Named data scenarios#

A scenario is a saved choice of sample data that a person can reopen in the preview. It is stored like the theme: one record per scenario, an opaque version in ETag, and If-Match / If-None-Match: * on writes.

  • The body of a PUT has four fields: format (the integer 1), name, base and picksText (a JSON text). Store them as received and return them as they are in GET scenarios and GET scenarios/{id}; a record whose format is higher than the editor knows is shown as unavailable and never rewritten.
  • Add your own accounting to the record when you store it: createdAt, createdBy, actor, actedAt, all strings, taken from your verified token. The editor reads them back and never sends them.
  • If-None-Match: * means "create": answer 409 { "error": "stale" } if the id is taken. If-Match on a write or a delete names the version the person saw; answer 409 { "error": "stale" } when it differs. The editor then reads the record with GET scenarios/{id} and offers the person the choice.
  • Scenarios are optional, in the HTTP API and in a storage object alike (listScenarios, saveScenario, deleteScenario, all three or none). An API that has no scenario routes answers 404 to the list: the editor reads it as "this storage has no scenarios", shows no scenario controls and no error.

Review before publishing#

The editor can send the draft to a colleague for review, give a person outside the team a link to a frozen copy, and (when you turn it on) refuse to publish anything a second person has not approved. All nine review rows of the table are one feature: serve all of them, or none, and leave the nine methods out of a storage object — without any of them the editor draws no review actions.

What the API must keep, the same as the HotLayout cloud does:

  • The snapshot never changes. POST …/reviews stores the document, the theme and the data dictionary exactly as sent, once; every reviewer reads the same bytes. A snapshot of 1 MiB or more is refused with 413. The snapshot does not carry the e-mail of the person who sent it — a stranger with a link reads the snapshot.
  • You choose the facts, not the editor. The id of the review, its version, the time and the author come from your side: the author from the verified token. Ignore sentBy, version, reviewId and the times if a client sends them. The version of a document's reviews grows by exactly one (1, 2, 3 …) and is never reused; two reviews sent at the same moment must not get the same version.
  • The record is what lists and the review page show: { "format": 1, "reviewId", "version", "sentBy", "sentByEmail"?, "sentAt", "documentName"?, "note"?, "snapshotMd5", "snapshotBytes", "state": "open" | "approved" | "returned", "decision": null | { "by", "byEmail"?, "at", "comment"? }, "link": null | { "enabledBy", "enabledAt", "expiresAt", "revokedBy"?, "revokedAt"? } }. Ids of a document and of a review in these paths have no dot (letters, digits, _, -). latest is the review with the highest version, or null.
  • The address of the link (url) is yours to name. A person outside the team opens a page, and only your server knows where that page is: the editor is on an internal address the stranger cannot reach, and a link built on it would put the token into the request log of the editor's web server. Answer url (an https:// address) next to token, for example https://reviews.bank.example/#<documentId>/<reviewId>/<token>: the part after # never reaches a server log, and your page reads the copy with GET …/review-links/{reviewId}/{token}. The editor shows and copies exactly this address. If you do not answer url, the editor does not offer the link: it turns the token off again and says the storage has no page for outside review. The sample server answers url only when the environment variable REVIEW_PAGE_URL is set, and does not ship the page.
  • The link token is 256 random bits (32 bytes, base64url, 43 characters), lives only in the answers of …/link, and is never in a record, a list or a log. The term is 1 to 30 days (7 when days is absent). A new link closes the previous one at once. A revoked link stays revoked, and a repeated DELETE changes nothing. Reading by link answers 404 for a missing, revoked, expired or wrong token alike, so that a stranger learns nothing about which it was; compare tokens in constant time.
  • The decision. The person who sent a version does not decide it (403 own_review); a version is decided once (409 already_decided) and only the latest version is decided (409 not_latest); "returned" needs a comment (400 comment_required); a comment has at most 2000 characters. Check in this order. The reviewer is the verified token again, never a field of the body.
  • Rights. The cloud lets everyone who can edit send a review, people who can publish enable the link, and people who can publish decide. The sample server only authenticates — add your own authorisation where BANK: stands.
  • "Publish only what was approved". GET approval-policy says whether the project requires it. When it does, make POST …/publish answer 409 { "error": "approval_required" } unless the published document equals the document of the latest approved review (compare the documents as canonical JSON without schemaVersion). The editor already greys out the button; the check on your side is what makes it a rule and not a habit. An API without the approval-policy route (404) is read as "not required". An API that has no review routes at all (404 on the list of reviews) is read as "no review feature": the editor shows no review actions and no error.

The placement map#

GET placements returns the published placement map of the project with an ETag. The body is the inner object only — { "placementsVersion", "publishedAt", "placements": { … } } — not the whole webhook body that carries it (version, event, generation, …). An answer in another shape is read as "not checked". The editor only reads it — to warn at publishing that a placement points at an entry point the new version no longer has. What the apps do with the map is in Placements. Your own admin writes the file; there is no write request in this API.

The screen map layout#

The Map tab of the editor shows every screen of the document as a card, and people arrange the cards by dragging them. Where each card stands is shared by the team, so the editor keeps it next to the document: { "format": "hotlayout-map/1", "positions": { "<screenId>": { "x": 120, "y": -40 } } }, with whole numbers from -100000 to 100000. It is data of the editor only: phones never read it, it is not part of the document, and publishing does not touch it. The PUT replaces the file whole and there is no version check — the editor reads the file again right before it writes and changes only the screens the person moved, so two people arranging the map at once do not undo each other. Both routes are optional: without them (or without loadMapLayout and saveMapLayout in a storage object) the layout stays in the person's browser, and the map says so.

The live copy#

On my phone in the editor writes the draft, the theme and the data dictionary to documents/{id}/live/{token} right away and after every saved change; Stop showing writes { "format": "hotlayout-live/1", "stopped": true } to the same address. token is 43 characters of base64url. The route is optional: answer 404 or 405 and the person is told that the copy for the phone could not be prepared, or leave saveLive out of a storage object and the button is not drawn at all. If you serve it, let the phone read the copy by its address without a session (GET of the same path, the token in the address is the key), keep it for a limited time after the last write (the cloud keeps one hour; the sample server does the same and answers 404 afterwards), and never list the folder. Answer { "url" } with the address the phone should read; the editor uses it only when it starts with https://, and otherwise the address of the request. The live preview page describes the envelope.

Cross-origin pages#

When the editor page and the API are on different origins, the API must answer the preflight and expose the version header:

Access-Control-Allow-Origin: https://builder.bank.example
Access-Control-Allow-Headers: Authorization, Content-Type, If-Match, If-None-Match, X-Hotlayout-Writer, X-Hotlayout-Writer-Revision, X-Hotlayout-Replace-Reason, X-Hotlayout-Replace-From, X-Hotlayout-Overwrite, X-Hotlayout-User
Access-Control-Allow-Methods: GET, HEAD, PUT, POST, DELETE, OPTIONS
Access-Control-Expose-Headers: ETag

Without Access-Control-Expose-Headers: ETag the browser hides the version from the editor, and the draft does not open. This is the most common reason for "the document does not open" in a new installation.

Images#

The editor checks a file before it sends it (type by its first bytes, size, a free name), so your API gets PNG, JPEG or WebP files with a free name. It still must protect itself: check the type and the size, and refuse a name that is already taken with 409. Check the content, not only the declared type: the Content-Type is the caller's word, and an HTML page sent as image/png and served from your address is a page on your address. The sample compares the first bytes with the type (PNG, JPEG, WebP) and answers 415 when they differ, and serves every image with X-Content-Type-Options: nosniff and Content-Security-Policy: default-src 'none'.

The address of an image is chosen by your API. Every item of GET media and every successful upload carries a url; the editor puts exactly that address into the document and never builds one. Make it an address the apps of your customers can reach, and stable: it stays in published documents. The editor recognises a library image by the address: either …/{orgId}/{projectId}/media/ of your API, or the folder of any address your API has returned in GET media or in an upload answer. So images served from another host, such as a CDN, are recognised once the library has been listed.

SVG#

An SVG file is a document that can carry scripts, so it must never be stored as received. The editor sends it to the same PUT media/{name} with Content-Type: image/svg+xml, and your API chooses one of three answers:

Answer When
201 with the item you sanitised the file and stored the clean result
422 { "error": "svg_not_supported" } your installation does not accept SVG; the person is told to use PNG or WebP
422 { "error": "svg_rejected", "why": "<reason>" } the file is not acceptable; why is one of not-svg, too-large, too-complex, doctype, embedded-raster, empty, no-size, name-taken, internal

The sample server answers svg_not_supported. Add a sanitiser of your own before you accept SVG.

Sign-in and the person#

Setting storage-url (or the storage property) switches the editor into the bank mode, and in it the editor has no sign-in of its own: no form, no request to identitytoolkit.googleapis.com, securetoken.googleapis.com or hotlayout.com, nothing kept in localStorage. Your page signs the person in; the editor only needs two things from it.

  • Who is working — the user property, { id: string, email?: string, name?: string }. It signs the edits: the REST adapter sends it on every request as the X-Hotlayout-User header (percent-encoded JSON; the sample server decodes it), and a storage object receives it as scope.user. Without it the person is { id: 'anonymous' } and the console says so once. The header is only what the page claims: take the real author from your verified token or session and use the header at most as a display name.
  • A token — the tokenProvider property, optional. Whatever it returns is an opaque string: the editor sends it as Authorization: Bearer <token> (REST) or hands it to your storage object in scope.token, and never reads what is inside. If the provider fails or returns an empty string, the editor makes no request and shows the sign-in problem. Without a provider the REST adapter sends no Authorization header.

Two more things to know:

  • sessionProvider has no effect. The ticket exchange talks to HotLayout servers, so the element ignores the property and writes one sentence to the console.
  • The access attribute (view, edit, publish) works as everywhere: it only decides what the editor draws, and publishing is drawn only on publish. Enforce the same rule on your API.

Requests from other sites (CSRF)#

If your API accepts a session cookie — which is what a host that gives no tokenProvider relies on — then a page of any other site can make the person's browser send a POST, PUT or DELETE to it, cookie included. The page cannot read the answer, but the change is made: a published screen, a replaced theme. A bearer token in Authorization is not sent by the browser on its own and is not exposed to this, but a cookie is. For every state-changing request (POST, PUT, DELETE, PATCH):

  1. Check Origin. Browsers attach it to such requests. Refuse with 403 { "error": "cross_origin_refused" } when it is present and is neither your own origin nor one you list (ALLOWED_ORIGINS in the sample). When Origin is absent, refuse a request whose Sec-Fetch-Site is cross-site. A caller that is not a browser sends neither, and passes: it carries a token the attacker's page cannot read.
  2. Require Content-Type: application/json for every JSON body, and answer 415 otherwise. The editor always sends it. A type such as text/plain or multipart/form-data is what lets a hostile page skip the browser's preflight question to your server, so refusing it closes the way that needs no cookie rule at all.
  3. Set SameSite=Lax or Strict on the session cookie (and Secure, HttpOnly). This is the third wall, not the first: it is your cookie, so only your code can set it.

The sample server does the first two for every route, before it looks at who is asking, and writes the refusal to the audit log as access.denied. With ALLOWED_ORIGINS=* the origin check is off by your choice, and only the content type stands. The editor needs nothing changed: it sends Origin and Content-Type: application/json as the browser and the adapter do on their own.

Audit log#

A bank has to answer who did what and when. In this mode the log is kept by your server, not by the editor. Every action of the editor that changes anything is exactly one request to your API, so the server already has all three facts: the person from the verified token in Authorization, the time from its own clock, and the action from the method, the path and a few headers of the request. The editor sends no separate event and calls no separate log endpoint: a second channel could be bypassed or lose a message, a request that does the change cannot be.

What the editor guarantees is that every action is recognisable from its request alone. Write one line per request that changed state (answered 2xx), plus one per refusal of access (401, 403):

The person… Request Action to write Worth recording
saves the draft (autosave included) PUT documents/{id}/draft document.draftEdited the new version
rolls back to a version, imports JSON, takes the other person's version the same PUT, with X-Hotlayout-Replace-Reason: rollback | import | takeTheirs | keepMine document.draftReplaced the reason (keepMine is "keep mine" after a conflict: it overwrites what somebody else saved, so it is the line to look for when a colleague's change disappears) and, for a rollback, X-Hotlayout-Replace-From (the stamp). These are the page's claim: you can record it, you cannot check it
publishes POST documents/{id}/publish document.published the stamp of the answer; whether the approval check passed
publishes the theme PUT theme theme.published the version; whether X-Hotlayout-Overwrite: true was sent
uploads an image PUT media/{name} media.uploaded the file name
creates a scenario PUT scenarios/{id} with If-None-Match: * scenario.created
changes a scenario PUT scenarios/{id} with If-Match scenario.changed
deletes a scenario DELETE scenarios/{id} scenario.deleted
sends a draft for review POST documents/{id}/reviews review.created review id, version
enables the review link POST …/reviews/{reviewId}/link review.linkEnabled review id, the end of the term. Never the token
revokes the review link DELETE …/reviews/{reviewId}/link review.linkRevoked review id
decides a review POST …/reviews/{reviewId}/decision review.decided review id, version, verdict (approved or returned)
shows the draft on a phone, or stops showing it PUT documents/{id}/live/{token} live.updated whether the envelope is stopped. Never the token
arranges the screen map PUT documents/{id}/map-layout map.arranged how many screens have a position
is refused any of the above answered 401 or 403 (a request refused as coming from another site is 403 cross_origin_refused) access.denied status, error code, the action that was attempted. The document id is written only when it has the form of an identifier: the refused request is the caller's text

Reads (GET, HEAD) change nothing and need no line. The names are the ones the HotLayout cloud writes in its own log, so a bank and a cloud customer read the same words. A 409 or 404 is not a change and not a refusal of access, so it gets no line.

Things the editor does that you may see as several requests: autosave writes the draft after a pause in typing, so a long editing session is many document.draftEdited lines; aggregate them in your SIEM if that is noise. Publishing is one request, not three.

The line of the sample server#

The sample server (audit.mjs) appends one JSON object per line to audit.jsonl in its data folder:

{"at":"2026-10-27T10:00:03.120Z","actor":"olena","action":"document.published","org":"org-bank","project":"proj-1","documentId":"doc-1","details":{"stamp":"2026-10-27T10-00-03-120Z"}}
Field Meaning
at the time of the server, ISO 8601 UTC
actor the subject (sub) of the verified token; null when nobody was identified (401)
action one of the names above
org, project, documentId where; documentId is absent for the theme, images and scenarios
details small and fixed per action, see the table

The line never carries a token of a person, the token of a review link or of a live copy, a secret, or the path of a refused request (a path can contain a link token). Copy the rule, not only the format: whatever you add to a line, keep the tokens out of it. In production send the lines to your own SIEM instead of a file.

What does not work in this mode#

  • The HotLayout admin (organizations, projects, members, invitations, plans) is not part of it. Your own admin lists the documents and opens the editor with the three address attributes.
  • The HotLayout activity log is not written, and no event leaves the editor. Your API keeps the audit log, because every action passes through it: see Audit log.
  • Webhook delivery from HotLayout is not used: nothing leaves your network. Your API receives the published document itself, so it is the delivery: serve it to the apps from your own servers, as described in the backend guide. If your backend already receives the webhook of the cloud, the sample server below can send the same request from inside your network.
  • The editor's own sign-in and the ticket exchange of sessionProvider are off in this mode: see Sign-in and the person.

Licence key#

In this mode the editor starts only with a licence key from HotLayout. The key is one line of text that starts with hl_lic_. Put it into the licence-key attribute, or assign it to the licenceKey property:

<hotlayout-builder
  storage-url="https://builder-api.bank.example/hotlayout"
  licence-key="hl_lic_eyJsaWNlbmNlSWQiOi…"
  org-id="your-org-id"
  project-id="your-project-id"
  document-id="your-document-id"
></hotlayout-builder>

The key is not a secret. It names your company, the addresses where the editor may run, the end date, the enabled features and the number of people in the agreement, and it carries a signature that only HotLayout can make. The editor checks it in the browser, with no request anywhere: when the page opens and once an hour after that. Any change to the text, even one letter, breaks the signature.

The addresses are exact origins, compared with the address of the page that shows the editor: scheme, host and port. https://builder.bank.example and http://builder.bank.example are two different origins, and so are :443 and :8443. Tell HotLayout every origin where your people open the editor, including test and standby installations.

What the people see:

State of the key What happens
no key, a damaged key, a key for other addresses, a key signed with a key this version of the editor does not know the editor does not open: the page says No valid HotLayout licence, the licence number if it can be read, and the reason. Your storage is not read
valid, more than 30 days left the editor works with no marks
30 days or less left a bar above the editor: the licence expires on a date — contact HotLayout. Everyone sees it
expired, up to 14 days ago the same bar, more prominent, with the date when publishing stops
expired more than 14 days ago people can keep editing and drafts are saved, but Publish is greyed out with the reason in words. What is already published and your apps are not affected

The editor uses the clock of the computer it runs on. The browser console tells your developers what is wrong with a key that is not accepted, in English.

Renewing means replacing the line: HotLayout sends a new key with a new end date, you put it into the attribute instead of the old one, and the editor uses it on the next page load. Nothing is reinstalled. A key works with every version of the editor released before its end date.

Licensing terms are part of the agreement with HotLayout.

The sample server#

HotLayout provides a sample server on request, together with the editor files and the licence key; it is not part of the public documentation. It is a complete implementation of this API in Node.js (examples/self-hosted-server/: server.mjs, reviews.mjs for the review routes, and routes-*.mjs for the live copy, scenarios and images), with no dependencies. Read it as a specification you can run, or start your pilot with it.

One command#

The folder holds a Dockerfile and a compose.yaml. One container serves, on one origin: a minimal admin page (the documents of a project, create one, open it in the editor), the editor file, a reader page that draws the published document with the React package, and the API under /api:

cd examples/self-hosted-server
cp .env.example .env    # LICENCE_KEY=hl_lic_… for http://localhost:8787
# compose.yaml sets ALLOW_NO_TOKEN=1: the sample pages hand over no token
docker compose up --build

Open http://localhost:8787. The documents are kept in a named volume and survive docker compose restart. The licence key comes from the LICENCE_KEY variable and is not built into the image; without it the page says which variable is missing. The port is published on 127.0.0.1 only, because the sign-in of the sample is a stub. The editor publishes image addresses only when they start with https://, so put the container behind your HTTPS proxy and set PUBLIC_URL to that address before you publish screens with images.

Set WEBHOOK_URL and WEBHOOK_SECRET, and after each publication of a document the server sends the same request as the HotLayout cloud: the body, the headers, the signature and the retries of the webhook. Your receiver is then the same code in both modes. The differences: the address may be inside your network (http: or https:), dataContract is always null (the server keeps no data dictionary; your page hands it to the editor), and the request goes after the editor has been answered, so publishing never waits for your backend.

The API alone#

cd examples/self-hosted-server
# ALLOW_NO_TOKEN=1 lets a page without a tokenProvider work; drop it when your page hands over a token
ALLOW_NO_TOKEN=1 DATA_DIR=./data ALLOWED_ORIGINS=http://localhost:5173 node server.mjs
Variable Meaning Default
PORT port to listen on 8787
ALLOW_NO_TOKEN set to 1 to accept requests without an Authorization header (a host that gave no tokenProvider) requests without a token get 401
DATA_DIR folder for the files ./data (/data in the container)
ALLOWED_ORIGINS comma-separated origins of the editor page; * allows all * (with a warning); in the container, only its own origin
API_TOKEN if set, the only token the server accepts any non-empty token
PUBLIC_BASE_URL the start of image addresses in answers; used by server.mjs run alone — the container's start.mjs sets it from PUBLIC_URL plus /api the Host of the request
LICENCE_KEY container only: the licence key the admin page hands to the editor empty
PUBLIC_URL container only: the address people open, an origin without a path (https://hotlayout.bank.example); image addresses start with it plus /api. The server refuses to start on anything else; it warns when the address is not https: (screens accept only https: image addresses) and when the licence key names other addresses (read without checking the signature, only as a hint) http://localhost:8787
ORG_ID, PROJECT_ID container only: the organization and the project of the admin page org-bank, proj-1
WEBHOOK_URL, WEBHOOK_SECRET container only: send the webhook after each publication off

What your team replaces#

Each place is marked BANK: in the code.

  1. authenticate() accepts any token. Verify your own session token and return the person; pass your function as createHotlayoutServer({ authenticate }).
  2. The store. The server keeps everything through one object of six operations — read, write, remove, list, append, exclusive — passed as createHotlayoutServer({ store }); the sample's is a folder on disk. For your database or object storage, implement the same six and keep their promises: write is atomic per key; exclusive runs a piece of work with no other one between its reads and its writes (a transaction or a lock in your database; with several server instances it must hold across all of them). Mind the phantom row: SELECT ... FOR UPDATE locks only rows that exist, and a new draft (If-None-Match: *) or a new image name has no row yet, so two requests would both see "absent" and both write. Close that gap with a unique key and INSERT ... ON CONFLICT DO NOTHING (zero inserted rows means "exists"), or an advisory lock derived from the key, or a SERIALIZABLE transaction with a retry; list returns the names one level under a prefix; append only appends (the audit log). Every "compare the version with If-Match, then write" of the routes runs inside exclusive, after the request body has been read, and the rest of the semantics stays in the routes: content-hash versions, distinct stamps for two publications within one millisecond, the writer and writer revision of the draft.
  3. Image files go through the same store; route the media keys to your object storage if that is where images live.
  4. The SVG refusal stays until you add a sanitiser.
  5. The public reads exist because the reader has no token: images (an <img> tag cannot send one), the copy behind a review link and the live copy for a phone (the 256-bit token in the address is the key). Decide how yours are served.
  6. Rights. The sample authenticates; it does not tell an editor from a publisher. Where the cloud lets only people who can publish enable a review link or decide a review, add that check where BANK: stands in reviews.mjs.

Two files of the project folder are written by your side, not by the editor, and the sample only reads them: placements/published.json (the placement map) and project.json with { "publishRequiresApproval": true } (turns on "publish only what was approved").

The same cases run against this server and against an in-memory storage in the editor's test suite, so it is a safe reference for the behaviour above.