# Is it possible to initiate a logout from the account in the widget programmatically?
## Symptoms

Is it possible to initiate a logout from the account in the widget programmatically?
Is there an API for logging out of the widget account?

## Solution

Yes, it is possible to initiate a logout from the widget account programmatically using the standard browser API [window.postMessage](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) on the DOM iframe object:


```jsx
const iframe = document.getElementById("swarmica_widget_iframe_id");
iframe.contentWindow.postMessage({ type: "LOGOUT_WIDGET" }, "*");
```

For example, this is what the code for logging out of the account when a button is clicked might look like:

```html
<!-- parent HTML --> 
<button id="logoutWidgetBtn">
  Logout widget
</button>

<!-- start embedded Swarmica widget script -->
<iframe src="..." id="swarmica_widget_iframe_id" style="position: fixed; right: 12px; bottom: 12px; width: 56px; height: 56px; overflow: hidden; "
  allowTransparency="true"
  frameborder="0"
  allowTransparency="true" frameborder="0"></iframe>
<!-- rest of embed code -->
<script>
  const iframe = document.getElementById("swarmica_widget_iframe_id")
  iframe.onload = () => {
    renderWidget("swarmica_widget_iframe_id")
  }
  document.getElementById("swarmica_widget_iframe_id").addEventListener("click", 
    () => {
            if (!iframe || !iframe.contentWindow) return;
            iframe.contentWindow.postMessage({ type: "LOGOUT_WIDGET" }, "*")
  });
</script>
<!-- end embedded Swarmica widget scripts -->
```

:::info
You will need to have Swarmica version [v5.7.2](https://support.swarmica.com/article/ru/1237-obnovlenie-v57x.html) or above
:::