Templates
See Templates for working copy vs publish, schema, and workflow. Get the museum id from listMuseums first.
Every tool that changes a template is checked before anything is saved: against the template as it is now and against what its kind can hold (getTemplateSchema). A call saves all of what it was given or nothing. When a change does not fit, the tool answers Not saved, then one line per problem: which part of what you sent, what is wrong, and what would be right. See Every change is checked.
listTemplates
List every template of a museum. Optionally filter by type (the type string from getTemplateSchema).
| Argument | Type | Required | Description |
|---|---|---|---|
museumId | string | Yes | Museum id from listMuseums |
type | string | No | Template type string from getTemplateSchema |
getTemplate
Get one template and its working copy (the draft tree of nodes). Look this up before you change anything.
| Argument | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Template id |
createTemplate
Create a new template. Pass museumId and a type from getTemplateSchema; a type that is not a kind of template is turned down with the list of kinds. A receipt (the PDF, its email, the one a cash register prints), a price tag, a printed ticket, a voucher and a booking start as a copy of Loby's own for that kind, so read what comes back before you add to it; the other kinds start empty. It is a working copy: guests see it once someone publishes it in Loby Cloud and, where a museum has one in use per kind (getTemplateAssignments), picks it there.
| Argument | Type | Required | Description |
|---|---|---|---|
museumId | string | Yes | Museum id |
type | string | Yes | Template type string from getTemplateSchema |
name | string | No | Name of the template |
renameTemplate
Change the name of a template. Does not change the working copy.
| Argument | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Template id |
name | string | Yes | New name |
deleteTemplate
Remove a template. Guests keep seeing the last published version until a replacement is published.
| Argument | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Template id |
insertTemplateNodes
Add one or many nodes in a single change; use it for a whole block. Each node needs a type this kind of template can hold, with the props and styles that type has there (getTemplateSchema). LAYER and other groups may hold children. All of the nodes are saved or none.
| Argument | Type | Required | Description |
|---|---|---|---|
templateId | string | Yes | Template id |
nodes | array | Yes | List of nodes: [{ type, props, styles, children }]. styles may be one flat object, { fontSize: 13 }. A TEXT may be written { type: "TEXT", text: "Tak for besøget", language: "da" }; without language the text is in the museum's default language. Leave id out: each node gets one. |
parentId | string | No | Id of the node to add them inside; it has to be one that holds nodes, like a LAYER. Omit or pass null for the top level. |
index | integer | No | Place among the parent's nodes, counted from 0. Omit to add at the end. |
Returns the nodes as they are stored (nodes), their ids (insertedNodeIds), parentId and the template's nodeCount. It does not return the whole working copy; call getTemplate for that.
updateTemplateNode
Change one node. Only what you pass changes: props, styles, the text of a TEXT in one language, the name shown in the designer, or whether the node is hidden. All of it is saved or none.
| Argument | Type | Required | Description |
|---|---|---|---|
templateId | string | Yes | Template id |
nodeId | string | Yes | Id of the node, from getTemplate |
props | object | No | Object of props to set, for example { url: "https://…" }. null on a key clears it. |
styles | object | No | Object of styles to set, for example { fontSize: 13 }. null on a key clears it. The names are the ones this kind of template has (getTemplateSchema), not CSS. |
elementStyles | array | No | List of { element, propertyName, propertyValue, stylesKey } for checkout and rich text. |
text | string | No | The text of a TEXT node in one language. Its other languages keep their text: change each one the wording should change in. An empty text removes that language. |
language | string | No | The language text is written in, two letters. Defaults to the museum's default language (masterLanguage on listMuseums). |
name | string | No | Display name in the tree |
hide | boolean | No | Hide or show the node |
Returns the node as it is stored now (node), its parentId and the template's nodeCount.
An older text can be a plain text, or hold value beside its translations: the words it shows in every language it has no translation for. The first time text changes such a node it becomes one text per language, with those words as the default language's.
removeTemplateNode
Remove one node and everything inside it.
| Argument | Type | Required | Description |
|---|---|---|---|
templateId | string | Yes | Template id |
nodeId | string | Yes | Node id |
moveTemplateNode
Move one node next to or inside another. placement is INSIDE, ABOVE, or BELOW. INSIDE needs a target that holds nodes, and a node cannot be moved into itself. Returns where the node sits now (parentId, index).
| Argument | Type | Required | Description |
|---|---|---|---|
templateId | string | Yes | Template id |
nodeId | string | Yes | Node to move |
targetId | string | Yes | Node to move relative to |
placement | string | Yes | INSIDE, ABOVE, or BELOW |
setTemplateOption
Change an option of the whole template (an email's subject and background colour, a pass's images and colours, a label's size, an app's content roots, default styles and intro). The options a kind has, with what each takes, are in getTemplateSchema; another option is turned down. Returns the template's options as they are stored now.
| Argument | Type | Required | Description |
|---|---|---|---|
templateId | string | Yes | Template id |
path | string | Yes | Name of the option, from getTemplateSchema: for example subject, backgroundColor or labelWidth |
value | any | No | New value. Omit or pass null to clear. |
language | string | No | The language a subject is written in, two letters. Defaults to the museum's default language. |
getTemplateSchema
What a kind of template can hold: its node types with their props, the styles each has there, its options, the values it is drawn from (variables), and what a condition can test on it (conditions). A change that uses anything else is turned down. Pass a type for one kind, or a category (email, print, wallet, seating, thermal, mobile, website, checkout, selfService, customerScreen, receiptPrinter, labelPrinter, ticketPrinter). With neither, lists kinds.
| Argument | Type | Required | Description |
|---|---|---|---|
type | string | No | Template type string, for example from listTemplates |
category | string | No | email, print, wallet, seating, thermal, mobile, website, checkout, selfService, customerScreen, receiptPrinter, labelPrinter, or ticketPrinter |
getTemplateAssignments
See which default emails, PDFs, passes, thermal slips, checkout styling and customer screen welcome screen a museum uses, and under overrides the items that chose their own instead: booking types and things (the booking PDF and email; a thing's own wins over its type's, which wins over the museum's), ticket types and voucher products (their PDF), and locations (their ticket receipt email). Events and their ticket types choose theirs on each event and are not listed. Read-only.
| Argument | Type | Required | Description |
|---|---|---|---|
museumId | string | Yes | Museum id |