Docs / Embeddable editor

Platform

Embeddable editor

If your product lets customers customise their documents (their own invoice layout, their own certificate), you can put the DevilPDF template editor inside your app. Your user edits one template in an iframe. They never see DevilPDF's dashboard and never hold your API key.

The embeddable editor is available on the Growth plan and up.

#How it works

  1. Your backend creates an embed token for one template.
  2. Your frontend loads the returned URL in an iframe.
  3. The user edits and saves. Changes are written to that template.
  4. Your backend keeps rendering the template by id, as usual.

#1. Give each customer a template

A token unlocks exactly one template, so each of your customers needs their own copy. Create it once, when they first open the editor, and store the id with the customer.

curl https://devilpdf.com/v1/templates \
  -H "Authorization: Bearer $DEVILPDF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "from": "invoice", "name": "Invoice: customer 8813" }'

Starter templates cannot be embedded directly, because they are read-only. Copy one first, as above.

#2. Create an embed token

Do this on your server, each time the user opens the editor.

curl https://devilpdf.com/v1/embed-tokens \
  -H "Authorization: Bearer $DEVILPDF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "template": "tpl_8sK2mQx7Lp0aVn3RtYc1", "expires_in": 3600 }'
FieldTypeDescription
templatestringRequired. The template to open. Must be an HTML template on your account.
expires_innumberSeconds the token is valid. Default 3600. Minimum 60, maximum 86400 (24 hours).

#3. Show the editor

<iframe
  src="https://devilpdf.com/embed/editor?token=..."
  style="width: 100%; height: 720px; border: 0"
  title="Document editor"
></iframe>

Give the iframe plenty of room: the editor shows the template and a live preview side by side.

Your user gets the same editor as the dashboard: a code view (HTML, CSS, sample data, page settings), a visual view, a live preview and a test render button. Test renders from the embedded editor are free and do not count against your allowance. AI generation is not available inside the embed.

#Security

  • Create tokens on your server. Creating one needs your API key, which must never reach the browser.
  • A token is limited to one template. It cannot list or read anything else on your account, and it cannot render billable documents.
  • Tokens expire. Keep expires_in short and create a fresh token each time the editor is opened. A token cannot be revoked early, so do not issue 24-hour tokens unless you need to.
  • Decide the template on your server. Map the signed-in user to their template id yourself. If the browser could choose the id, one customer could open another's template.

#Errors

TypeStatusCause
plan_limit403Your plan does not include the embeddable editor.
not_found404The template does not exist on your account.
invalid_request400The template is a starter, or is not an HTML template.