Widget Reference

The options and callbacks you can pass when you create the widget, and the versions you can load.

Embed the widget

Add the script to your page, create a SmileLinkModal instance, and call open():

<script src="https://web.smileapi.io/v2/smile.v2.js"></script>
<script>
  const smileLinkModal = new SmileLinkModal({
    userToken: '<link-token>',        // minted by your backend, per launch
    templateId: '<wink-template-id>', // from the Developer Portal

    // Account lifecycle
    onAccountCreated: ({ accountId, userId, providerId }) => { /* account record created */ },
    onAccountConnected: ({ accountId, userId, providerId }) => { /* link completed */ },
    onAccountRemoved: ({ accountId, userId, providerId }) => { /* access revoked */ },
    onAccountError: ({ accountId, userId, providerId, errorCode }) => { /* link failed */ },

    // Documents uploaded instead of a provider login
    onUploadsCreated: ({ uploads, userId }) => { /* documents submitted */ },
    onUploadsRemoved: ({ uploads, userId }) => { /* documents removed */ },

    // The widget itself
    onTokenExpired: () => { /* the Link token expired */ },
    onClose: ({ reason }) => { /* 'close' | 'exit' | 'error' */ },

    // Every user activity, if you need the full funnel
    onUIEvent: ({ eventName, eventTime, mode, userId, account, archive }) => { /* ... */ }
  });
  smileLinkModal.open();
</script>

All nine callbacks are registered above; drop the ones you do not need. The runnable version of this page is the Web sample in Sample Apps, which console.logs every payload.

Options

The Wink Widget uses Wink Templates to manage instantiated settings for each widget embedded in your app. Templates allow for rich customisation, including primary colors and the data sources selected for the instance.

ParameterValue
templateIdID of the Wink Template in use
userTokenThe Link token returned from Smile using the /users endpoint (see documentation on Users endpoint)
callbacksAll the callbacks are optional, but suggest listening to onClose() callback, so you can return from the widget to your application page

Callbacks

Every callback is optional, but listen to at least onClose so the user can return from the widget to your page:

CallbackFires when
onUIEventany user activity inside the widget — provider selection, form input, and so on
onAccountCreatedthe account record is created for the selected provider
onAccountConnectedthe user authenticated and the account is CONNECTED
onAccountErrorthe connection failed; the callback carries errorCode
onUploadsCreateddocuments were submitted
onUploadsRemovedsubmitted documents were removed
onTokenExpiredthe Link token expired before the flow finished
onAccountRemovedthe user revoked the connection
onClosethe widget closed — close is the X button, exit is the DONE button, error is Exit on the error screen

Taken together, these are the widget-level events: they fire in the browser or WebView, so they are only available to you when you embed the widget. Invitation and Wink Site users run inside a Smile-hosted page, where you receive the account-level webhooks instead.

Versions

Wink Widget Version 2 contains many user experience and functionality improvements and is the recommended version.

Version 1 is still maintained and security monitoring, updates, and patches will continue to be done.

VersionWidget JavaScript embed
Version 2 (recommended)<script src="https://web.smileapi.io/v2/smile.v2.js"></script>
Version 1 (deprecated)<script src="https://web.smileapi.io/v1/smile.v1.js"></script>

Switching from version 1 to version 2 only requires changing the script URL — no other code changes. Wink Sites and invitation emails always use the current version.