# How widget works

With the ZapSign widget, you can integrate electronic signatures directly into your website, ensuring a smooth and secure experience!&#x20;

{% hint style="warning" %}
To use the widget, your application must be a web application compatible with JavaScript.
{% endhint %}

### Adding the Widget to Your Site

**To embed the ZapSign widget** into your site, **use the HTML code provided below**:

```markup
<!DOCTYPE html>
<html>
<head>
	<title>Test Widget ZapSign</title>
</head>
<body>
        <!--Note: It is important to include the 'allow' attribute in your iframe so we can request the signer's photo or document photo if you have opted for any of these signing methods -->
	<iframe src="https://app.zapsign.co/verificar/SIGNER-TOKEN" width="100%" height="800px" allow="camera"></iframe>

	<script>		
			window.onmessage = function(e){
	        if(e.data === 'zs-doc-loaded'){
	        	alert('Doc loaded in iframe')
	        }
	        if(e.data === 'zs-doc-signed'){
	        	alert('Doc signed by signer')
	        }
	        if(e.data === 'zs-signed-file-ready'){
	        	alert('Signed file (final pdf) ready to download')
	        }
			};
	</script>

</body>
</html>
```

{% hint style="info" %}
Each signer has their own token, and the linkage occurs automatically when creating the document. See the section ["Types of Tokens and How to Locate Them"](/english/types-of-tokens.md) for more information.
{% endhint %}

***

### Using `window.onmessage` with the Widgets

The `window.onmessage` function is optional but helps provide immediate feedback to users, ensuring a faster and more efficient signing experience. Available events include: document loading, signature completion, and the availability of the signed file for download.<br>

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td></td><td><mark style="background-color:green;"><strong>zs-doc-loaded</strong>:</mark> when the PDF finishes loading on the signer's screen.</td><td></td><td><a href="/files/lTQ3RRm2s3TeQUhyxRUc">/files/lTQ3RRm2s3TeQUhyxRUc</a></td></tr><tr><td></td><td><mark style="background-color:green;"><strong>zs-doc-signed</strong>:</mark> when the signer successfully signs the document.</td><td></td><td><a href="/files/lTQ3RRm2s3TeQUhyxRUc">/files/lTQ3RRm2s3TeQUhyxRUc</a></td></tr><tr><td></td><td><mark style="background-color:green;"><strong>zs-signed-file-ready</strong>:</mark> when the final PDF is ready to download (this is when the "download signed" button is enabled for example).</td><td></td><td><a href="/files/lTQ3RRm2s3TeQUhyxRUc">/files/lTQ3RRm2s3TeQUhyxRUc</a></td></tr></tbody></table>

***

### Allow Attribute

In the ZapSign widget, the `allow` attribute in the `<iframe>` element permits access to the device’s camera when necessary, such as capturing a photo of the signer or a document during the signing process. **Adding `allow="camera"` ensures that the widget can request the camera if this signing option is enabled.**

<figure><img src="https://github.com/AmandaAmani/documenta-ocurso/blob/main/allow%20camera.gif?raw=true" alt="GIF demonstrating the use of the allow attribute in an iframe, highlighting permission for camera access."><figcaption><p>Example of using the <code>allow</code> attribute in an iframe to enable camera access.</p></figcaption></figure>

{% hint style="warning" %}
Documents using facial recognition authentication require additional configurations to ensure the security of the entire application. If you need this functionality or have questions on how to integrate it into your workflow, contact our support team at <support@zapsign.com.br>.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zapsign.com.br/english/widget/como-funciona.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
