> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntage.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Widget (Deprecated)

<Warning>
  This widget is deprecated. Existing integrations can continue using it, but new integrations should use [Embedding Entity Onboarding](/guides/embedding-entity-onboarding) instead.
</Warning>

The widget script embeds the legacy registration experience in your application. Use this page if your integration already depends on the legacy widget and you need to keep it working or troubleshoot it.

## Add the script

Get your `SCRIPT_URL` and `COMPANY_SLUG` from the dashboard under `Widget > Widget script`, then add the script tag to your application.

```html theme={null}
<script
  async
  id="satws-widget-id"
  type="text/javascript"
  src="SCRIPT_URL"
  data-key="COMPANY_SLUG"
></script>
```

The `data-key` value identifies your widget configuration. Keep it aligned with the environment you are using.

## Start and stop registration

After the script loads, use `window.Satws.init()` to open the registration experience.

```js theme={null}
window.Satws.init();
```

Use `window.Satws.destroy()` to close and clean up the widget.

```js theme={null}
window.Satws.destroy();
```

## Sandbox warning

To show the legacy sandbox warning, pass `data-sandbox="true"` in the script tag.

```html theme={null}
<script
  async
  id="satws-widget-id"
  type="text/javascript"
  src="SCRIPT_URL"
  data-key="COMPANY_SLUG"
  data-sandbox="true"
></script>
```

<Note>
  The `data-sandbox` attribute only controls the warning shown to users. The token and script URL determine whether the widget connects to production or sandbox.
</Note>

## Events

Use `window.Satws.subscribe` to subscribe to widget events.

| Event                 | Description                       |
| --------------------- | --------------------------------- |
| `registerWithSuccess` | Fired when registration succeeds. |
| `errorOnRegister`     | Fired when registration fails.    |

```js theme={null}
window.Satws.subscribe("registerWithSuccess", () => {
  // Continue your success flow.
});
```

```js theme={null}
window.Satws.subscribe("errorOnRegister", () => {
  // Show your error state or retry option.
});
```

## Dynamic loading

If you load the widget dynamically in an SPA or through GTM, the script may not be ready when you call `init()`. Listen for `widgetScriptLoaded` before starting registration.

```js theme={null}
try {
  window.Satws.init();
} catch {
  window.addEventListener("widgetScriptLoaded", () => {
    window.Satws.init();
  });
}
```

## Troubleshooting

* Confirm the script tag uses the `id="satws-widget-id"` attribute.
* Confirm `data-key` matches the widget configuration for the environment you are using.
* Confirm the widget script is allowed by your Content Security Policy.
* Subscribe to `errorOnRegister` so your application can show a useful error state.
