D
Druckling
Docs

Create an embedded editor session

POST
/embed_sessions

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.

Authorization

headerAuthorizationBearer <token>

Authorization: Bearer dr_live_… or dr_test_…

Request Body

application/json
  1. body
template*string

Slug of the template to edit, e.g. invoice-standard.

Length1 <= length <= 64
permissions?
expires_in?integer

Seconds until the session ends: default 1800, at most 3600.

Range60 <= value <= 3600
user?

Who is editing. Shown in Druckling's request logs and on the versions they publish (embed:<id>).

theme?

Response Body

OK

application/json
  1. response
id*string
object*unknown
url*|

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*string

Slug 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
Value in"active""expired""revoked"
expires_at*string
Formatdate-time
revoked_at*|null
test_mode*boolean
created_at*string
Formatdate-time
Example Request
curl -X POST 'https://druckling-nine.vercel.app/v1/embed_sessions' \  -H 'Content-Type: application/json' \  -d '{  "template": "string"}'
Example Response201
{  "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"}