HelixML

Embed HelixOS in your web application

Show a HelixOS module page inside your own web application, signed in as the person using your app. Covers sign-in, the server-side API, the iframe, a complete working example, and how data moves between your app and the module.

You can show a HelixOS module page, for example a search page with a live agent desktop, inside your own web application. The person using your app sees it as part of your app, and HelixOS treats them as themselves.

This page is written for two readers: a developer, and the coding agent (Claude Code or similar) that the developer asks to do the work. Every step says exactly what to call and what comes back. The worked example near the end is complete and runs as-is.

How it works

Three parties are involved: the person's browser, your server, and HelixOS. The module page itself is served by the module, inside HelixOS.

  1. Once: an owner of your HelixOS organization registers your application under Settings → Embedding. HelixOS gives them a secret for your server.
  2. Each page view: your server calls POST /api/embed/sessions with that secret, the signed-in person's email, the module and the page within it. HelixOS returns a one-time URL.
  3. Your page puts that URL in an <iframe>.
  4. The iframe exchanges the one-time URL for a session that lasts 8 hours, kept only in that browser tab, and shows the module page.
Browser                       Your server                          HelixOS
───────                       ───────────                          ───────
GET /jobs/42  ─────────────▶
                              POST /api/embed/sessions ─────────▶  checks secret, person, module
                              ◀──────── { "url": ".../embed?c=…#start=…" }
◀──── page with <iframe src=url>
iframe loads url  ────────────────────────────────────────────────▶ start token → session (8h)
                                                                    module page, as that person

No cookie is involved, so third-party cookie blocking in Safari, Firefox and Chrome does not affect it.

Who the person is

HelixOS needs to know which of its users is looking at the page. It matches the person by verified email:

  • You send the email of the person signed in to your app. It must be an address your own sign-in has verified, such as their work Microsoft or Google account.
  • HelixOS looks that email up among its own verified sign-ins. A person becomes known to HelixOS the first time they sign in to it with that email and their identity provider confirms the address. They must also be a member of your HelixOS organization.
  • Nobody creates accounts, and there is no admin endpoint. If HelixOS doesn't know the person yet, the call fails with person_not_found and gives you a sign-in link. Show it to them once (see First visit).

The secret is powerful: it lets your server open module pages as any verified member of your organization. Treat it like a password.

  • Keep it on your server. Never send it to a browser.
  • Store it in your secrets manager or server environment.
  • If it leaks, revoke the application in Settings → Embedding. Its secret stops working at once, and so does every view it has open.

Step 1: Register your application

An owner of your HelixOS organization:

  1. Opens Settings → Embedding and clicks Add an application.
  2. Enters a name and Where it runs: every origin your app is served from, separated by spaces, for example https://app.example.com https://staging.example.com.
    • An origin is the scheme and host only: no path and no wildcards.
    • Each must use https. Plain http is accepted for localhost and 127.0.0.1 only, for development.
  3. Copies the secret (it starts with hoec_) into your server's configuration, for example as HELIXOS_EMBED_SECRET. It is shown once.

Only the origins listed here can frame HelixOS for this application. The browser enforces this with Content-Security-Policy: frame-ancestors.

Step 2: Create a session on your server

Call this from your server, on every page view that shows the module:

http
POST https://<your HelixOS>/api/embed/sessions
Authorization: Bearer hoec_…
Content-Type: application/json
 
{
  "email": "jane@yourcompany.com",
  "module": "candidate-search",
  "path": "/job?id=42"
}
FieldRequiredMeaning
emailyesThe signed-in person's verified email. Case does not matter.
moduleyesThe module's key, as shown on its page in HelixOS. It must be installed in your organization.
pathnoThe page inside the module, starting with /. Defaults to /.

A successful response is 201 Created:

json
{
  "session_id": "ems_…",
  "url": "https://<your HelixOS>/embed?c=emc_…#start=hoet_…",
  "expires_at": "2026-12-02T14:15:00Z"
}

Use url straight away. It works once, and only for 2 minutes: create a new one for every page view, and never cache it.

Errors use this shape: {"error": "human-readable message", "code": "machine_code"}.

StatuscodeMeaning and what to do
400invalid_requestemail or module missing, or path doesn't start with /. Fix the request.
401unauthenticatedThe secret is wrong, or the application was revoked.
404module_not_installedNo module with that key is installed in your organization.
404person_not_foundHelixOS has no verified sign-in for this email in your organization. The response also has sign_in_url. See First visit.

Step 3: Show it in your page

Put the URL in an iframe. Give it a real height; the module fills whatever space you give it.

html
<iframe
  src="https://<your HelixOS>/embed?c=emc_…#start=hoet_…"
  allow="clipboard-read; clipboard-write; fullscreen"
  title="HelixOS"
  style="border:0;width:100%;height:80vh"
