# Passcode

Functions to manage passcode in the app.

> You'll need to import the javascript file in your website before starting from this [link](https://docs.webtonative.com/javascript-apis/getting-started).

## Set Passcode

Creates or updates a user's passcode with an optional reauthentication step.

{% tabs %}
{% tab title="Plain Javascript" %}

```javascript
window.WTN.Passcode.setPasscode({ reauthenticate: true });
```

{% endtab %}

{% tab title="ES5+" %}

```javascript
import { Passcode } from "webtonative";

Passcode.setPasscode({ reauthenticate: true });
```

{% endtab %}
{% endtabs %}

**Parameter:**

| Key              | Type      | Description                                                                                                                                                                   |
| ---------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `reauthenticate` | `Boolean` | If `true`, the user must enter their existing password before setting or changing the passcode. If `false`, the passcode can be set without asking for the existing password. |

When reauthentication is enabled, the function prompts for the current password before proceeding. Otherwise, it goes directly to passcode setup.

***

## Reset Passcode

Resets the user's passcode with optional app data cleanup.

{% tabs %}
{% tab title="Plain Javascript" %}

```javascript
window.WTN.Passcode.resetPasscode({ resetAppData: false });
```

{% endtab %}

{% tab title="ES5+" %}

```javascript
import { Passcode } from "webtonative";

Passcode.resetPasscode({ resetAppData: false });
```

{% endtab %}
{% endtabs %}

**Parameter:**

| Key            | Type      | Description                                                                                                                                                            |
| -------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `resetAppData` | `Boolean` | If `true`, all application data is cleared along with the passcode. If `false`, only the passcode-related data is cleared and the rest of the app data remains intact. |

Depending on the value of `resetAppData`, this either performs a full app data reset or limits the reset to passcode information only.


---

# 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.webtonative.com/javascript-apis/passcode.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.
