> ## Documentation Index
> Fetch the complete documentation index at: https://docs.checkin.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Web SDK callbacks and events

> Completion, failure, close and tracking callbacks.

Set the callbacks in the `init` config:

```javascript theme={null}
window.getidWebSdk.init({
  // ...other options
  onComplete: (data) => {
    console.log('onComplete:', data);
  },
  onFail: (error) => {
    console.log('onFail:', error);
  },
  onClose: () => {
    console.log('onClose');
  },
  onBack: () => {
    console.log('onBack');
  },
});
```

See [Configuration](https://docs.checkin.com/integrate/web-sdk/configuration.md#callbacks) for all options.

## onComplete

Called when all data is collected and no further input is needed from the applicant.

```javascript theme={null}
onComplete: (data) => {
  const applicationId = data.applicationId;
  // Send applicationId to your backend and match it with the webhook result
}
```

### Completion is not the decision

When `onComplete` fires, the verification is usually still `processing`. If you set [`onVerificationComplete`](#onverificationcomplete), `onComplete` fires after processing is done. Either way, always take the decision on your backend.

Results are usually available within 9 seconds, occasionally within 30 seconds. You can continue the applicant's journey and show the result later, or show a loading state while you wait.

See [Webhooks](https://docs.checkin.com/integrate/results/webhooks.md).

## onFail

Called when something goes wrong during the verification process. Receives `code` and `message`.

```javascript theme={null}
onFail: (data) => console.log(data.code, data.message)
```

| Code | When | Recommended handling |
| - | - | - |
| `apiurl_mismatch` | `apiUrl` was not passed to `init` | Integration error. Fix the configuration. |
| `token_mismatch` | No `jwt` and no `sdkKey`, the token request failed (also when the SDK key is invalid), or the token can't be read | Integration error. Check how you generate the token. |
| `token_malformed` | The JWT is malformed | Generate a new token and start again. |
| `token_invalid` | The token was rejected | Generate a new token and start again. |
| `token_expired` | The token has expired | Generate a new token and start again. |
| `session_not_found`, `session_completed` | The session doesn't exist or was already used | Create a new session and token. |
| `configuration_not_found`, `flow_not_found` | `flowName` doesn't exist for this account | Configuration error. Check `flowName`. |
| `customerid_exists` | An application with this customer ID already exists | Don't retry with the same customer ID. Look up the existing application instead. |
| `api_version_mismatch` | The SDK version isn't compatible with the API | Update the SDK. |

## onClose

When set, a close button is added. The callback fires when the applicant clicks it. Receives `code` and `message`.

## onBack

When set, a back button is added to the first screen. The callback fires when the applicant clicks it.

```javascript theme={null}
onBack: () => {
  console.log('onBack');
}
```

## onVerificationComplete

When set, the SDK waits for the verification result before it finishes:

1. After the applicant submits, the SDK keeps them on a wait screen and checks the application status every second.
2. When processing is done, it calls `onVerificationComplete` with the result.
3. The SDK shows the thank-you screen.
4. `onComplete` fires.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.