Skip to main content

JavaScript SDK

The SpitShake JavaScript SDK provides a global window.SpitShake 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.SpitShake and defines the <docuseal-form> and <docuseal-builder> web components.
For single-page applications, you can load the script dynamically:

Methods

SpitShake.configure(options)

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

SpitShake.mount(options)

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

SpitShake.mountBuilder(options)

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

SpitShake.form(options)

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

SpitShake.builder(options)

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

SpitShake.on(event, callback)

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

SpitShake.off(event, callback)

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

Events

Form events

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

loaded

Fired when the form content has fully rendered and is interactive.
Callback argument:
submitter is the signer’s slug.

completed

Fired when the signer successfully submits the form.
Callback argument:
redirect_url is the completed_redirect_url resolved for this signer, or null. The event carries no document, field or submission data; use the API or webhooks for those. When redirect_url is an http(s) URL, the form element redirects your page to it after the event. SpitShake.on('completed') cannot stop that. To handle the redirect yourself, listen on the element that mount() returns and call preventDefault():
See Redirect after completion for where the URL comes from and what a reopened link shows.

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 SpitShake.mountBuilder() or SpitShake.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 SpitShake.on(), the loaded event fires for both. Differentiate by checking for detail.submitter (form only).