---
title: "Migrating to v4"
description: "Upgrade to Email Editor v4 — what's new, which upgrade path fits your integration (script tag or NPM packages), the backend changes both paths share, and the recommended nonce authentication."
url: https://docs.topol.io/email-editor/guide/v4-migration.html
---

# 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](#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](https://docs.topol.io/email-editor/guide/callbacks.html#one-save-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

-   [`clickTrackingOptOut`](https://docs.topol.io/email-editor/reference/topol-options.html#clicktrackingoptout) excludes single links from click tracking, for example unsubscribe links.
-   [List comparators](https://docs.topol.io/email-editor/guide/conditional-content.html#list-comparators) match a merge tag against a list of values with `is one of` and `is not one of`.
-   `emailServiceProvider: "jinja"` exports [conditional content](https://docs.topol.io/email-editor/guide/conditional-content.html#conditional-syntax) in Jinja syntax.
-   [`saveAndCloseButton`](https://docs.topol.io/email-editor/guide/top-bar.html) shows Save & Close as its own button.
-   [`disableShortcuts`](https://docs.topol.io/email-editor/reference/topol-options.html#disableshortcuts) turns off all or some of the editor's keyboard shortcuts, such as Ctrl/Cmd+S.

### 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.

| Feature | What your users get | To turn it off |
| --- | --- | --- |
| [Smart merge tags](https://docs.topol.io/email-editor/guide/merge-tags.html#smart-merge-tags) | Inserted merge tags show as boxes; clicking one swaps it for another merge tag | `smartMergeTags: { enabled: false }` |
| [Mobile-first editing](https://docs.topol.io/email-editor/guide/mobile-first.html) | A mobile and desktop canvas switch, and per-device visibility on blocks and structures | `mobileFirstEnabled: false` |
| [Premade templates](https://docs.topol.io/email-editor/guide/premade-templates-in-editor.html) | A picker to start from a designed template instead of an empty canvas | `premadeTemplates: false` |
| [Control panel toggle](https://docs.topol.io/email-editor/guide/control-panel-settings.html#control-panel-visibility) | A button on the edge of the control panel that shows and hides it | `hideSelectionPanelExpand: 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.

[Script tag**You add HTML and JavaScript to your page**Your page loads `v3.email-assets.topol.io/loader/build.js` and calls `TopolPlugin.init()`.Script tag: v3 to v4 →](https://docs.topol.io/email-editor/guide/v3-to-v4-migration)[NPM packages**You install the editor from npm**Your `package.json` has `@topol.io/editor`, `@topol.io/editor-react`, `@topol.io/editor-vue` or `@topol.io/editor-svelte`.NPM packages: upgrading to v1 →](https://docs.topol.io/email-editor/guide/npm-v1-migration)

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](https://github.com/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:

    | Call | v3  | v4  |
    | --- | --- | --- |
    | List autosaves | `GET AUTOSAVES` | `GET AUTOSAVES` |
    | Create an autosave | `POST AUTOSAVE` | `POST AUTOSAVES` |
    | Read one autosave | `GET 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](https://docs.topol.io/email-editor/guide/allowed-domains.html), 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](https://docs.topol.io/email-editor/guide/how-to-get-secret-key.html) 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](https://docs.topol.io/email-editor/guide/nonce-authentication.html) 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](https://docs.topol.io/landing-page-editor/guide/nonce-authentication.html) guide.

> **INFO**
>
> Running into trouble while upgrading? **Contact our support team** [here](https://topol.io/contact) and we'll help you get it working.
