# Get Started

{% hint style="info" %} <mark style="color:blue;">**This document is for old version of nonstress. check latest version of nonstress:**</mark> <https://nonstress.mintlify.app/>
{% endhint %}

## Add Script Tag

Add this tag to your website's html to use nonstress in the page.

```javascript
<script src="https://hamutan86.pythonanywhere.com/nonstress/nonstress.js" async defer></script><script src="https://hamutan86.pythonanywhere.com/nonstress/nonstress.js" async defer></script>
```

Now your page is prepared to being protected by nonstress!

## Get The Token

You need "token" to check request's validity on server side. the token will be created automatically when the user opened your page.

When the token is ready, `nonstressCompleted` Event will be dispatched.\
Seeing is believing, check this example code:

```javascript
document.addEventListener("nonstressCompleted", (e) => {
    console.log(e.detail.success); // true|false
    console.log(e.detail.token); // "0dc240c66802f7329a1cb9f85804c49f6bb34a..."
});
```

When `e.detail.success` was false, it means failed to verify the user.\
In that case, you can't get token. so you have to reload the page, or use [nonstress.generateToken()](#regenerate-the-token) .\
\
You can get the token directly even the Event is already dispatched:

```javascript
nonstress.getToken(); // "0dc240c66802f7329a1cb9f85804c49f6bb34a..."
```

It's pretty simple. in this case, it returns empty string when nonstress isn't completed or it's failed.

## Regenerate The Token

Oh, user typo the password, cancelled action, or nonstress failed? if token is once validated, it can't be reused, but you don't have to reload the page.

Here's magic:

```javascript
nonstress.generateToken()
```

It will regenerate the token, redispatch the Event and overwrite nonstress.getToken() .


---

# 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://nonstress.gitbook.io/nonstress-docs/get-started.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.
