Skip to main content
API reference for all Onboarding SDK methods, types, and options.

createWorthOnboarding

Import

Parameters

createWorthOnboarding accepts a single argument object with the following properties:
createWorthOnboarding validates its options synchronously. An invalid or missing inviteToken or other malformed option throws a WorthOnboardingError immediately rather than surfacing it later through mount() or onError. See Error Handling.

Example

SDK 3 also ships a browser-global build at dist-sdk/sdk3/worthai-onboarding-sdk.global.js. When loaded directly in a browser page, use the global namespace configured by the SDK build:

Returned Methods

createWorthOnboarding returns a WorthOnboarding object with two methods:

mount(target)

Mounts the embedded onboarding runtime into a DOM target. SDK styles are injected automatically as part of this call. Parameters:
  • target: HTMLElement | string - The element to mount into, or a CSS selector string that resolves to one
Returns:
  • Promise<HTMLElement> - Resolves with the mounted host element once the runtime has rendered
Example:
Only one onboarding instance can be mounted at a time. Call unmount() before mounting a new instance on the same page.

unmount()

Tears down the mounted runtime, removes its DOM element, and releases the mount target so that a new instance can be mounted later. Parameters: None Returns: void Example:
If the runtime fails to tear down cleanly, unmount() will throw a WorthOnboardingError with the code UNMOUNT_FAILED.

Callbacks

onComplete(event)

Observes the completion of the onboarding flow once the applicant has submitted the final step. Event shape (WorthOnboardingCompleteEvent):
If onComplete fails or rejects, it will throw a WorthOnboardingError with the code CALLBACK_FAILED.

onStepSubmit(event)

Observes submitted step payloads as an applicant progresses through the onboarding flow. Event shape (WorthOnboardingStepSubmitEvent):
If onStepSubmit fails or rejects, it will throw a WorthOnboardingError with the code CALLBACK_FAILED.

onError(error)

Observes every SDK and runtime error, including validation failures, mount failures, and callback failures. See Error Handling for a complete list of codes.

onAuthenticated(result) / onAuthUnsupported(result)

Observes authentication outcomes for the invite token.
  • onAuthenticated fires when the invite token authenticates successfully. The result includes authMode, authResponse, and status: 'authenticated'
  • onAuthUnsupported fires when the invite token’s auth mode isn’t supported by the embedded flow. The result includes authMode, message, an optional redirectPath, and status: 'unsupported'

Error Handling

Every error that the SDK raises is an instance of WorthOnboardingError, an Error subclass with a stable code:
WorthOnboardingError has the following shape:

Error Codes

Every error raised from mount() and unmount() is delivered to onError (if provided) before the returned promise rejects with the same error object.

Next Steps


Support

For questions or issues, please contact your Worth Customer Success team or reach out to support@joinworth.com.