Skip to content

Widget developer guide: embed, prefill, webhooks and booking return

Download for agent.md

This guide as one Markdown file for an AI coding agent. Agents can also fetch it directly:

https://help.templatesbooth.com/widget/widget-developer-guide/?format=md
Contents

This guide is for developers who connect the TemplatesBooth Widget to a website, a customer portal or a booking system. It covers every way to embed the widget, the link parameters it reads, how to prefill the form, how to pass your own details (a booking or event ID) through the widget, how to send guests back to your system after they submit, the webhook, page events, and how to check signatures.

Your guests never see TemplatesBooth in the widget. This guide is for members and their developers, so it uses the TemplatesBooth names.

What you need: a TemplatesBooth membership and a widget. You create widgets in the Widget dashboard. Each widget has an ID such as w_yourwidget. The Embed tab shows your codes. The Connect tab holds notifications, the redirect, the booking return, pass-through fields and the webhook.


1. Three ways to embed

Embed script (embed.js)
Best for
Your own website or portal
Height
Grows with its content; opens full-screen sheets on phones
Page events
Yes, as DOM events
Prefill by JavaScript
Yes, TBWidget.prefill()
Plain iframe
Best for
Sites or apps that remove <script> tags, booking systems that frame pages
Height
Fixed; scrolls inside
Page events
Yes, as postMessage
Prefill by JavaScript
Yes, by postMessage
Hosted page
Best for
Links in e-mails, social posts, a "link in bio"
Height
Full page
Page events
No (it is a page, not a frame)
Prefill by JavaScript
No (link parameters only)

All three show the same widget with the same settings. A change you save in the dashboard reaches every copy.

Copy it from Embed → Embed code. It looks like this:

HTML
<script async src="https://widget.templatesbooth.com/embed.js" data-tbw="w_yourwidget"></script>

Paste it where the widget should appear. The script adds an iframe right after itself (or inside data-target). The iframe grows to fit its content. On phones, sheets such as the preview and the form cover the screen. If you connect your own domain to the widget, the dashboard gives you the same code loading from your domain. Use the code exactly as the dashboard shows it.

Attributes on the <script> tag:

data-tbw
Which widget to show. The dashboard always names the widget by ID, because the ID never changes.
Values
widget ID (w_…)
Default
required
data-lang
Interface language. auto uses the page's <html lang>, then the browser's language. Codes: en fr de es nl pt it pl he th ru ar hi lv.
Values
auto or a language code
Default
the widget's language
data-theme
Forces light or dark colors.
Values
light, dark, auto
Default
the widget's Look settings
data-min-height
Space kept for the widget while it loads.
Values
pixels (≥ 120)
Default
480
data-target
Puts the widget inside this element instead of after the script tag.
Values
CSS selector
Default
none
data-prefill
0 stops the script from passing anything from your page's address to the widget: no tbw_ parameters and no pass-through fields (see §3).
Values
0
Default
on
data-fit
content = grow with the content. box = a fixed box that scrolls inside. auto = content, or box when your page is itself inside an iframe (Wix, GoDaddy HTML elements).
Values
auto, content, box
Default
auto
data-height
Height of the box when data-fit is box.
Values
pixels
Default
fills the screen
data-offset
Height of a fixed or sticky site header, so the widget scrolls to just below it.
Values
pixels
Default
detected
data-title
The iframe's accessible title (screen readers).
Values
text
Default
"Choose your design"
data-return-hosts
Extra hosts this script lets the widget move the page to. It does not allow a tbw_return host: that is Connect → Allowed return websites (see §5).
Values
host names, comma or space separated
Default
none

Several widgets on one page work: add one script tag per widget. If the page adds a script tag later (a single-page app), call window.TBWidget.scan() after adding it.

window.TBWidget (created by the script):

