Custom metadata
A text variable normally takes its value from the render query, which the editor calls Manual, or from the source asset's DAM metadata, which it calls Asset metadata. custom-metadata adds a third Source type: your own field names.
The point is that an author binds a variable to sku rather than having to remember which slug happens to mean the SKU.
<sfx-template-builder
base-url="https://templates.example.com"
token="PROJECT_TOKEN"
sec-template="SEC_TEMPLATE_KEY"
stateless
custom-metadata='[
{ "key": "sku", "title": "SKU", "group": "Product" },
{ "key": "price", "title": "Price", "group": "Product" },
{ "key": "campaign", "title": "Campaign name" }
]'
></sfx-template-builder>Or as a property, which is nicer for anything built at runtime:
builder.customMetadata = fields.map((f) => ({ key: f.id, title: f.label }))Fields appear in the editor's picker in the order you declare them, grouped under group where present, with title - or the bare key - as the label. Set no model and the source is not offered at all.
Naming the source
The source type is called Custom metadata in the editor by default. custom-metadata-label renames it to fit your domain - External metadata, Product attributes, whatever your authors already call it:
<sfx-template-builder custom-metadata-label="Product attributes" ...></sfx-template-builder>Wording only. The saved template carries the same custom_ckey either way. To rename the rest of the editor's vocabulary, see Editor labels.
Names only
No values travel with the model, and the editor resolves nothing against it. The binding is stored in the saved template on the variable, as custom_ckey:
The variable then renders exactly like a Manual one: your pipeline substitutes the value by putting $slug=value in the render query.
So the round trip is:
The author binds a variable to a key from your model. You store the template.
You read
custom_ckeyback from the template you stored.You look that field up in your own data.
You render with
$<slug>=<that value>.
Until you do, the editor and any render show the variable's default value.
Image variables
Image variables bind the same way: an author picks a field for the image's variable, and your pipeline renders with $slug=<image URL>. The saved variable is type="image_src" with the same source="URL" and custom_ckey.
Mark the fields that hold image URLs with type: "image" and the editor offers image variables only those, and text variables only the rest:
type is optional and defaults to "text". Image variables are offered only the fields marked "image", so a model that types nothing offers them none.
If the image layer carries bg_remove="1", the URL you substitute still needs the background-removal parameters appended, exactly as for any image variable. See Background-removed image sources.
Consequences worth knowing
The model can change between sessions. A variable bound to a key your current model does not list keeps its binding. The editor shows it read-only and says so, so opening a template with a narrower model never silently rewrites it.
Nothing is validated at render time. A key you stop sending simply stops being substituted, and the default shows instead.
Send it whenever you like. The widget delivers the model as soon as the editor is ready and re-sends it whenever you change it. Assigning an equal model is a no-op.
It applies to DAM-backed embeds too, not only stateless ones.
The variation builder shows the binding but does not fill it. A saved variation renders from its own values, so a bound variable is filled in there like any other, under a badge naming the field: its
title, or the barekeywhen the editor has no model. An image variable keeps its URL field and DAM picker. A render URL your pipeline builds still sets the value with$slug=.Malformed fields are dropped, not fatal. An entry with no
key, a duplicatekey- first one wins - or akeycontaining a character XML cannot carry, such as a C0 control or an unpaired surrogate, is skipped. The rest of the model still works. Ordinary text, punctuation, accents and emoji are all fine.
Asset metadata needs a session
Asset metadata, the second source, reads the DAM's own metadata model and so needs a Hub session. It is unavailable under a security template, where it is dropped from the picker rather than shown disabled. Custom metadata is the source that works in a guest embed, which is usually why an integration reaches for it.
Where to go next
The render URL - delivering the values you looked up
API reference - the model's exact shape