# Initialize

You can pass in different handler functions like the **onLoad**, **onStart, onRestart, onPassStep, onComplete** or **onError** method to handle different events of the verification flow to the **init** function.

<table data-header-hidden><thead><tr><th width="367">Argument</th><th>Description</th></tr></thead><tbody><tr><td><p></p><pre class="language-javascript"><code class="lang-javascript">let onLoad: () => void;
</code></pre></td><td>Method that is being called once a verification flow is loaded. You can use this to show your own loader and then show <strong>div</strong> <strong>allpass</strong>.</td></tr><tr><td><pre class="language-javascript"><code class="lang-javascript">let onStart: (event: {
  appKey: string;
  transactionId: string;
  externalUserId: string;
  flowId: number;
  mode: 'LIVE' | 'TEST';
}) => void;
</code></pre></td><td><p>Method that is being called once a user starts the verification flow.<br><strong><code>appKey</code></strong>: API Key<br><strong><code>transactionId</code></strong>: UUID of the verification.  You can use this to query our API.</p><p><strong><code>externalUserId</code></strong>: External user ID (user ID in your system)<br><strong>flowId</strong> : Workflow ID <br><strong>mode</strong> : Live or Test mode</p></td></tr><tr><td><pre class="language-javascript"><code class="lang-javascript">let onRestart: (event: {
  appKey: string;
  transactionId: string;
  externalUserId: string;
  flowId: number;
  mode: 'LIVE' | 'TEST';
}) => void;
</code></pre></td><td><p>Method that is being called once a user starts the verification flow, but the  verification is not completed</p><p><strong><code>appKey</code></strong>: API Key<br><strong><code>transactionId</code></strong>: UUID of the verification.  You can use this to query our API.</p><p><strong><code>externalUserId</code></strong>: External user ID (user ID in your system)<br><strong>flowId</strong> : Workflow ID <br><strong>mode</strong> : Live or Test mode</p></td></tr><tr><td><pre class="language-javascript"><code class="lang-javascript"><strong>let onPassStep: (event: {
</strong>  appKey: string;
  transactionId: string;
  stepType: string;
  externalUserId: string;
  flowId: number;
  mode: 'LIVE' | 'TEST';
}) => void;
</code></pre></td><td><p>Method that is being called once a user pass any step of the verification flow.</p><p><strong><code>stepType:</code></strong>The step can be one of the following</p><p><code>"intro" | "biometry" | "documents" | "scan" | "diia" | "complete"</code></p><p><strong><code>appKey</code></strong>: API Key<br><strong><code>transactionId</code></strong>: UUID of the verification.  You can use this to query our API.</p><p><strong><code>externalUserId</code></strong>: External user ID (user ID in your system)<br><strong>flowId</strong> : Workflow ID <br><strong>mode</strong> : Live or Test mode</p></td></tr><tr><td><pre class="language-javascript"><code class="lang-javascript"><strong>let onComplete: (event: {
</strong>  appKey: string;
  transactionId: string;
  externalUserId: string;
  flowId: number;
  mode: 'LIVE' | 'TEST';
}) => void;
</code></pre></td><td><p>Method that is being called once the verification is completed.</p><p><strong><code>appKey</code></strong>: API Key<br><strong><code>transactionId</code></strong>: UUID of the verification.  You can use this to query our API.</p><p><strong><code>externalUserId</code></strong>: External user ID (user ID in your system)<br><strong>flowId</strong> : Workflow ID <br><strong>mode</strong> : Live or Test mode</p></td></tr><tr><td><pre class="language-javascript"><code class="lang-javascript"><strong>let onError: (event: {
</strong>  appKey: string;
  transactionId: string;
  error: string;
  stepType?: string;
  externalUserId: string;
  flowId: number;
  mode: 'LIVE' | 'TEST';
}) => void;
</code></pre></td><td><p><strong><code>error:</code></strong>  The reason why the flow failed. </p><p><strong><code>stepType:</code></strong>The step where the error occurred, can be <strong>undefined</strong> or one of the following</p><p><code>"intro" | "biometry" | "documents" | "scan" | "diia" | "complete"</code><br><strong><code>appKey</code></strong>: API Key<br><strong><code>transactionId</code></strong>: UUID of the verification.  You can use this to query our API.</p><p><strong><code>externalUserId</code></strong>: External user ID (user ID in your system)<br><strong>flowId</strong> : Workflow ID <br><strong>mode</strong> : Live or Test mode</p></td></tr></tbody></table>

```javascript
Allpass.init({
  onLoad: () => {},
  onRestart: ({appKey, transactionId, externalUserId}) => {},
  onStart: ({appKey, transactionId, externalUserId}) => {},
  onPassStep: ({appKey, transactionId, stepType, externalUserId}) => {},
  onComplete: ({appKey, transactionId, externalUserId}) => {},
  onError: ({appKey, transactionId, error, stepType, externalUserId}) => {},
});
```

{% hint style="info" %}
If user doesn't finish verification process and current session is still active - we can automatically start this verification. In order to make it you should call **restart** after **init** method.
{% endhint %}

```javascript
Allpass.restart();
```

Also it could be chaining with an init method:

```javascript
Allpass
  .init({onComplete: ({appKey, transactionId, externalUserId, flowId, mode}) => {}})
  .start(accessToken);
```


---

# 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.elkyc.com/home/integration/usage.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.
