Skip to content
Open in

Getting Started with Topol Landing Page Editor ​

Embedding the Landing Page Editor takes two steps: create an API token, then add a container element and a short script to your page. A third step, nonce authentication, is what we recommend before real users open the editor. Everything else is optional and can be layered on later.

Using React, Vue, or another framework?

Step 1 applies to every integration. Step 2 does not; follow NPM & Frameworks instead.

Step 1: Create your API token ​

Log into your Topol Account, open the API Tokens tab and click + New API Token. The page that opens creates the token that authorizes the Landing Page Editor in your application.

Newly created API token with its Public API key and Secret key

The token comes with two keys, shown in the API Keys tab: the Public API key goes into the editor configuration in your page, and the Secret key authorizes server-side calls to the Topol API and must never be exposed in client-side code.

With the token created, switch to the Configuration tab and add every domain where the editor will run to the Allowed domains list.

Allowed domains list in the token's Configuration tab

WARNING

The token only works on the domains listed in its configuration. Loading the editor from an unlisted domain fails authorization.

Step 2: Add the editor to your application ​

With the API key ready, the editor goes into your page in two pieces: a container element and a script that configures and starts it. (In a framework app, the NPM packages replace this setup.)

The setup mirrors the Topol Email Editor: the LandingPageEditor() factory takes the options under config, callbacks are passed as top-level properties next to it, and render() mounts the editor into the container.

Let your coding agent do it recommended ​

The fastest way to integrate is to hand the job to your AI coding agent. The official topol-editors-integration skill teaches it the current API, so it writes the integration from the source of truth instead of from older examples it may have seen.

1. Install the skills in the project that will embed the editor:

claude
/plugin marketplace add TOPOL-io/skills
/plugin install topol-editors@topol
bash
npx skills@latest add TOPOL-io/skills

The skills are plain markdown in TOPOL-io/skills, so you can read what the agent will do before it runs, or point any other agent at the files directly.

2. Ask for the integration, in your own words:

text
Add a Topol landing page editor screen to this app

The agent adds the editor through the NPM package that fits your framework, or with the script tag below when the page has no build step. It mounts the editor in a sized container, wires onSave and onEditorError, reads the API key from your environment configuration, and runs your type-check and build.

3. Finish what only you can decide: put the Public API key from Step 1 where the agent tells you, decide where saved pages are stored, and open the page once to see the editor load. Then go on to Step 3.

Add it by hand ​

First, add this HTML where you want the editor to appear. The container needs an explicit width and height, otherwise the editor has no space to render:

html
<!-- Container where the Landing Page Editor will be rendered -->
<div id="landing-page-editor" style="width: 100%; height: 100vh;"></div>

Next, load the editor script and initialize it. The editor runs inside its own iframe, isolated from your application's styling and scripts:

html
<!-- Load the Topol Landing Page Editor script -->
<script
  src="https://v1.page-assets.topol.io/loader/build.js"
  type="text/javascript"
></script>

<!-- Configure and initialize the Landing Page Editor -->
<script>
  const TOPOL_OPTIONS = {
    authorize: {
      apiKey: "YOUR_API_KEY", // Replace with your actual API key from step 1
      entityId: "user-123", // Any unique ID for your user
    },
  };

  // Initialize the Landing Page Editor.
  // Callbacks are top-level properties, passed next to `config`.
  const LPE = LandingPageEditor({
    config: TOPOL_OPTIONS,
    onSave: function ({ json, html }) {
      // Runs when the user saves.
      // `json` is the template definition, `html` is the rendered page.
      console.log("Saved landing page:", json, html);
    },
    onInit: function () {
      // Runs once the editor is initialized and ready
      console.log("Landing Page Editor is ready");
    },
  });

  // Render the editor into the container
  LPE.render("#landing-page-editor");

  // Optional: Load a template into the editor on start
  // Replace the URL with your own template, or remove this to start with an empty page
  fetch("https://example.com/your-template.json")
    .then((response) => response.json())
    .then((template) => {
      LPE.load(template);
    })
    .catch((error) => {
      console.error("Failed to load template:", error);
    });
</script>

Important notes:

  • The apiKey is the Public API key from Step 1.
  • The entityId is a unique string or number that identifies the current user. It counts as one unique user for monthly billing and determines where that user's images are stored. Typically, one entityId corresponds to one client of your app, CRM, or platform.
  • The onSave({ json, html }) callback receives the page JSON definition and the rendered HTML on every save. Store both: the JSON to load back into the editor later, the HTML to publish the page. Every callback gets a single payload object like this one, see the Callbacks Reference.
  • onInit() fires once the editor is initialized and ready, which makes it the place to hide loaders or start tracking. A separate onLoaded() callback fires after a template passed to load() has been applied.

Step 3: Authorize with nonces recommended ​

The API key from Step 1 is enough to get the editor on screen, but it sits in your page source and never expires. For real users we recommend nonce authentication: your backend signs a short-lived nonce for each signed-in user with the Secret key, and the editor runs on that. A nonce is bound to one user, expires within the hour, and stops working the moment you rotate the Secret key.

It takes two additions and changes nothing else in your integration:

  1. A backend endpoint that signs a nonce for the signed-in user with the Secret key. It makes no call to Topol.
  2. A getNonce callback next to config that fetches the nonce from that endpoint.
js
import { createHash, createHmac } from "node:crypto";

function signTopolNonce(entityId) {
  const key = createHash("sha256").update(process.env.TOPOL_SECRET_KEY).digest("hex");
  const payload = {
    credPk: process.env.TOPOL_API_KEY, // the Public API key from Step 1
    entityId: String(entityId), // same value as authorize.entityId
    exp: Math.floor(Date.now() / 1000) + 3600, // one hour at most
  };
  const body = Buffer.from(JSON.stringify(payload)).toString("base64url");
  const signature = createHmac("sha256", key).update(body).digest("base64url");
  return `nc_${body}.${signature}`;
}

// Only for signed-in users
app.post("/api/topol/nonce", requireLogin, (req, res) => {
  res.json({ nonce: signTopolNonce(req.user.id) });
});
js
const LPE = LandingPageEditor({
  config: TOPOL_OPTIONS,
  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;
  },
  // ...your other callbacks
});

The Secret key stays on your server: never send it to the browser or sign nonces there. A Secret key that doesn't start with sk_ (issued before the prefix existed) needs sk_ put in front of it before hashing.

Nonce Authentication is the full guide: the nonce format, PHP signing code, the NPM package variants, and how refresh and errors behave. If you integrated with a coding agent, ask it to "add Topol nonce authentication" and it writes both pieces.

Loading and saving landing pages ​

Loading a page programmatically means passing its JSON definition into the load() method:

javascript
const template = {
  // Your landing page JSON structure
};

LPE.load(template);

A save can also be triggered from your application code:

javascript
LPE.save();

Calling save() renders the page server-side and then triggers the onSave({ json, html }) callback. If the rendering request fails, the editor shows an error notification and onSave is not called.

Next steps ​

With the editor embedded, the integration grows through options:

INFO

Running into trouble while implementing the Landing Page Editor? Contact our support team here and we'll help you get it working.