> For the complete documentation index, see [llms.txt](https://docs.legitimate.tech/technical-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.legitimate.tech/technical-docs/developer-resources/web-html-implementation/getting-started.md).

# Getting Started

Use our provided javascript function in your own HTML website to easily verify the digital signatures emitted by Legitimate's NFC tags

For convenience, Legitimate provides a simple javascript implementation of the API verification mechanism required to validate the digital signatures emitted by NFC tags. You can see a full HTML example [here](/technical-docs/developer-resources/web-html-implementation/simple-html-example.md).

### Add the JS snippet

To get started, simply add our minified javascript function to the top of your HTML `<head>` block. Make sure this is at the top of the `<head>` block as it is required to load first.

<pre class="language-html"><code class="lang-html"><strong>&#x3C;head>
</strong><strong>    &#x3C;script type="text/javascript">
</strong><strong>        (function(){var a=document.createElement('style');a.innerHTML=`
</strong>    body { display: none !important; }
  `;document.head.appendChild(a);var b='https://api.legitimate.tech/external/v1/tags/verify';document.addEventListener('DOMContentLoaded',()=>{console.log('DOM loaded, making API request');fetch(b,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(Object.fromEntries(new URLSearchParams(window.location.search)))}).then(async A=>{var _=await A.json();if(!A.ok){A.status===422&#x26;&#x26;_.errors.cmac.indexOf('has expired')!==-1?c('expired_cmac'):c();return}!_.errors?a.innerHTML=`
          body { display: block !important; }
          #legitimate-custom-error-message { display: none !important; }
          #legitimate-expired-cmac-message { display: none !important; }
        `:c()}).catch(()=>c())});function c(B='default'){let C=document.getElementById('legitimate-error-message-container');!C&#x26;&#x26;(console.log('Creating error message container'),C=document.createElement('div'),C.id='legitimate-error-message-container',document.body.appendChild(C));let _c=`
      &#x3C;div style="font-family: sans-serif; color: red; padding: 2rem; text-align: center;">
        An error occurred. Please try again later.
      &#x3C;/div>
    `;if(B==='expired_cmac'){var d=document.getElementById('legitimate-expired-cmac-message');d&#x26;&#x26;(console.log('Using expired cmac error message'),_c=d.innerHTML)}else{var e=document.getElementById('legitimate-custom-error-message');e&#x26;&#x26;(console.log('Using custom error message'),_c=e.innerHTML)}C.innerHTML=_c;a.innerHTML=`
      body { display: block !important; }
      body > *:not(#legitimate-error-message-container) { display: none !important; }
    `}})();
<strong>    &#x3C;/script>
</strong><strong>    &#x3C;!-- other code that may need to go into the head element -->
</strong><strong>&#x3C;/head>
</strong></code></pre>

This script contains sensible defaults that will hide the entirety of your page's contents until after the digital signature verification is complete. You can see the un-minified implementation of this script [here](https://github.com/LegitimateTech/lgt-verify-example/blob/main/html/verify-sdk-v1.js).

### What this script does

This script calls the exact same API endpoint as described in [Verify](/technical-docs/api-resources/verify.md) by passing through the verification parameters present in the URL query parameters. If the verification is successful, the contents of your HTML `<body>` will be displayed as normal.

### Adding Custom Error States

By default, the snippet will display an error message if the digital signature verification fails. You may add custom error messages by adding the following HTML elements to your page.

#### Reused Digital Signature Parameters Error Message

The inner contents of an HTML element with the following id `legitimate-expired-cmac-message` will be used as the error state content if the verification fails due to the verification parameters being reused.

```html
<div id="legitimate-expired-cmac-message" class="hidden">
    <!-- Expired CMAC Error Message -->
</div>
```

Our API is designed in such a way that each tag verification can only occur once with a given set of parameters. This is to prevent customers from sharing or replicating any URLs or links emitted by the NFC tag.

#### Default Error State Message

The inner contents of an HTML element with the following id `legitimate-custom-error-message` will be used as the default error state content if the verification fails.

```html
<div id="legitimate-custom-error-message" class="hidden">
    <!-- Your content here -->
</div>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.legitimate.tech/technical-docs/developer-resources/web-html-implementation/getting-started.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
