Create an embedded editor session
Lets one of your users edit one template inside your product, in Druckling's white-label editor. Call this from your backend with a full-access key (templates:write) when the user opens the editor, then give the returned url to their browser.
The editor loads in an iframe on the origins allowed in Settings › Embed (enforced with CSP frame-ancestors); without any allowed origin the answer is 409 invalid_state. The session can read that template, save its draft, render previews and, if you allow it, publish. Nothing else in the workspace (other templates, documents, API keys, webhooks, billing, team) is reachable with it.
Sessions are short-lived: 30 minutes by default, at most an hour. When one expires the editor tells your page with an error event (session_expired); create a new session to continue. Drafts are saved continuously, so nothing is lost. The editor shows a small "Powered by Druckling" mark on the Free and Starter plans.
AuthorizationBearer <token>Authorization: Bearer dr_live_… or dr_test_…
application/json- body
template*stringSlug of the template to edit, e.g. invoice-standard.
1 <= length <= 64permissions?expires_in?integerSeconds until the session ends: default 1800, at most 3600.
60 <= value <= 3600user?Who is editing. Shown in Druckling's request logs and on the versions they publish (embed:<id>).
theme?OK
application/json- response
id*stringobject*unknownurl*|Load this URL in an iframe (or pass it to mountEditor from @druckling/embed). Returned only when the session is created. The session token sits in the fragment (#token=…), which browsers never send to servers; Druckling keeps only a hash of it. Hand the URL to the signed-in user's browser only, never log or cache it.
template*stringSlug of the template the session edits.
permissions*What the editor offers beyond editing the draft.
user*|Your user, as you described them.
theme*status*string"active""expired""revoked"expires_at*stringdate-timerevoked_at*|nulltest_mode*booleancreated_at*stringdate-timecurl -X POST 'https://druckling-nine.vercel.app/v1/embed_sessions' \ -H 'Content-Type: application/json' \ -d '{ "template": "string"}'{ "id": "string", "object": "embed_session", "url": "string", "template": "string", "permissions": { "publish": true, "assistant": true }, "user": { "id": "string", "name": "string" }, "theme": { "mode": "light", "accent": "string" }, "status": "active", "expires_at": "2019-08-24T14:15:22Z", "revoked_at": "2019-08-24T14:15:22Z", "test_mode": true, "created_at": "2019-08-24T14:15:22Z"}