Skip to content
Open in

Migrating to Email Editor v4 ​

Email Editor v4 is a new major version of the editor. It shares its interface with the Landing Page Editor, works on tablets and phones, and gives your code an editor instance with promise-based methods instead of a global plugin object.

Your templates keep working. v4 opens the same template JSON as v3, so the upgrade only touches the code that embeds the editor, plus a few endpoints if you host your own API.

What's new in v4 ​

Nonce authentication recommended ​

The way we recommend to authorize the editor from v4 on. Your backend signs a short-lived nonce for each signed-in user with your Secret key, and the editor runs on that instead of on the API key in your page. You can add it during the upgrade or any time later. See Nonce authentication below.

One interface with the Landing Page Editor ​

Both editors now look and behave the same, so your users learn one tool. The interface also adapts to touch screens and narrow windows, which makes the editor usable on tablets and phones.

An editor instance with promises ​

Creating the editor returns an instance, and every method on it returns a Promise: await editor.load(template), await editor.save(). One page can run several editors side by side.

Saves your backend confirms ​

When onSave returns a Promise, the editor shows the saving state until your backend answers, reports a failed save to the user, and marks changes as saved only after the save succeeds. Only one save runs at a time.

Saved blocks become sections ​

Saved blocks and premade blocks are called sections, in the interface and in the API: savedSections, premadeSections, onSavedSectionSave and so on.

New options ​

Features now on by default ​

Your users see these right after the upgrade

Four features that were off by default in v3 are on in v4. If you didn't set these options before, the editor looks different after the upgrade. Set an option to false to keep the v3 behaviour.

FeatureWhat your users getTo turn it off
Smart merge tagsInserted merge tags show as boxes; clicking one swaps it for another merge tagsmartMergeTags: { enabled: false }
Mobile-first editingA mobile and desktop canvas switch, and per-device visibility on blocks and structuresmobileFirstEnabled: false
Premade templatesA picker to start from a designed template instead of an empty canvaspremadeTemplates: false
Control panel toggleA button on the edge of the control panel that shows and hides ithideSelectionPanelExpand: true

The control panel also starts hidden when the editor is narrower than 1024 px.

Choose your upgrade path ​

How you upgrade depends on how you embed the editor today.

Not sure which one you have? Search your code for TopolPlugin.init or email-assets.topol.io. If you find either outside node_modules, take the script tag path.

Both paths make the same kinds of changes to your code:

  • Create an editor instance and render it into your container.
  • Rewrite callbacks to receive one object, and rename onError to onEditorError and onClose to onEditorClose.
  • Rename saved and premade blocks to sections.
  • Rename authorize.userId to authorize.entityId.
  • Rename the control panel options and method (hideControlPanel, showControlPanelExpand, toggleControlPanel()) to their selection panel names, and a handful of other options whose spelling was fixed.
  • Make sure every entityId is a non-negative integer or uses only letters, numbers, _ and -.

v4 accepts only the new names. An option or callback left under its v3 name is ignored without a warning, so go through the rename tables of your path rather than waiting for an error.

Let an AI agent do the upgrade

TOPOL-io/skills has a skill for each path: topol-editors-upgrade-email-v4 for the script tag and topol-editors-upgrade-v1 for the NPM packages. They install as a Claude Code plugin (/plugin marketplace add TOPOL-io/skills) or into any agent with npx skills@latest add TOPOL-io/skills.

Backend and security policy ​

These changes are the same on both paths. Skip the first part if you don't host any api.* endpoints yourself.

Your API endpoints ​

  • CORS: allow requests from https://v4.email-assets.topol.io instead of the v3 origin.

  • Autosaves: one AUTOSAVES URL now handles all three calls:

    Callv3v4
    List autosavesGET AUTOSAVESGET AUTOSAVES
    Create an autosavePOST AUTOSAVEPOST AUTOSAVES
    Read one autosaveGET GET_AUTOSAVE/{key}GET AUTOSAVES/{key}

    Request parameters and bodies are unchanged. Before the first autosave of a session, v4 also lists the existing autosaves, reads the newest one, and may create one extra autosave for the initial state.

  • Saved sections: SAVED_SECTIONS keeps its URLs and payloads. Listing requests can now include type=folder to fetch only folders; return just the folders in that case.

  • Comments: CONVERSATIONS and COMMENTS are unchanged.

Your page's security policy ​

If your page sets a Content Security Policy or Permissions-Policy, replace v3.email-assets.topol.io with v4.email-assets.topol.io in script-src, frame-src and any feature allowlists. The editor iframe asks for fullscreen, clipboard-read, clipboard-write and local-network-access. The other domains in Allowed domains, such as api.topol.io, stay the same.

Nonce authentication ​

Recommended for every integration

Nonce authentication is the setup we recommend from v4 on. The upgrade itself works without it, because the API key in authorize keeps authorizing the editor on its own, so you can add it during the upgrade or right after.

With the API key alone, the editor runs on a key that sits in your page source and never expires. With nonce authentication, it runs on a nonce that your backend issues to a signed-in user:

  • Short-lived. A nonce is valid for at most an hour. The editor asks for a new one before it expires, so users aren't interrupted.
  • Bound to one user. Your backend signs the entityId into the nonce, so it can't be changed in the browser.
  • Secret key stays on your server. Your backend signs nonces itself, with no call to Topol.
  • Revocable at once. Rotating the Secret key invalidates every nonce signed with it, however long it still has to live.

You add two things, and they work the same on both upgrade paths:

  1. A backend endpoint that signs a nonce with the Secret key for the signed-in user.
  2. A getNonce callback that fetches it from that endpoint.
js
async getNonce() {
  const response = await fetch("/api/topol/nonce", { method: "POST" });
  if (!response.ok) throw new Error("Could not get a Topol nonce");
  return (await response.json()).nonce;
},

Nonce Authentication has the signing code for Node.js and PHP and shows where getNonce goes for the script tag and each NPM package. The Landing Page Editor supports nonces the same way; see its Nonce Authentication guide.

INFO

Running into trouble while upgrading? Contact our support team here and we'll help you get it working.