---
title: Receiving the result
canonical: https://developer.unico.io/dual-api/developers/sdks-and-tools/web/web-sdk/capture-flow/receiving-the-result
locale: en
generated_by: markdown-export
---

The SDK returns the capture result through the `callback` object passed to `open()`. Both `success` and `error` handlers are mandatory.

## Selfie capture

****`success`** (selfie)**

Called when the image is captured successfully. Receives an object with:

  - **`base64`** — captured image; can be used to display a preview in your application.
  - **`encrypted`** — JWT payload that must be sent to your backend to complete biometric validation via the REST API.

  ```javascript
  const callback = {
    on: {
      success: (obj) => {
        const base64 = obj.base64;
        const encrypted = obj.encrypted; // JWT to send to your backend
      },
      error: (error) => {
        console.error(error);
      }
    }
  };
  ```

  :::danger[`encrypted` usage]
  - The `encrypted` attribute is strictly intended for sending the image through the by Client APIs. It must not be opened, serialized, or modified — its characteristics may change without prior notice. It must be sent to the API within **10 minutes** of capture. Unico is not responsible for any damages resulting from improper handling.
  - The `base64`/`encrypted` files may vary in size depending on device quality, generated photo size, and Unico's business rules. **Do not limit the size** of the string generated by the SDK in your programming logic or infrastructure.
  :::

****`error`** (selfie)**

Called when an error occurs during capture. Receives an `ErrorBio` object with `getCode()` and `getDescription()`. See [Error handling](/dual-api/developers/sdks-and-tools/web/web-sdk/error-handling) for the full list of error codes.

  ```javascript
  error: (error) => {
    const code = error.getCode();
    const description = error.getDescription();
  }
  ```

## Document capture

****`success`** (document)**

Called when the document image is captured successfully. Receives an object with:

  - **`base64`** — captured image; can be used to display a preview.
  - **`encrypted`** — JWT payload that must be sent to your backend within **10 minutes** and must never be modified or deserialized.

  ```javascript
  const callback = {
    on: {
      success: (obj) => {
        const base64 = obj.base64;
        const encrypted = obj.encrypted;
      },
      error: (error) => { /* ... */ }
    }
  };
  ```

****`error`** (document)**

Called when an error occurs during document capture. Receives an `ErrorBio` object. See [Error handling](/dual-api/developers/sdks-and-tools/web/web-sdk/error-handling) for the full list of error codes.