## UI Embedding Guide

### Launching the PDF Insights Webapp

To run the PDF Insights webapp from a browser, do the following:

1. Contact [MoneyThumb support](https://www.moneythumb.com/support/) to whitelist the domain you'll be using to call the iFrame.
2. Use the URL [https://online.moneythumb.com/](https://online.moneythumb.com/).
3. Use the URL parameters from the table below.


| URL Parameter  | Description | Required |
|  --- | --- | --- |
| `ctype` | Product, i.e., `pdfinsights` or `pdfinsightstp`. | ✅ |
| `token` | Token received from the Authenticate call. | ✅ |
| `appid` | The value with the loan application ID previously received. | ✅ |
| `landingName` | The name of the landing URL. The default is `SIGNED_SCORECARD`. To  get a new landing, use `SIGNED_REVIEW`. |
| `username` | User name to display in the upper-right while in webapp. | ✅ |
| `customerid` | Customer ID to track conversions by that customer. |  |
| `css` | Applies the CSS style sheet. |  |
| `altlogo` | The URL for an alternate logo. `altlogo` must be URL-encoded. For example `\&altlogo=https%3A%2F%2F[http://www.myco.com](http://www.myco.com/)%2Flogos%2Fmylogo.png` |  |
| `readOnlyCustomMode` | Opens the application to the convert page and prevents the user from modifying the application. The values for this parameter are `true` or `false`. |  |


#### Sample URL

If you set up the URL correctly, it should like the following:

[https://online.moneythumb.com/?ctype=pdfinsights
/&token=/*token/*/
&appid=123/
&landingName=SIGNED_REVIEW/
&username=you@yourdomain.com](https://insights.moneythumb.com/?ctype=pdfinsights&token=_token_&appid=123&landingName=SIGNED_REVIEW&username=you@yourdomain.com)

#### Responses

| Success Response | Error Response |
|  --- | --- |
| PDFInsights web app will launch with specified application. | Code 401 if token/appid do not match. Or, if appid does not exist. |


#### IFrame from the Signed Scorecard URL Endpoint

If you only want the end user to view the scorecard, then use the `scorecard/signedURL` endpoint. You can retrieve a formatted URL from this endpoint. This hides the header and only shows the scorecard. For details, see [Retrieve signed scorecard URL](https://docs.moneythumb.com/pdf-insights/api-reference/other/signedurl).

### Exiting the PDFInsights Webapp

When you click the **Return to CRM** button, the webapp sends a message to the parent window. This message has 2 values:

* **appName:** Always MoneyThumb.
* **appId:**  The `appid` of the loan application.


⚠️ **Warning:** Due to the web browser's "same-origin" policy, if you open the webapp in another window or iFrame, the webapp won't be able to close the window because it would violate browser security.

#### Sample Return from Webapp


```
window.addEventListener("message", receiveMessage, false);  
function receiveMessage(event)  
{  
    var evdata = event.data;  
    if (evdata.appName \== 'MoneyThumb')  
    {  
        console.log("AppId " + evdata.appId)  
        var iframe = document.getElementById("iframe");  
        iframe.style.display = "none";  
    }

}
```