# Iframe embedding

The editor is embeddable in an iframe too, using `/tokenAuth?token=<token>`method. The only difference is that you use `app-proxy.thebrief.ai` subdomain instead `app.thebrief.ai`

```html
<iframe
      title="The Brief"
      src="https://app-proxy.thebrief.ai/tokenAuth?token=<token>"
      style="width: 100%; border: none; min-height: 800px"
    >
</iframe>
```

To ensure consistent integration, the iframe sends two messages to the parent window. One when the session starts and another when it ends, triggered by clicking the "End session" button.

You can catch the messages using the next script:

```javascript

    window.addEventListener("message", (event) => {
      // Optionally, check the origin of the message for security purposes
      if (event.origin !== "https://app-proxy.thebrief.ai") return;

      // Handle the message
      console.log("Message received from iframe:", event.data);
    });
  
```

{% code title="Session started" fullWidth="false" %}

```json
{
    "type": "sessionStarted",
    "sessionId": "xxx", // id of the session that just started
    "initToken": "<token>" // the JWT sent to authenticate the current session /token-auth/{token}
}    
```

{% endcode %}

{% code title="Session ended" %}

```json
{
    "type": "sessionEnded",
    "sessionId": "xxx", // id of the session that just finished
}    
```

{% endcode %}