></iframe>

The embedded page tells your page what is happening with postMessage. Always check event.origin against your HelixOS origin before trusting a message.

event.data.typeWhen
helixos.embed.readyThe module page is open.
helixos.embed.expiredThe session ended (after 8 hours, or the application was revoked). Reload your page to get a fresh one.
helixos.embed.errorIt could not open. event.data.detail says why.

The messages carry no secrets.

First visit: the person has never used HelixOS

The first time someone uses the embedded page, HelixOS may not know them yet, and you get 404 person_not_found. Show them a link instead of the iframe:

  1. Tell them to sign in to HelixOS once, with the same email they use in your app.
  2. Link to sign_in_url from the error, opening in a new tab.
  3. Ask them to come back and reload.

After that one sign-in, HelixOS knows them and your page works every time. If your organization lets people join by email domain, signing in also makes them a member.

Worked example

A complete application in one file: Node 18 or later, no dependencies. It serves /jobs/<id> and shows the module's /job?id=<id> page, with the first-visit case and expiry handled. This exact file was tested against a running HelixOS, framed from a different site.

js
// Example: a web application that embeds a HelixOS module page.
// Node 18+, no dependencies. Run with:
//   HELIXOS_URL=https://recruit.helix.ml HELIXOS_EMBED_SECRET=hoec_... \
//   HELIXOS_MODULE=candidate-search node server.mjs
import http from "node:http";
 
const HELIXOS_URL = process.env.HELIXOS_URL;           // where your HelixOS is
const SECRET = process.env.HELIXOS_EMBED_SECRET;      // from Settings → Embedding; server-side only
const MODULE = process.env.HELIXOS_MODULE;            // the module's key
const PORT = Number(process.env.PORT || 8099);
 
// Your application's own sign-in. This example pretends everyone is one
// person; use your real session here. HelixOS trusts the email you send, so
// it must be the signed-in person's VERIFIED email from your own login.
function currentUser(req) {
  return { email: process.env.DEMO_USER_EMAIL || "person@example.com" };
}
 
// Ask HelixOS for a one-time URL that opens `path` in the module as `email`.
async function createEmbedSession(email, path) {
  const res = await fetch(`${HELIXOS_URL}/api/embed/sessions`, {
    method: "POST",
    headers: { Authorization: `Bearer ${SECRET}`, "Content-Type": "application/json" },
    body: JSON.stringify({ email, module: MODULE, path }),
  });
  const body = await res.json();
  if (!res.ok) return { error: body };
  return { url: body.url };
}
 
const escape = (s) => String(s).replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
 
function page(title, inner) {
  return `<!doctype html><html><head><meta charset="utf-8"><title>${escape(title)}</title>
<style>body{margin:0;font:15px system-ui}header{padding:12px 20px;border-bottom:1px solid #ddd}
iframe{border:0;width:100%;height:calc(100vh - 50px);display:block}.note{padding:20px}</style></head>
<body><header><strong>Acme Recruit</strong> · ${escape(title)}</header>${inner}</body></html>`;
}
 
http.createServer(async (req, res) => {
  const url = new URL(req.url, `http://localhost:${PORT}`);
  const match = url.pathname.match(/^\/jobs\/([\w-]+)$/);
  if (!match) {
    res.writeHead(302, { Location: "/jobs/42" });
    return res.end();
  }
  const user = currentUser(req);
  // A fresh session on every page view: each start URL works once, for two minutes.
  const session = await createEmbedSession(user.email, `/job?id=${match[1]}`);
  res.setHeader("Content-Type", "text/html; charset=utf-8");
  res.setHeader("Cache-Control", "no-store");
 
  if (session.error?.code === "person_not_found") {
    // First visit: this person has never signed in to HelixOS. Send them once.
    return res.end(page("LinkedIn search", `<div class="note">
      <p>To run searches here, sign in to HelixOS once with ${escape(user.email)}.</p>
      <p><a href="${escape(session.error.sign_in_url)}" target="_blank" rel="noopener">Sign in to HelixOS</a>,
      then <a href="">reload this page</a>.</p></div>`));
  }
  if (session.error) {
    return res.end(page("LinkedIn search", `<div class="note">HelixOS said: ${escape(session.error.error)}</div>`));
  }
 
  res.end(page("LinkedIn search", `
    <iframe src="${escape(session.url)}" allow="clipboard-read; clipboard-write; fullscreen" title="HelixOS"></iframe>
    <script>
      // The embedded view tells you when it has expired; open a fresh one.
      const helixos = new URL(${JSON.stringify(HELIXOS_URL)}).origin;
      window.addEventListener("message", (ev) => {
        if (ev.origin !== helixos) return;
        if (ev.data && ev.data.type === "helixos.embed.expired") location.reload();
      });
    </script>`));
}).listen(PORT, () => console.log(`Acme Recruit on http://127.0.0.1:${PORT}`));