Member What it is
TBWidget.prefill(fields, id?) Fills the form and sets pass-through fields in every widget on the page, or only in one (id = the iframe's name from the tbw:ready event, or the widget ID w_…). See §3.
TBWidget.scan() Mounts script tags added after the page loaded.
TBWidget.list The mounted widgets: { id, pid, iframe } each.

1.2 Plain iframe

Copy it from Embed → If your website blocks scripts:

HTML
<iframe src="https://widget.templatesbooth.com/w/w_yourwidget/embed/?boxed=1"
        title="Choose your design" loading="lazy"
        allow="clipboard-write; screen-wake-lock"
        style="width:100%;height:900px;border:0"></iframe>
  • Keep boxed=1. It tells the widget that it sits in a fixed-height frame.
  • Set the height you need (the dashboard's Frame height sets the number in the code).
  • You can add link parameters and pass-through fields to the src (see §2), for example &tbw_ref=EV-456&event_id=456.
  • Any website may frame /embed/. The widget sends Content-Security-Policy: frame-ancestors *.
  • If you add a sandbox attribute, include at least allow-scripts allow-same-origin allow-forms allow-popups allow-top-navigation-by-user-activation. Without top navigation the widget cannot send the guest on to your page after Send.
  • Do not give the iframe a name that starts with tbw_. Those names are reserved for embed.js.
  • In a plain iframe the widget often cannot see your page's address (a strict Referrer-Policy hides it), so list your host in Allowed return websites if you use the booking return (see §5.1).

1.3 Hosted page

Embed → Hosted page shows your widget's own address, for example https://widget.templatesbooth.com/your-business/. The ID form https://widget.templatesbooth.com/w/w_yourwidget/ always works and forwards to it. Link parameters go in its address (see §2). The hosted page is not indexed by search engines (on your own domain you can switch indexing on).

1.4 Old embed codes

Embed codes from the previous widget (templatesbooth.com/widget-embed/?key=…) now show your default widget in a fixed-height box. They keep working, and keep their old parameters (default_layout, default_type, tag, image_type, no_of_images, search_val). They cannot read your page's address, so they cannot pick up tbw_ parameters or pass-through fields from it, and they send page events only as postMessage, like a plain iframe. Replace them with the new embed code for any integration.


2. Link parameters

You can put these parameters in three places:

  • your page's address, when the page uses embed.js (the script hands them to the widget);
  • the src of a plain iframe;
  • the hosted page's address.

Values must be URL-encoded (encodeURIComponent in JavaScript, rawurlencode in PHP).

Fill in the customer's details

tbw_name
Fills the Name field.
Example
tbw_name=Anna%20Smith
Limits
120 characters (a longer name is refused at Send). Personal data: see §3.2.
tbw_email
Fills the E-mail field.
Example
tbw_email=anna%40example.com
Limits
A valid address, 254 characters. Personal data.
tbw_phone
Fills the Phone field.
Example
tbw_phone=%2B15550100
Limits
5 to 40 characters: digits, spaces and + ( ) . / - only. Personal data.
tbw_date
Fills the Event date.
Example
tbw_date=2027-06-12
Limits
YYYY-MM-DD only. Another format is ignored. The widget refuses a date in the past or more than 5 years ahead.
tbw_lock
Makes the prefilled name, e-mail, phone and date read-only (a lock icon shows).
Example
tbw_lock=1
Limits
A date is locked only when it is valid (today to 5 years ahead).

Your own data

tbw_ref
Your own reference (a booking or event number). Stored with the submission and returned in the webhook (request.source.ref), the booking return, the redirect (when details are added) and page events.
Example
tbw_ref=EV-456
Limits
120 characters. Control characters other than tabs and line breaks are removed; spaces at the ends are trimmed.
your listed names
Pass-through fields: names you list in Connect → Pass-through fields come back with the submission (see §4).
Example
event_id=456
Limits
10 fields, 200 characters each.
tbw_data_<name>
A pass-through field without listing it first. Comes back as franchise.
Example
tbw_data_franchise=north
Limits
As above.

After Send

tbw_return
Where to send the guest after Send, with the submission's details (see §5).
Example
tbw_return=https%3A%2F%2Fbooking.example.com%2Fevents%2F456
Limits
http(s) (use https), 1,000 characters. The host must be allowed.

Open the widget on a design, format, category or search

tbw_designs
Preselects designs by template (post) ID. The guest goes straight to Continue.
Example
tbw_designs=75106,81234
Limits
Up to 20 IDs; only as many as the widget allows (Library → How many designs can a customer choose?). Only when the widget takes submissions.
tbw_layout or layout
Opens the gallery on one format.
Example
tbw_layout=46postcard-p
Limits
One of 26strip, 26horizontal, 46postcard-p, 46postcard-l, 46postcard-h, square (and the animated formats the widget shows). Ignored when the widget does not offer it.
tbw_category or category
Opens the gallery on one occasion.
Example
tbw_category=wedding
Limits
The category's ID or its English slug (as in templatesbooth.com addresses, for example wedding, halloween). Ignored when unknown or hidden in the widget.
tbw_design or design
Opens the preview of one design: {post ID} or {post ID}-{row ID} (a format of that design). This is the form the widget's own Share button uses.
Example
tbw_design=75106-75106002
q
Opens the gallery with this search. Iframe src or hosted page only.
Example
q=gold
Limits
80 characters.

Look and language

tbw_lang or lang
Interface language (as data-lang).
Example
tbw_lang=fr
Limits
The 14 codes above, or auto.
theme
Light or dark colors. Iframe src or hosted page only; with embed.js use data-theme.
Example
theme=dark
Limits
light, dark, auto.

Testing

tbw_preview
Shows the real widget without recording anything; Send is disabled. Useful while you build your page. Iframe src or hosted page only.
Example
tbw_preview=1

With embed.js, your page's address passes on only the tbw_ parameters of this section (except tbw_preview), your pass-through fields and tbw_data_ fields. The short forms (layout, category…), theme and q work in an iframe's src and on the hosted page.

Parameters the widget writes itself, which you do not build: tbw_edit (the guest's edit link), tbw_page and id (added by embed.js), boxed.

Template (post) IDs appear in the webhook (selections[].post_id) and in the links the widget's Share button makes (?design=75106-75106002).

The widget has no event type or venue fields. tbw_event and tbw_venue are ignored. To carry those details, use pass-through fields, for example event_type=wedding&venue=Rosewood%20Hall (see §4).


3. Prefilling the form

You can fill in what you already know about the guest, so they only choose a design. There are two ways.

Add tbw_name, tbw_email, tbw_phone, tbw_date, tbw_ref and tbw_return to the link (see §2). Add tbw_lock=1 to stop the guest changing them.

URL
https://www.example.com/choose-your-design/?tbw_date=2027-06-12&tbw_ref=BK-123&tbw_return=https%3A%2F%2Fbooking.example.com%2Fbook%2F

A field the widget does not show (switched off in the Form tab) is not filled.

3.2 Keep personal data out of addresses

A name, an e-mail address or a phone number in a link ends up in browser history, server logs, analytics tools and the Referer header of other requests. For that reason embed.js never copies tbw_name, tbw_email or tbw_phone into the iframe's address: it reads them from your page's address and hands them to the widget by postMessage. They are still in your page's address, though.

Prefer JavaScript for personal data. Put only non-personal values (a date, a reference, an event ID) in links, and pass the name, e-mail and phone with TBWidget.prefill() (embed script) or tbw:prefill (plain iframe).

3.3 By JavaScript

With embed.js:

HTML
<script async src="https://widget.templatesbooth.com/embed.js" data-tbw="w_yourwidget"></script>
<script>
  // Wait until the widget is ready, then fill it in.
  document.addEventListener('tbw:ready', function (e) {
    window.TBWidget.prefill({
      name: 'Anna Smith',
      email: 'anna@example.com',
      phone: '+1 555 0100',
      date: '2027-06-12',        // YYYY-MM-DD
      ref: 'BK-123',             // your booking reference, ≤ 120 characters
      return: 'https://booking.example.com/bookings/123/design-chosen',
      data: { event_id: '456', franchise_id: '12' },  // pass-through fields (§4)
      lock: true                 // make name, e-mail, phone and date read-only
    }, e.detail.id);             // only this widget
  });
</script>

Fields TBWidget.prefill() takes: name, email, phone, date, ref, return, data, lock. The limits are those of the link parameters (§2). You can call it again at any time: a later call replaces earlier form values, and data from several calls is merged. A call made before the widget is ready is delivered once it is, but window.TBWidget exists only once embed.js has loaded, so call it from the tbw:ready event as above. tbw:ready can fire again (for example after the guest switches language): make the handler safe to run twice.

With a plain iframe: wait for the widget's tbw:ready message, then post tbw:prefill to the iframe with the same fields.

HTML
<iframe id="tbw" src="https://widget.templatesbooth.com/w/w_yourwidget/embed/?boxed=1"
        title="Choose your design" allow="clipboard-write; screen-wake-lock"
        style="width:100%;height:900px;border:0"></iframe>
<script>
  var WIDGET_ORIGIN = 'https://widget.templatesbooth.com'; // or your own widget domain
  var frame = document.getElementById('tbw');
  window.addEventListener('message', function (e) {
    if (e.origin !== WIDGET_ORIGIN || e.source !== frame.contentWindow) return;
    var d = e.data;
    if (!d || d.v !== 2) return;
    if (d.type === 'tbw:ready') {
      frame.contentWindow.postMessage({
        type: 'tbw:prefill', v: 2,
        fields: { name: 'Anna Smith', email: 'anna@example.com', date: '2027-06-12', ref: 'BK-123',
                  data: { event_id: '456' }, lock: true }
      }, WIDGET_ORIGIN);
    }
  });
</script>

Always post with the widget's origin as the target, never '*'.


4. Pass-through fields: your own details, there and back

Pass-through fields carry your own identifiers (a booking ID, an event ID, a franchise, a sales rep) through the widget. The widget stores them with the submission and hands them back under the same names. Nothing changes in your embed code.

4.1 Set up

In Connect → Pass-through fields, list the names your system needs back, for example event_id and franchise_id. Up to 10 names.

A name is 1 to 40 characters of lowercase letters, digits, _ and -. Matching is exact (Event_ID is not event_id). A name cannot start with tbw_, and cannot be one the widget uses itself: id pid t v lang theme design layout category q boxed mock preview legacy extras tag default_layout default_type image_type no_of_images search_val key sort colour colours orientation photos match.

4.2 Three ways to pass values

Way Example Needs the name listed?
The listed name in the address of your page (with embed.js), of a plain iframe's src, or of the hosted page ?event_id=456&franchise_id=12 Yes
tbw_data_<name> in the same places ?tbw_data_franchise_id=12 (comes back as franchise_id) No
JavaScript: TBWidget.prefill({ data: { … } }), or tbw:prefill with fields.data in a plain iframe (§3.3) prefill({ data: { event_id: '456' } }) No

If the same name arrives more than one way, JavaScript wins over tbw_data_<name>, which wins over the listed name.

Values: text (a number is kept as text). Control characters are removed, spaces at the ends are trimmed, and each value is cut at 200 characters. An empty value is not stored. At most 10 fields are kept per submission (listed names first); anything more, and any invalid name, is dropped without an error.

Keep values short: IDs, not text. Fields travel in addresses (the iframe's, the booking return's, the redirect's). With many long fields an address can grow past about 8 KB, and some servers and proxies then answer 414 URI Too Long.

With embed.js the script does not forward your page's whole address. When the widget is ready it asks the page for its listed names, and the script answers with those names and every tbw_data_ parameter from the page's address (never other parameters). data-prefill="0" turns this off.

Cached copies of embed.js. Browsers keep embed.js for 5 minutes and may then run the copy they have once more while they fetch the new one in the background (Cache-Control: max-age=300, stale-while-revalidate=86400). So for up to a day after we update the script, a returning visitor can run an older copy once, which may not hand over listed names or tbw_data_ fields from your page's address. TBWidget.prefill({ data }) works with every copy: use it when a field must always arrive.

With a plain iframe, put the fields in the src, or send them with tbw:prefill (fields.data). The widget also posts { type: 'tbw:ask', v: 2, keys: [your listed names] } to the parent page after tbw:ready. A parent page may answer it with { type: 'tbw:params', v: 2, fields: { event_id: '456' } }, posted to the widget's origin. You only need this if you want the iframe to read the parent page's address the way embed.js does.

Old embed codes (/widget-embed/?key=…) cannot pass fields from your page. Use the new embed code.

4.3 Where they come back

Place How
Webhook request.source.data: { "event_id": "456", "franchise_id": "12" }, always present, {} when none (§7).
Booking return and redirect As plain parameters, event_id=456&franchise_id=12, signed by tbw_signature (§5, §6). The redirect carries them only when Add submission details to the address is on.
Page events payload.data of tbw:submitted and tbw:edited (§9).
Dashboard The submission's details, one row per field, after "Booking reference".
CSV export One column data_<name> per field.

They are never shown to the guest and never appear in the guest's e-mails or their submission page. A guest's later edit of the submission never changes them.

Send test (Connect → Webhook) puts one sample value per listed name in request.source.data (TEST-1, TEST-2, …), so you can test your field mapping.


5. After Send: redirect or booking return

After Send, the guest normally sees the "Submission sent" screen (with an optional Back to website button from Connect → After sending). You can send them somewhere else instead, in two ways.

Redirect Booking return
Set where Connect → Redirect to (one address for every guest) Per link: tbw_return in the link or in prefill()
Details added to the address Only with Add submission details to the address switched on Always
Signatures tbw_signature (with a signing secret) tbw_signature and the older tbw_sig (with a signing secret)
Allowed hosts Any address you save (use https) The page the widget is on, plus Connect → Allowed return websites
What moves With embed.js (data-fit content): the whole page. In a plain iframe, a boxed embed or an old embed code: only the frame The whole page, in every embed
When both are set The booking return wins

The move happens at once after Send, with no countdown. The booking return always moves the whole page: with embed.js the script does it; in a plain iframe the widget moves the top window, and if the browser refuses it opens the address in a new tab (the guest also sees a Continue button). The redirect moves the whole page only with embed.js in its normal mode; in a plain iframe or a boxed embed it opens inside the frame, so a page that refuses to be framed shows nothing. To move a framing page, use the booking return.

A guest's later edit of the submission is saved in the widget: it never redirects or returns.

With a redirect or a booking return, guests do not see the confirmation screen, so they cannot use its edit link. They still get the edit link in their confirmation e-mail (when you allow editing in the Form tab).

5.1 Booking return

  1. In Connect → Booking-system return → Allowed return websites, add the host names of your booking system, for example booking.example.com. *.example.com allows every subdomain of example.com and example.com itself. Up to 20 hosts. The host of the page the widget is on is also allowed when the widget can see it; in a plain iframe it often cannot, so always list your host.
  2. Set a Signing secret in Connect → Webhook (you do not need a webhook URL for this). Without a secret, the address carries no signatures.
  3. Link to the widget with tbw_return (URL-encoded, up to 1,000 characters), and usually tbw_ref and your pass-through fields:
URL
https://widget.templatesbooth.com/w/w_yourwidget/embed/?boxed=1&tbw_ref=EV-456&event_id=456&tbw_return=https%3A%2F%2Fbooking.example.com%2Fevents%2F456%2Fdesign

After Send the guest lands on (one line in reality):

URL
https://booking.example.com/events/456/design?event_id=456&tbw_request=r_k3m9q2x7p4ab&tbw_ref=EV-456
  &tbw_designs=75106,81234&tbw_sig=…&tbw_keys=event_id&tbw_ts=1793000000&tbw_signature=…

A tbw_return whose host is not allowed is dropped without an error: the guest sees the confirmation screen (or your redirect) instead.

5.2 Redirect

Connect → Redirect to sends every guest to one address after Send (use https), for example a thank-you page. Switch on Add submission details to the address to add the submission's details, as for the booking return. Off (the default), the address is used exactly as you typed it.

5.3 The parameters added

In this order:

Parameter Meaning
your pass-through fields event_id=456… under their own names (§4).
tbw_request The submission ID (r_ + 12 characters). The same as request.id in the webhook.
tbw_ref Your tbw_ref. Booking return: always present (empty when you sent none). Redirect: only when there is one.
tbw_designs The chosen template (post) IDs, comma-separated, in the order chosen, each once. A welcome screen is not included.
tbw_sig Booking return only, with a signing secret: the older signature (§6.2).
tbw_keys The pass-through field names, sorted, comma-separated (empty when none).
tbw_ts When the widget made the address (Unix seconds). It is signed, so you can refuse old links.
tbw_signature With a signing secret: the signature of all the above (§6.1).

Your address's own parameters stay as they are. A parameter of yours with the same name as one of these is replaced, never doubled, and a #fragment stays at the end.


6. Verifying the redirect and return signatures

The signatures prove that the widget made the address with these values, so a guest cannot invent a submission ID, swap designs or change your fields after Send. Both use your signing secret (Connect → Webhook), the same secret that signs webhooks.

6.1 tbw_signature (use this one)

tbw_signature = lowercase hex HMAC-SHA256(key = signing secret, message = canonical string).

The canonical string:

  1. Take the signed parameters: the names listed in tbw_keys, plus tbw_request, tbw_designs, tbw_keys and tbw_ts, plus tbw_ref when the address has it.
  2. Take each one's decoded value.
  3. Sort by name (byte order).
  4. Write each as name= + the value encoded per RFC 3986: every byte except A–Z a–z 0–9 - . _ ~ as %XX (upper-case hex, UTF-8; a space is %20). That is PHP's rawurlencode(), or JavaScript's encodeURIComponent() plus ! ' ( ) *.
  5. Join with &.

Then compare with tbw_signature in constant time, and check tbw_ts against your own freshness rule (for example 24 hours).

Worked example. Secret whsec_example; redirect https://example.com/thank-you/; submission r_7k2m9qx3, ref BK-1042, designs 384123 and 385001, fields event_id = "EV 77" and franchise_id = "north", made at 1793000000:

URL
https://example.com/thank-you/?event_id=EV%2077&franchise_id=north&tbw_request=r_7k2m9qx3&tbw_ref=BK-1042&tbw_designs=384123%2C385001&tbw_keys=event_id%2Cfranchise_id&tbw_ts=1793000000&tbw_signature=917d238594b866f5cd758aba0fad924654823ba662b055e9c02048e0f0d1ca43

canonical string:
event_id=EV%2077&franchise_id=north&tbw_designs=384123%2C385001&tbw_keys=event_id%2Cfranchise_id&tbw_ref=BK-1042&tbw_request=r_7k2m9qx3&tbw_ts=1793000000

PHP

PHP
<?php
/** Returns ['request','ref','designs','data','ts'] when tbw_signature is good and fresh, else null. */
function tbw_verify_signature(array $q, string $secret, int $maxAge = 86400): ?array {
    foreach ($q as $v) if (!is_string($v)) return null;     // e.g. ?tbw_keys[]=x
    $got = $q['tbw_signature'] ?? '';
    if ($secret === '' || !preg_match('/^[0-9a-f]{64}$/', $got)) return null;
    $keys  = (string) ($q['tbw_keys'] ?? '') === '' ? [] : explode(',', (string) $q['tbw_keys']);
    $names = array_merge($keys, ['tbw_request', 'tbw_designs', 'tbw_keys', 'tbw_ts']);
    if (array_key_exists('tbw_ref', $q)) $names[] = 'tbw_ref';
    sort($names, SORT_STRING);
    $canonical = implode('&', array_map(fn($k) => $k . '=' . rawurlencode((string) ($q[$k] ?? '')), $names));
    if (!hash_equals(hash_hmac('sha256', $canonical, $secret), $got)) return null;
    $ts = (int) ($q['tbw_ts'] ?? 0);
    if (abs(time() - $ts) >= $maxAge) return null;            // your own freshness rule
    $data = [];
    foreach ($keys as $k) $data[$k] = (string) ($q[$k] ?? '');
    $ids = (string) ($q['tbw_designs'] ?? '');
    return ['request' => (string) $q['tbw_request'], 'ref' => (string) ($q['tbw_ref'] ?? ''),
            'designs' => $ids === '' ? [] : array_map('intval', explode(',', $ids)), 'data' => $data, 'ts' => $ts];
}

$ok = tbw_verify_signature($_GET, (string) getenv('TBW_SIGNING_SECRET'));
if (!$ok) { http_response_code(400); exit('Invalid link'); }
// $ok['data']['event_id'], $ok['request'], $ok['designs'] …

Node.js (18 or later)

Node.js
import { createHmac, timingSafeEqual } from 'node:crypto';

// RFC 3986 encoding: encodeURIComponent() plus ! ' ( ) *
const enc = (v) => encodeURIComponent(v).replace(/[!'()*]/g, (c) => '%' + c.charCodeAt(0).toString(16).toUpperCase());

/** fullUrl must be absolute: with Express use `https://${req.get('host')}${req.originalUrl}`.
 *  Returns { request, ref, designs, data, ts } when tbw_signature is good and fresh, else null. */
export function verifyTbwSignature(fullUrl, secret, maxAgeSeconds = 86400) {
  const p = new URL(fullUrl).searchParams;
  const got = p.get('tbw_signature') || '';  if (!secret || !/^[0-9a-f]{64}$/.test(got)) return null;
  const keys = p.get('tbw_keys') ? p.get('tbw_keys').split(',') : [];
  const names = [...keys, 'tbw_request', 'tbw_designs', 'tbw_keys', 'tbw_ts'];
  if (p.has('tbw_ref')) names.push('tbw_ref');
  names.sort();
  const canonical = names.map((k) => `${k}=${enc(p.get(k) ?? '')}`).join('&');
  const want = createHmac('sha256', secret).update(canonical).digest('hex');
  if (!timingSafeEqual(Buffer.from(want), Buffer.from(got))) return null;
  const ts = Number(p.get('tbw_ts'));
  if (!(Math.abs(Date.now() / 1000 - ts) < maxAgeSeconds)) return null; // your own freshness rule
  const data = Object.fromEntries(keys.map((k) => [k, p.get(k) ?? '']));
  const designs = (p.get('tbw_designs') || '').split(',').filter(Boolean).map(Number);
  return { request: p.get('tbw_request'), ref: p.get('tbw_ref') ?? '', designs, data, ts };
}

Both were run against the widget's own code for redirects and returns, with and without fields, with spaces, &, +, =, /, ( ) ! * ' and accented letters in values, with the worked example above, and with a changed value (refused).

Trust only the fields named in tbw_keys. Any other parameter on the address (your own, or one a visitor added) is not signed.

After verifying, use the values the verifier returns (request, ref, designs, data above), not the query string again. Only the keys in tbw_keys are signed, and frameworks parse addresses their own way: Express, for example, turns a repeated parameter (?event_id=1&event_id=2) into an array, so re-reading req.query after a good check can give you a value that was never signed.

6.2 tbw_sig (older, booking return only)

Addresses made before pass-through fields existed carried only tbw_sig, and the booking return still carries it, unchanged, so existing integrations keep working. It covers tbw_request, tbw_ref and tbw_designs only: not your fields, and no timestamp. New integrations should verify tbw_signature.

tbw_sig = hex HMAC-SHA256(secret, "tbw_request={id}&tbw_ref={ref}&tbw_designs={id1,id2}"), where the ID and ref are encoded like JavaScript's encodeURIComponent() and the design IDs are joined with plain commas.

PHP
<?php
function tbw_encode_uri_component(string $s): string {   // = JavaScript's encodeURIComponent()
    return strtr(rawurlencode($s), ['%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')']);
}
function tbw_verify_sig(array $q, string $secret): bool {
    $signed = 'tbw_request=' . tbw_encode_uri_component((string) ($q['tbw_request'] ?? ''))
            . '&tbw_ref=' . tbw_encode_uri_component((string) ($q['tbw_ref'] ?? ''))
            . '&tbw_designs=' . (string) ($q['tbw_designs'] ?? '');
    return hash_equals(hash_hmac('sha256', $signed, $secret), (string) ($q['tbw_sig'] ?? ''));
}
JavaScript
const signed = `tbw_request=${encodeURIComponent(p.get('tbw_request') || '')}` +
  `&tbw_ref=${encodeURIComponent(p.get('tbw_ref') || '')}&tbw_designs=${p.get('tbw_designs') || ''}`;
const ok = createHmac('sha256', secret).update(signed).digest('hex') === p.get('tbw_sig'); // use timingSafeEqual in production

6.3 Good to know

  • The guest usually arrives before the webhook does (the webhook is sent within seconds, and is retried if it fails). Show "We received your design choice" and complete the record when the webhook for the same tbw_request arrives.
  • The same address can be opened twice (a reload, a shared link). Key your return page on tbw_request, and use tbw_ts to refuse old links.
  • The signature proves the values came from the widget. It does not prove that the link the guest started from was not edited before Send. Compare tbw_ref and your fields with the booking the guest is signed in to.
  • If you change the signing secret, addresses made before the change no longer verify.

7. Webhooks

A webhook sends every submission to your system as JSON: Zapier, Make, your CRM or your own server.

7.1 Set up

In Connect → Webhook:

  1. Webhook URL: an https:// address reachable from the internet. Not accepted: http://, IP addresses, localhost, .local, .internal.
  2. Signing secret: click Generate, or paste your own (printable characters, no spaces, up to 200). Keep it private. It signs every delivery, the booking return and the redirect.
  3. Send test: sends a sample submission to the address and shows your endpoint's answer. The URL and secret do not need saving first, but the sample's pass-through fields come from your saved list. The sample is a shorter body than a real submission ("test": true, design post_id 0, no files). Up to 10 tests a minute.
  4. Save.

7.2 Events

X-TBW-Event When Body extras
request.created A guest sent a submission.
request.status_changed You changed the submission's status in the dashboard. previous_status
request.edited The guest edited a sent submission (when you allow editing). One delivery per save that changes something. edit: { version, at, changes }

Statuses: new, read, contacted, artwork, awaiting_approval, approved, delivered, archived. new → read happens when you open the submission in the dashboard, and a guest's edit turns read back into new. Neither change is sent as request.status_changed.

Submissions imported from the previous widget do not send webhooks.

7.3 The request

HTTP
POST {your webhook URL}
Content-Type: application/json
User-Agent: TemplatesBooth-Widget/2 (+webhook)
X-TBW-Event: request.created
X-TBW-Delivery: job-48213
X-TBW-Signature: sha256=3f1c…(64 hex)
  • X-TBW-Delivery is the same on every retry of one delivery (job-…; test-… for Send test). Use it to ignore repeats.
  • X-TBW-Signature is present only when the widget has a signing secret.

7.4 Answer quickly, with a 2xx

  • Answer with any 2xx status within 10 seconds. Store the body and do the slow work later.
  • Anything else counts as a failure: a 3xx (redirects are not followed), 4xx, 5xx, a timeout or a network error.
  • After a failure we retry after 1 minute, 10 minutes and 1 hour: four attempts in all. Then we stop.
  • Every attempt shows on the submission's timeline in the dashboard ("Sent to your webhook" or "Webhook delivery failed").
  • Deliveries can arrive more than once and out of order (a status change can overtake a retried request.created). Use X-TBW-Delivery against repeats, and request.updated_at to keep the newest state.

7.5 Verifying X-TBW-Signature

X-TBW-Signature is sha256= followed by the hex HMAC-SHA256 of the raw request body, keyed with your signing secret. Verify the bytes exactly as received, before parsing the JSON: parsing and re-encoding changes them.

PHP

PHP
<?php
$secret = (string) getenv('TBW_SIGNING_SECRET');   // the signing secret from Connect → Webhook
if ($secret === '') { http_response_code(500); exit('no secret configured'); }
$raw    = file_get_contents('php://input');        // the RAW body: verify before json_decode()
$header = $_SERVER['HTTP_X_TBW_SIGNATURE'] ?? '';  // "sha256=<64 hex>"

if (!hash_equals('sha256=' . hash_hmac('sha256', $raw, $secret), $header)) {
    http_response_code(401);
    exit('bad signature');
}

$event    = $_SERVER['HTTP_X_TBW_EVENT'] ?? '';     // request.created | request.status_changed | request.edited
$delivery = $_SERVER['HTTP_X_TBW_DELIVERY'] ?? '';  // the same on every retry
$payload  = json_decode($raw, true);
$fields   = $payload['request']['source']['data'];  // your pass-through fields, {} when none
// Store $payload; skip a $delivery you have already processed.
http_response_code(200);
echo 'ok';

Node.js (18 or later, no dependencies)

Node.js
import { createServer } from 'node:http';
import { createHmac, timingSafeEqual } from 'node:crypto';

const SECRET = process.env.TBW_SIGNING_SECRET;

createServer((req, res) => {
  if (req.method !== 'POST') { res.writeHead(405).end(); return; }
  const chunks = [];
  req.on('data', (c) => chunks.push(c));
  req.on('end', () => {
    const raw = Buffer.concat(chunks); // the raw bytes, not re-serialized JSON
    const expected = Buffer.from('sha256=' + createHmac('sha256', SECRET).update(raw).digest('hex'));
    const got = Buffer.from(String(req.headers['x-tbw-signature'] || ''));
    if (got.length !== expected.length || !timingSafeEqual(got, expected)) {
      res.writeHead(401).end('bad signature');
      return;
    }
    const body = JSON.parse(raw.toString('utf8'));
    // body.request.source.data = your pass-through fields
    // queue body (and req.headers['x-tbw-delivery']) for processing, then answer at once
    res.writeHead(200).end('ok');
  });
}).listen(process.env.PORT || 8787);

With Express, read the body with express.raw({ type: 'application/json' }) on this route, not express.json(). Both examples were tested with valid and invalid signatures.

7.6 Example payload (request.created)

All values below are examples.

JSON
{
  "event": "request.created",
  "request": {
    "id": "r_k3m9q2x7p4ab",
    "widget": "w_yourwidget",
    "status": "new",
    "customer": { "name": "Anna Smith", "email": "anna@example.com", "phone": "+1 555 0100" },
    "event": { "date": "2027-06-12", "type": "", "venue": "" },
    "selections": [
      {
        "post_id": 75106,
        "row_id": 75106000,
        "row_index": 0,
        "layout": "26strip",
        "title": "Rustic Barn Wedding",
        "thumb": "https://templatesbooth.com/wp-content/uploads/2026/01/widget-image-611-1.jpg",
        "permalink": "https://templatesbooth.com/premium/rustic-barn-wedding-photo-booth-template/",
        "wording": { "line1": "Anna & Tom", "line2": "12.06.2027" },
        "design_ref": null,
        "preview": null,
        "design": null,
        "downloads": {
          "edited": false,
          "formats": [
            { "key": "png", "label": "PNG", "url": "https://templatesbooth.com/?tbw_download=r_k3m9q2x7p4ab&selection=0&format=png" },
            { "key": "psd", "label": "PSD", "url": "https://templatesbooth.com/?tbw_download=r_k3m9q2x7p4ab&selection=0&format=psd" },
            { "key": "dslrbooth-windows", "label": "DSLR Booth (Windows)", "url": "https://templatesbooth.com/?tbw_download=r_k3m9q2x7p4ab&selection=0&format=dslrbooth-windows" },
            { "key": "dslrbooth-mac", "label": "DSLR Booth (Mac)", "url": "https://templatesbooth.com/?tbw_download=r_k3m9q2x7p4ab&selection=0&format=dslrbooth-mac" },
            { "key": "lumabooth", "label": "LumaBooth", "url": "https://templatesbooth.com/?tbw_download=r_k3m9q2x7p4ab&selection=0&format=lumabooth" }
          ]
        }
      },
      {
        "post_id": 81234,
        "row_id": 81234002,
        "row_index": 2,
        "layout": "46postcard-p",
        "title": "Golden Florals",
        "thumb": "https://templatesbooth.com/wp-content/uploads/2026/03/widget-image-902-3.jpg",
        "permalink": "https://templatesbooth.com/premium/golden-florals-photo-booth-template/",
        "wording": {},
        "design_ref": null,
        "preview": "https://widget.templatesbooth.com/files/requests/r_k3m9q2x7p4ab/design-2.png?e=1795435200&s=9b1f…",
        "design": {
          "has_delta": true,
          "lines": { "line1": "Anna & Tom", "line2": "June 12, 2027", "line3": "#AnnaAndTom" },
          "text": ["Anna & Tom", "June 12, 2027", "#AnnaAndTom"],
          "preview_key": "requests/r_k3m9q2x7p4ab/design-2.png",
          "preview_url": "https://widget.templatesbooth.com/files/requests/r_k3m9q2x7p4ab/design-2.png?e=1795435200&s=9b1f…",
          "editor_item": 81234,
          "editor_widget": 2,
          "assets": [
            {
              "id": "a1", "name": "2-a1.png", "mime": "image/png", "w": 600, "h": 300, "bytes": 7273,
              "url": "https://widget.templatesbooth.com/files/requests/r_k3m9q2x7p4ab/assets/2-a1.png?e=1795435200&s=c04d…&dl=1"
            }
          ]
        },
        "downloads": {
          "edited": true,
          "formats": [
            { "key": "png", "label": "PNG", "url": "https://templatesbooth.com/?tbw_download=r_k3m9q2x7p4ab&selection=1&format=png" },
            { "key": "psd", "label": "PSD", "url": "https://templatesbooth.com/?tbw_download=r_k3m9q2x7p4ab&selection=1&format=psd" },
            { "key": "dslrbooth-windows", "label": "DSLR Booth (Windows)", "url": "https://templatesbooth.com/?tbw_download=r_k3m9q2x7p4ab&selection=1&format=dslrbooth-windows" },
            { "key": "dslrbooth-mac", "label": "DSLR Booth (Mac)", "url": "https://templatesbooth.com/?tbw_download=r_k3m9q2x7p4ab&selection=1&format=dslrbooth-mac" },
            { "key": "lumabooth", "label": "LumaBooth", "url": "https://templatesbooth.com/?tbw_download=r_k3m9q2x7p4ab&selection=1&format=lumabooth" }
          ]
        }
      }
    ],
    "welcome": null,
    "extras": [
      { "collection_id": 12, "collection": "Backdrops", "item_id": 88, "title": "Gold sequins",
        "image": "https://widget.templatesbooth.com/files/requests/r_k3m9q2x7p4ab/extras/88.jpg?e=1795435200&s=77aa…" }
    ],
    "brief": { "colours": null, "notes": "Can the strip say Mr & Mrs?" },
    "uploads": [],
    "attachments": [
      { "id": "a_q8w2e4r6t1", "name": "logo.pdf", "size": 284113, "at": "2026-10-23T14:02:11.000Z" }
    ],
    "personalise_skipped": false,
    "source": {
      "host": "booking.example.com",
      "page": "https://booking.example.com/events/456",
      "ref": "EV-456",
      "return": "https://booking.example.com/events/456/design",
      "lang": "en",
      "device": "mobile",
      "session": "Yk2pQ9xW1c",
      "mode": "boxed",
      "data": { "event_id": "456", "franchise_id": "12" },
      "turnstile": "verified"
    },
    "timeline": [
      { "type": "created", "at": "2026-10-23T14:02:15.412Z", "actor": "customer", "data": { "selections": 2, "host": "booking.example.com", "files": 1 } }
    ],
    "share_url": "https://widget.templatesbooth.com/your-business/r/r_k3m9q2x7p4ab?t=…",
    "status_at": "2026-10-23T14:02:15.412Z",
    "created_at": "2026-10-23T14:02:15.412Z",
    "updated_at": "2026-10-23T14:02:15.412Z",
    "version": 1,
    "edited_at": "",
    "edit_count": 0,
    "edit_until": "",
    "origin": "widget",
    "notes": "",
    "files_until": "2027-07-12T23:59:59.999Z",
    "legacy_ids": [],
    "notified_at": ""
  },
  "widget": { "pid": "w_yourwidget", "name": "Main widget" },
  "sent_at": "2026-10-23T14:02:16.020Z"
}

7.7 Field reference

Top level

Field Meaning
event Same as the X-TBW-Event header.
request The whole submission as it is now (below).
widget { pid, name } of the widget it came through.
previous_status request.status_changed only: the status before.
edit request.edited only: { version, at, changes: [{ field, label, from, to }] }. field is one of customer.name, customer.email, customer.phone, event.date, notes, design, design.personalised, wording, logos, welcome, extras, files. from / to are display text.
sent_at When this attempt was sent (ISO 8601, UTC).
test true only for Send test.

request

Field Meaning
id Submission ID, r_ + 12 characters. Same as tbw_request in the booking return and the redirect.
widget Widget ID.
status See §7.2.
customer name, email, phone. A field the form does not ask for is "".
event date (YYYY-MM-DD or ""). type and venue are always "": the widget has no such fields (use pass-through fields).
selections[] One per chosen design, in the order chosen.
selections[].post_id Template ID (the design set).
selections[].row_id, row_index, layout Which format of the set: layout is its format key (26strip, 46postcard-p, …).
selections[].title, thumb The design's title and a small picture.
selections[].permalink The template's page on templatesbooth.com, where you download the files. For you only: never show it to the guest.
selections[].wording What the guest typed into the form's text lines, keyed by your line keys (line1…) or by the template's own lines (t1…, then text_lines gives each line's label). {} for a design personalized in the editor.
selections[].text_lines Present when wording is keyed t{i}: [{ i, sample }].
selections[].brief_assets[] Logos added on the wording step, for you to place: { id, name, mime, w, h, bytes, url }.
selections[].design null, or the design the guest personalized in the editor: lines (line1… in the template's reading order), text (the same, empty lines left out), preview_url (a picture of their design), assets[] (images they added, with download url).
selections[].downloads The final design's files, as links for you to click (the same links as the Download buttons in your notification e-mail). edited: true = the files are the guest's personalized version, false = the design as it is in the template. formats[]: { key, label, url } for png, psd, dslrbooth-windows, dslrbooth-mac, lumabooth, always in that order. Opening one asks you to sign in to TemplatesBooth; the editor then makes the file in your browser. A server cannot fetch them (see §8). Only on print designs: an animated design has no downloads key. The file's name ends in ID <post_id> (see §8).
selections[].personalise_skipped, personalise_skip_reason Only when your widget requires personalizing and this design went without it.
welcome null, or the welcome screen chosen: { post_id, row_id, layout, title, thumb, full, is_video, video, matched, permalink }.
extras[] Backdrops, props and other extras chosen: { collection_id, collection, item_id, title, image? }.
brief.notes The guest's notes. brief.colours is always null now.
brief.consent GDPR mode only: { given, text, at }.
uploads[] Files kept from the previous upload field (edits of older submissions): { key, name, size, url }.
attachments[] Files the guest attached: { id, name, size, at }. Names and sizes only: download them in the dashboard.
source.data Your pass-through fields: { name: value }. Always present; {} when none (§4).
source.ref Your tbw_ref ("" when none).
source (other) host and page (the page the widget was on), return (the allowed tbw_return, else ""), lang, device (mobile, tablet, desktop), session, mode (embed, boxed, page, legacy), turnstile (verified when the spam check passed). host, page, ref and data come from the browser: see §12.
timeline[] What happened: { type, at, actor, data }. Types include created, status_changed, edited, webhook, webhook_failed, notified.
share_url The guest's own page for this submission. It contains a private token: do not publish it.
created_at, updated_at, status_at ISO 8601, UTC.
version, edited_at, edit_count, edit_until Editing: version 1 = as sent, +1 per edit. edit_until = the guest's deadline ("" = no editing).
origin widget (sent through this widget) or v1 (imported from the previous widget).
notes Your own notes from the dashboard.
files_until The submission's files are kept at least until this time (see §8).
legacy_ids, notified_at Internal bookkeeping; ignore.

New fields may be added at any time. Ignore fields you do not know, and do not rely on key order.


8. Files and how long links last

  • File addresses in a webhook (preview, preview_url, assets[].url, brief_assets[].url, extras[].image, uploads[].url) are signed links that work for 30 days from the delivery. The e= parameter is the expiry (Unix time). Download what you need when the webhook arrives.
  • Links ending &dl=1 download the file instead of showing it.
  • Attached files (attachments[]) have no link in the webhook: names and sizes only. Download them from the submission in the dashboard.
  • The files themselves are kept at least until files_until: 30 days after the event date, or 365 days after the submission when there is no event date, and never less than 30 days after the last edit. The dashboard always makes fresh links, so it is the way to a file after the 30 days.
  • Links in your notification e-mails last 90 days.
  • The final design (selections[].downloads) is different: those links are for a person, not a server. Show them where you work (your CRM, booking system or portal) and click one when you need the file. It asks you to sign in to your TemplatesBooth account, checks that the submission is yours, and opens the editor, which makes the PNG, PSD or booth-app template in your browser. They do not expire and keep working as long as the submission exists, but only for the member who owns it with an active membership. A server, a script or a curl that opens one gets the sign-in page, never a file. Files are never sent automatically.
  • The downloaded file's name matches the webhook, so you can match a file to its submission: <title> — <guest's name> — <format> — ID <post_id>.png (or .psd, .zip), where <title> and <post_id> are the selection's title and post_id in the webhook, in your widget's language. Example: Modèle de fête verte pour photobooth — Anna Smith — 4x6 Postcard (Landscape) — ID 81234.png. With no guest name, the submission's id (r_…) takes its place; a long title is shortened first, never the ID.
  • The one picture a server can download is design.preview_url (also preview): a proof of the guest's design with their text (a JPEG, up to 1200 px). Use it to show the design. It is not a print file.

9. Page events

The widget tells your page what the guest does. Use page events to update your own interface, for analytics, or to move your booking flow on. They are not signed, so never treat one as proof of a submission: use the webhook or a signed address for that.

Event payload
ready none (with embed.js: detail is { id, widget }; id is the iframe's name, for TBWidget.prefill(fields, id)).
selected { designs: [post IDs], rows: [row IDs] }: the guest's choice changed.
shortlisted { designs: [post IDs] }: the guest's favorites changed.
submitted { id, ref, data, designs, rows }: a submission was sent. id = the submission ID; ref = your tbw_ref or null; data = the pass-through fields sent; designs / rows = post and row IDs per chosen design, in order.
edited { id, ref, data, designs, rows }: the guest saved an edit of a sent submission (also when nothing changed). ref and data are what this page gave the widget; the stored ones never change.

Payloads never contain the guest's name, e-mail or phone, and no links.

submitted and edited fire before the confirmation shows and before any redirect or booking return. A listener runs before the page moves, but the move follows at once: do not start slow work there that must finish.

9.1 With embed.js: DOM events

Each event is a CustomEvent named tbw:<name>, fired on the widget's iframe. It bubbles to document and window.

JavaScript
document.addEventListener('tbw:submitted', function (e) {
  // e.detail = { id: 'tbw_…', widget: 'w_yourwidget', name: 'submitted',
  //   payload: { id: 'r_k3m9q2x7p4ab', ref: 'EV-456', data: { event_id: '456' }, designs: [75106], rows: [75106000] } }
  console.log('Submission', e.detail.payload.id, e.detail.payload.data);
});

9.2 With a plain iframe: postMessage

Without embed.js, listen for messages from the iframe. Every message has v: 2 and a type. Events arrive as { type: 'tbw:event', v: 2, name, payload }.

JavaScript
var WIDGET_ORIGIN = 'https://widget.templatesbooth.com';
window.addEventListener('message', function (e) {
  if (e.origin !== WIDGET_ORIGIN) return;   // always check the origin
  var d = e.data;
  if (!d || d.v !== 2) return;
  if (d.type === 'tbw:ready') { /* the widget is ready: send tbw:prefill now */ }
  if (d.type === 'tbw:event' && d.name === 'submitted') {
    // d.payload = { id: 'r_…', ref: 'EV-456', data: { event_id: '456' }, designs: [75106], rows: [75106000] }
  }
});

The hosted page is a page of its own, not a frame: it sends no events.


10. Recipe: a booking system that frames the widget (Check Cherry and similar)

Goal: the booking system shows the widget inside its own page for one event, knows which event and franchise the choice belongs to, and gets the result back.

This is different from the existing Check Cherry integration, which uses your TemplatesBooth API key to show templates inside Check Cherry (see the helpdesk article "Check Cherry Integration"). This recipe frames your own widget, with your settings, extras and form.

Step 1. In the dashboard (Connect tab)

  • Pass-through fields: event_id, franchise_id.
  • Allowed return websites: the booking system's host, for example booking.example.com. In a plain iframe the widget usually cannot see the page's host, so list it.
  • Webhook: your endpoint's URL, and Generate a signing secret. Store the secret on your server.

Step 2. Build the iframe address per event (server side)

URL
https://widget.templatesbooth.com/w/w_yourwidget/embed/?boxed=1&event_id=456&franchise_id=12&tbw_date=2027-06-12&tbw_return=https%3A%2F%2Fbooking.example.com%2Fevents%2F456%2Fdesign-chosen

(Without listing the names in step 1, tbw_data_event_id=456&tbw_data_franchise_id=12 does the same.)

Step 3. Prefill personal data by postMessage, not in the address

HTML
<iframe id="tbw" src="…the address from step 2…" title="Choose your design"
        allow="clipboard-write; screen-wake-lock" style="width:100%;height:900px;border:0"></iframe>
<script>
  var WIDGET_ORIGIN = 'https://widget.templatesbooth.com';
  var frame = document.getElementById('tbw');
  window.addEventListener('message', function (e) {
    if (e.origin !== WIDGET_ORIGIN || e.source !== frame.contentWindow) return;
    var d = e.data;
    if (!d || d.v !== 2) return;
    if (d.type === 'tbw:ready') {
      frame.contentWindow.postMessage({ type: 'tbw:prefill', v: 2,
        fields: { name: 'Anna Smith', email: 'anna@example.com', phone: '+1 555 0100', lock: true } }, WIDGET_ORIGIN);
    }
    if (d.type === 'tbw:event' && d.name === 'submitted') {
      // d.payload.data = { event_id: '456', franchise_id: '12' }; the widget moves the page to tbw_return next
    }
  });
</script>

Step 4. Receive the result in two places

  • The return page (/events/456/design-chosen?event_id=456&franchise_id=12&tbw_request=…&tbw_ref=&tbw_designs=…&tbw_sig=…&tbw_keys=…&tbw_ts=…&tbw_signature=…): verify tbw_signature (§6.1), check that event_id belongs to the signed-in customer, save tbw_request and tbw_designs on the event, show "Design received".
  • The webhook (§7): verify X-TBW-Signature, find the event by request.source.data.event_id, and store the details: designs, the guest's text, the preview picture and images (download them within 30 days), extras and notes. Later request.edited and request.status_changed deliveries update the same record.
  • The files: store each design's downloads.formats[] links on the event and show them in the booking system as buttons ("PNG", "PSD", "LumaBooth"…). You click one, sign in to TemplatesBooth, and the editor makes the file (named with the selection's title and ID <post_id>, so an upload back into the booking system can be matched). The booking system's server cannot fetch them; for a picture on the event page, download design.preview_url (a proof, not a print file). See §8.

If the booking system cannot host a return page, leave out tbw_return: the guest sees the confirmation in the frame, and the webhook alone carries the result (match it by request.source.data).


11. Recipe: a customer portal

Goal: a signed-in customer chooses their design inside your portal. The form is already filled in, your booking ID travels with the submission, and the portal updates when they send.

HTML
<div id="design-picker"></div>
<p id="design-status"></p>
<script async src="https://widget.templatesbooth.com/embed.js"
        data-tbw="w_yourwidget" data-target="#design-picker" data-prefill="0"></script>
<script>
  // Values from your server for the signed-in customer (printed into the page, never into its URL).
  var booking = { id: 'BK-123', name: 'Anna Smith', email: 'anna@example.com', date: '2027-06-12' };

  document.addEventListener('tbw:ready', function (e) {
    window.TBWidget.prefill({
      name: booking.name, email: booking.email, date: booking.date,
      ref: booking.id,
      data: { booking_id: booking.id },
      lock: true
    }, e.detail.id);
  });

  document.addEventListener('tbw:submitted', function (e) {
    var p = e.detail.payload; // { id: 'r_…', ref: 'BK-123', data: { booking_id: 'BK-123' }, designs: [...], rows: [...] }
    // Update the portal's interface now; your server confirms it from the webhook.
    document.getElementById('design-status').textContent = 'Design received. Thank you!';
  });
</script>
  • data-prefill="0" stops the script reading anything from the portal's own address, so only your values are used. Values you pass with prefill() still work.
  • Leave out return to keep the guest in the portal (they see the confirmation in the widget). Add return: 'https://portal.example.com/bookings/123' to prefill() to move them on, with signed details (§5).
  • Your server matches the webhook by request.source.data.booking_id (or request.source.ref).
  • To show the guest their design, use design.preview_url from the webhook (download it: the link lasts 30 days). The downloads links are for you, in your own back office: never show them to the guest. They lead to your TemplatesBooth sign-in, and the editor makes the file in your browser.
  • In a single-page app, insert the script tag when the page opens and call window.TBWidget.scan() if embed.js is already loaded. Removing the iframe stops it.
  • For a fully white-label portal, connect your own domain to the widget (Embed → Connect your own domain). The embed code then loads from that domain; use that domain as WIDGET_ORIGIN in any postMessage code.

12. Security notes

  • Everything in a link can be changed by the visitor: tbw_ref, pass-through fields, tbw_designs, tbw_return, prefilled data. source.host and source.page are reported by the visitor's browser. Use them to match records, never as proof of who someone is or what they paid for.
  • Verify signatures: X-TBW-Signature on every webhook, tbw_signature on every redirect or return address. Compare in constant time (hash_equals, timingSafeEqual), and trust only the fields named in tbw_keys.
  • Keep the signing secret on your server. Never put it in page code or an app. If it leaks, generate a new one and save (it takes effect at once; update your server at the same time).
  • Page events and postMessage are unsigned. Use them for the interface only.
  • Check event.origin in every message listener, and post to the widget's origin, never '*'.
  • Personal data stays out of URLs (see §3.2). Do not use pass-through fields for names, e-mail addresses or phone numbers: they travel in addresses.
  • Treat share_url and file links as private. They open the guest's submission or files without a login.
  • Return hosts are an allow-list. List only hosts you control.
  • Guests' text and file names are their own input. Escape them before you show them in HTML.

13. Troubleshooting and FAQ

The widget does not appear. The site may remove <script> tags: use the plain iframe. With a Content Security Policy, allow script-src https://widget.templatesbooth.com and frame-src https://widget.templatesbooth.com (or your own widget domain).

On phones, the preview opens inside the widget instead of full screen. Some site styles (transforms, filters, a header with a high z-index) stop a frame from covering the screen. The widget checks this and falls back to showing its sheets inside the frame. Everything still works.

The guest is not sent back to my booking system. Check that the host is in Allowed return websites (in a plain iframe, always list it), that tbw_return is URL-encoded, and that it starts with https:// (an http:// address may not be followed). A host that is not allowed is dropped without an error. In a sandboxed iframe, allow top navigation (see §1.2).

My pass-through fields do not come back. Check the name rules (§4.1): lowercase only, no tbw_ start, not a reserved name. A name in your page's address is only picked up when it is listed in Connect → Pass-through fields (or written tbw_data_<name>). With data-prefill="0", nothing is read from the page's address: use prefill({ data }). Old embed codes cannot pass fields. Use Send test to see the shape.

The signatures are missing. The widget has no signing secret. Set one in Connect → Webhook. On the redirect, also switch on Add submission details to the address.

My signature check fails. For webhooks: you are probably hashing parsed and re-encoded JSON. Hash the raw body. For addresses: sign the decoded values, re-encoded per RFC 3986 (PHP rawurlencode), sorted by name (§6.1). In both cases check for spaces or line breaks around the stored secret, and that the secret was saved (Send test can use an unsaved secret).

My endpoint gets nothing. Use Send test and read the answer. The URL must be https:// and public. Redirects are not followed.

Sending stops working while I test. Each visitor address can send 6 submissions per 10 minutes (and save 12 edits per 10 minutes). Wait, or test from another network.

I received the same delivery twice. Retries and network timeouts can repeat a delivery. Ignore an X-TBW-Delivery you have already processed.

Prefilled values do not show. The field may be switched off in the Form tab. tbw_date must be YYYY-MM-DD. With data-prefill="0", page address values are ignored (use TBWidget.prefill()). In a plain iframe, send tbw:prefill after tbw:ready.

Can I ask for the event type or venue? The form has no such fields. Pass them as pass-through fields (for example event_type, venue), or ask in your own system.

Can I preselect designs or open on an occasion? Yes: tbw_designs=75106,81234 (template IDs, from your webhooks or the widget's Share links) and tbw_category=wedding (see §2).

Can I show only some formats or categories on one page? Use tbw_layout or tbw_category to open on one. For a different set of formats, categories or colors, make a second widget in the dashboard (Duplicate) and embed that one.

Do guests' edits reach my system? Yes, as request.edited, when you allow editing in the Form tab. Guests who were redirected only get the edit link by e-mail.

Is there an API to read submissions? Not yet. Use the webhook, or export CSV from the dashboard's Submissions page (pass-through fields are data_<name> columns). The TemplatesBooth API is for the template catalog, not the widget.

My old embed code uses default_layout / default_type. It still works (see §1.4). Replace it with the new embed code for anything in this guide.

Need help? Contact us.