Skip to main content

Template Builder Web Component

The <docuseal-builder> web component renders the full template editor inside your application. Users can upload documents, drag and drop fields, configure submitter roles, and save templates — all without leaving your page.

Quick start

Generate a JWT token server-side, then embed the builder:
The builder always requires authentication. Use a JWT token from POST /api/embed/token (recommended for embedded use) or pass data-template-id when the user is already authenticated via a session cookie.

Attributes

The <docuseal-builder> component accepts 33 data-* attributes to control behavior, authentication, and UI.

Full HTML example

Events

The <docuseal-builder> component emits DOM custom events. Listen with addEventListener on the element.

init

Fired when the web component is initialized and the iframe begins loading.
Event detail: null

load

Fired when the iframe has loaded and the builder is ready to render.
Event detail: null

loaded

Fired when the builder UI has fully rendered and is interactive.
Event detail:

template-saved

Fired when the template is saved (either by auto-save or the user clicking Save).
Event detail:

template-data

Fired when the builder emits template data in response to a getTemplate() call or internal state change.
Event detail: Same structure as template-saved.

send

Fired when the user clicks the “Send” button inside the builder.
Event detail:

upload

Fired when a document is uploaded to the builder.
Event detail:

change

Fired when any change occurs in the builder — field added, moved, resized, deleted, or properties updated. Useful for tracking unsaved changes or implementing custom auto-save logic.
Event detail:

Public methods

The <docuseal-builder> element exposes two public methods for programmatic interaction.

getTemplate()

Returns a Promise that resolves with the current template state. The method communicates with the builder iframe via postMessage and has a 5-second timeout.
Return value:

save()

Triggers a save operation via postMessage to the builder iframe. This is equivalent to the user clicking the Save button. The save is asynchronous — listen for the template-saved event to confirm completion.

Fields configuration

The data-fields attribute accepts a JSON array of field definitions. Each field object supports the following properties: Supported field types: Example with data-only-defined-fields: When you set data-only-defined-fields="true", only the field types specified in data-fields appear in the field palette. This is useful when you want to restrict what fields a user can place on the document.

React integration