Sessions
How your server opens the editor for one of your users, and how the editor proves where it is loaded.
A session is the only way into the editor. Your server creates it with a secret key, so your users never hold a key and never see a Muzekit login.
The flow
- Your serverholds the secret key
Muzekit APIapi.muzekit.com
- Your pagethe SDK and the editor
- 1Your server
Muzekit API
POST /v1/sessionsthe user, the mode, a template - 2
Muzekit APIYour server
client_secretsingle use, 10 minutes - 3Your serverYour pagehands the secret to the page
- 4Your page
Muzekit API
Muzekit.mountexchanges itchecked against your allowed domains - 5
Muzekit APIYour page
editor opens for that usertoken refreshes while it's open
- Your server calls
POST /v1/sessionswith the user, the mode and, optionally, a template to open. - Muzekit returns a
client_secret: single use, valid for 10 minutes. - Your page mounts the editor with that secret. The editor exchanges it for a session token that lasts 15 minutes and refreshes while the editor is open, up to 12 hours.
- The exchange checks the page that embeds the editor against your allowed domains. Any other page is refused.
Create sessions on your server. If a key leaks, revoke it in the dashboard: it stops working at once.
Create a session
curl https://api.muzekit.com/v1/sessions \
-H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 5b0f6a2e-…" \
-d '{
"user": { "id": "user_42", "name": "Ada", "email": "[email protected]" },
"mode": "fill",
"template": "tpl_vQ8VEOnjY5H"
}'Full reference: Create a session.
Users are upserted
user.id is your own id for the person. The first session creates the Muzekit user; later sessions with the same id update their name, email and locale and reuse their templates and assets.