Skip to main content

JavaScript SDK

The DocuTrust JavaScript SDK provides a global window.DocuTrust API for programmatic control over embedded signing forms and template builders. Use the SDK when you need imperative mounting, dynamic configuration, or event-driven integration that goes beyond static HTML attributes.

Loading the SDK

Include the embed script in your HTML. The script registers window.DocuTrust and defines the <docuseal-form> and <docuseal-builder> web components.
For single-page applications, you can load the script dynamically:

Methods

DocuTrust.configure(options)

Set the DocuTrust instance URL. Call this once before mounting any forms or builders. Parameters:

DocuTrust.mount(options)

Mount a signing form into a container element. Returns the created DOM element. Parameters: Returns: The created <docuseal-form> DOM element.

DocuTrust.mountBuilder(options)

Mount the template builder into a container element. Returns the created DOM element. Parameters: Returns: The created <docuseal-builder> DOM element.

DocuTrust.form(options)

Alias for DocuTrust.mount(). Accepts the same parameters and returns the same result.

DocuTrust.builder(options)

Alias for DocuTrust.mountBuilder(). Accepts the same parameters and returns the same result.

DocuTrust.on(event, callback)

Subscribe to an event. Returns the DocuTrust SDK instance for method chaining. Parameters: Returns: DocuTrust (for chaining)

DocuTrust.off(event, callback)

Unsubscribe from an event. Returns the DocuTrust SDK instance for method chaining. Parameters: Returns: DocuTrust (for chaining)

Events

Form events

These events fire when a signing form is mounted via DocuTrust.mount() or DocuTrust.form().

loaded

Fired when the form content has fully rendered and is interactive.
Callback argument:

completed

Fired when the signer successfully submits the form.
Callback argument:

declined

Fired when the signer declines to sign the document.
Callback argument:

field-value

Fired each time the signer fills in or changes a field value.
Callback argument:

Builder events

These events fire when a template builder is mounted via DocuTrust.mountBuilder() or DocuTrust.builder().

loaded

Fired when the builder UI has fully rendered.
Callback argument:

template-saved

Fired when the template is saved.
Callback argument:

template-data

Fired in response to a getTemplate() call or internal state changes.
Callback argument: Same structure as template-saved.

send

Fired when the user clicks the “Send” button inside the builder.
Callback argument:

change

Fired when any change occurs in the builder — field added, moved, resized, deleted, or properties updated.
Callback argument:

Complete integration example

This example shows a full SPA integration that loads the SDK dynamically, mounts a signing form, handles all events, and provides a fallback builder flow.

Chaining pattern

The on() and off() methods return the SDK instance, enabling a fluent chaining pattern:
When using both form and builder events with DocuTrust.on(), the loaded event fires for both. Differentiate by checking for detail.submitter_id (form) vs. detail.template_id without detail.submitter_id (builder).