To adapt it to your framework, keep three things:

  • Create the session on the server, per request. In Next.js, that's a server component or route handler; in Express, the route handler.
  • Take the email from your own verified session, never from the browser or a query string. Otherwise anyone could open HelixOS as anyone.
  • Never cache the page that contains the start URL.

Moving data between your app and HelixOS

The embedded page is for what a person does in the browser: watching an agent work, signing in to a site inside the agent's desktop, reviewing results. Moving data between your app and HelixOS is a separate job, done by the module, not by HelixOS:

  • A module keeps its own data, in its own database, and is code your organization controls. You can fork a published module, or build one: see Build a HelixOS module.
  • HelixOS runs the module's agents and shows its pages. It does not copy data between a module and other systems.

So the module gets a small API of its own for your app's server. The design we recommend:

DirectionHowWhy
Your app → moduleYour server calls the module's API, for example POST /api/partner/jobs, with a secret shared between your server and the module.Creating work needs no person, so it's a plain server-to-server call.
Module → your app, "something changed"The module POSTs a small webhook to your server, signed with HMAC-SHA256.You hear about results as they arrive, without polling.
Module → your app, the dataYour server reads it from the module's API, for example GET /api/partner/candidates?job_id=42&since=<cursor>.This is the source of truth. A missed or repeated webhook can never lose or duplicate data, because the next read catches up from the cursor.

Use both outbound mechanisms together. A webhook that carries all the data loses data when a delivery fails. Polling alone works, but with more delay.

What to build in the module

Tell your coding agent to add these to the module, in its existing API code:

  1. A shared secret. Read it from an environment variable such as PARTNER_API_SECRET, set as a secret on the module's Helix project with the prod scope.
    • If the variable is empty, don't register the partner routes at all.
    • Compare the secret in constant time.
  2. Partner routes, each checking Authorization: Bearer <secret>:
    • write routes for the things your app creates (for example jobs);
    • read routes that accept since, return records in a stable order, and include a next_cursor.
    • Scope every query to your organization, the same way the module's own pages do.
  3. A webhook to PARTNER_WEBHOOK_URL when something changes, for example when an agent run finishes. HelixOS sends the module a run.completed event; send yours after handling it.
    • Body: {"type": "…", "id": "<unique event id>", …}.
    • Header: X-Signature: sha256=<hex HMAC of the raw body>, keyed with the shared secret.
    • Send it in the background with a short timeout, so a slow app never blocks the module.
  4. Tests for each route: wrong or missing secret returns 401, and data from another organization is never returned.

What to build in your app

Verify the webhook before trusting it, then fetch the data:

js
import crypto from "node:crypto";
 
// rawBody: the request body exactly as received, before JSON parsing.
function verifyWebhook(rawBody, signatureHeader, secret) {
  const expected = "sha256=" + crypto.createHmac("sha256", secret).update(rawBody).digest("hex");
  const a = Buffer.from(expected);
  const b = Buffer.from(signatureHeader || "");
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

Then, on each webhook (or on a timer as a fallback):

  1. Read the module's partner API from your stored cursor.
  2. Upsert what comes back, keyed on a stable identifier, such as a profile URL or the module's record id.
  3. Store the new cursor.

Because the read is idempotent, it's safe to run it whenever you like.

What an embedded view can do

An embedded view is deliberately narrow. Its session:

  • opens one module, the one you named, as one person;
  • can't open other modules, Dev preview builds, or any other part of HelixOS;
  • stops working when the person leaves your organization, when the application is revoked, or after 8 hours.

Inside the module the person can do whatever the module lets them do, including watching and driving an agent's desktop. Modules decide their own permissions as usual.

CredentialPrefixLivesWhere
Application secrethoec_Until revokedYour server only
Start tokenhoet_2 minutes, one useThe iframe URL, after # so it never reaches server logs
Session tokenhoes_8 hoursThe browser tab's session storage

Troubleshooting

SymptomCause and fix
The iframe is blank, and the browser console says "violates the following Content Security Policy directive: frame-ancestors"Your page's origin isn't in the application's Where it runs list. Add it exactly: scheme, host and port.
"This link has expired or was already used."The start URL was used twice, or more than 2 minutes after it was created. Create a new session on every page view; never cache the page.
401 unauthenticated from /api/embed/sessionsWrong secret, or the application was revoked. Check HELIXOS_EMBED_SECRET on your server.
404 person_not_found for someone who uses HelixOSThey signed in to HelixOS with a different email, or their identity provider hasn't verified it, or they aren't a member of this organization.
404 module_not_installedInstall the module in your organization from Modules in HelixOS, and check the key.
The module says "This view has expired"The 8-hour session ended. Listen for helixos.embed.expired and reload your page.