# Quick start

> Create an editor, get a Test key, open a session from your server and mount the editor on your page.

## 1. Create your editor

[Sign up](/signup), add your details and name your editor. Then pick a plan: every plan starts with a 15-day free trial (Checkout asks for a card and charges nothing until it ends). Every editor has a **Test** and a **Live** [environment](/docs/environments), each with its own keys and data. Test always allows `localhost`, and sessions there are free.

<Screenshot src="/docs/1-dashboard-home.webp" original="/docs/raw/1-dashboard-home.png" alt="Your editor's Home in the dashboard, with the setup checklist that tracks each step from embedding to going live" />

Using an AI coding agent? Connect it to Muzekit's [MCP server](/docs/mcp#set-up-the-editor-in-your-app) and ask it to set up the editor in your app: it writes steps 3 and 4 for your stack.

## 2. Get a Test key

Your editor comes with a Test key: open **API keys** in the dashboard to copy it. It starts with `mk_test_`. Keep it on your server: it is a secret.

<Screenshot src="/docs/1-embed-code.webp" original="/docs/raw/1-embed-code.png" alt="The Embed code page: your Test key as an env line for your server, then the session route for your stack (HTML, React, Next.js or Node and Express)" />

## 3. Open a session from your server

```bash
curl https://api.muzekit.com/v1/sessions \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "user": { "id": "user_42", "name": "Ada" }, "mode": "design" }'
```

The response carries a single-use `client_secret` that is valid for 10 minutes, and the `editor_url`:

```json
{
  "object": "session",
  "id": "ses_…",
  "client_secret": "ses_…_secret_…",
  "editor_url": "https://editor.muzekit.com/session",
  "expires_at": "2026-10-16T21:45:00.000Z",
  "mode": "design",
  "user": { "object": "user", "id": "usr_…", "external_id": "user_42" }
}
```

Your user is created on the first session and updated on later ones, matched by your own `user.id`.

## 4. Mount the editor

Add the browser SDK to your page and give it a way to get a client secret from your server. The SDK loads the editor in an iframe and hands it the secret by message, to the editor's own origin only, so the secret never appears in a URL.

```html
<div id="editor" style="height: 720px"></div>
<script src="https://muzekit.com/sdk/v1.js"></script>
<script>
  const editor = Muzekit.mount("#editor", {
    // Called each time the editor opens; return a fresh client secret.
    fetchClientSecret: () =>
      fetch("/api/muzekit-session", { method: "POST" })
        .then((r) => r.json())
        .then((s) => s.client_secret),
    on: {
      ready: () => console.log("Editor ready"),
      save: (e) => console.log("Saved", e.template, e.revision),
      error: (e) => console.error(e.code, e.message),
    },
  });
</script>
```

<Screenshot src="/docs/1-embed-mount.webp" original="/docs/raw/1-embed-mount.png" alt="Embed code, steps 3 and 4: the SDK snippet that mounts the editor, and the check that turns green when your page first opens the editor" />

Pass `clientSecret` instead of `fetchClientSecret` when you already have one; it works once, since secrets are single use.

| Event | When | Detail |
| --- | --- | --- |
| `ready` | The editor is open | `mode`, `template` |
| `save` | A save finished | `template` (`tpl_…`), `revision`, `created` (true when the save made a new template) |
| `error` | The editor could not open, or a session refresh failed | `code`, `message` |

`editor.save()` asks the editor to save now, and `editor.destroy()` removes it from the page.

With a Test key, `localhost` and `127.0.0.1` on any port are always allowed, and those sessions are free. To go live, make a Live key (`mk_live_`), add your app's domain to Live under **Allowed domains** (the editor opens only inside pages on those exact origins) and use **Copy to Live** to move your templates, look and features.

<Screenshot src="/docs/1-environments-copy-to-live.webp" original="/docs/raw/1-environments-copy-to-live-annotated.png" alt="Environments in the dashboard: Test and Live side by side, and Copy to Live listing new, changed and conflicting templates before they move" />

## 5. Read what your users make

Templates your users save belong to them and are listed with `GET /v1/templates?user=usr_…`. Read a template's document with [Get a document](/docs/api-reference/templates-document-get).
