# Using OzCapsula Data Container in Web SDK

In this mode, the SDK captures media from the user, packs all biometric and technical data into a **container** (`application/octet-stream`), and then either:

* uploads it directly to Oz API (architecture: **normal** for stateful API or **lite** for Instant), or
* returns it to your backend for forwarding (**capture** architecture).

## **Configuration Overview**

When enabling container mode, the key parameters are:

| **Parameter**            | **Value**                    | **Description**                                                   |
| ------------------------ | ---------------------------- | ----------------------------------------------------------------- |
| use\_wasm\_container     | true                         | Enables data container generation                                 |
| architecture             | `normal` / `lite`/ `capture` | Defines who sends the data to Oz API (Web SDK or your backend)    |
| api\_use\_session\_token | `api` / `client`             | Defines who retrieves the session token (Web SDK or your backend) |

## Session Token

#### `api_use_session_token: "client"`

In this mode, your **backend** obtains the session token before opening the Web SDK.

**Steps:**

1. Request a session token from Oz API:

```bash
curl --location '{{host}}/api/authorize/session_token' \
  -H 'X-Forensic-Access-Token: <YOUR_TOKEN>'
```

2. The response will contain a short-term `session_token`:

```bash
{
  "session_token": "eyJh..."
}
```

3. Pass this token to the Web SDK Plugin:

```php
OzLiveness.open({
  session_token,
  // other open options
});
```

{% hint style="info" %}
The session token is valid only for a few minutes and must be requested before each capture session.
{% endhint %}

#### `api_use_session_token: "api"`

In this mode, the SDK automatically retrieves the session token directly from Oz API.\
You don’t need to request or provide it manually.

## Flow for Different Architectures

The flow is different depending on your architecture type.

#### `architecture: "normal"`

In this mode, the Web SDK **automatically uploads** the generated container to Oz API.\
You do **not** need to handle any upload manually.

#### `architecture: "lite"`

In this mode, the Web SDK **automatically uploads** the generated container to Oz API.\
You do **not** need to handle any upload manually.

#### `architecture: "capture"`

In this mode, **Web SDK only captures and packs data**, but **does not send it** to the Oz API.

Your backend is responsible for receiving the container and forwarding it to Oz API.

**Flow:**

1. Web SDK performs video capture and calls the `on_capture_complete(result, container)` callback, where the second argument (`container`) is a **Blob** object (`application/octet-stream`).
2. You send this blob to your backend.
3. Your backend sends it to Oz API using an HTTPS POST request.

**Example request:**

```bash
curl -X POST \
  '{{host}}/api/folders' \
  -H 'Content-Type: application/octet-stream' \
  -H 'X-Forensic-Access-Token: <YOUR_TOKEN>' \
  --data-binary '@/path/to/container.dat'
```

The response will be similar to the one from the non-container flow.

## Possible Errors

| **Error**                                                                                                                               | **Description**                                  |
| --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| error\_wasm\_internal\_failure\_1                                                                                                       | The device or browser used doesn’t support WASM  |
| error\_wasm\_internal\_failure\_2                                                                                                       | The device doesn’t have enough memory to proceed |
| <ul><li>error\_wasm\_internal\_failure\_3</li><li>error\_wasm\_internal\_failure\_4</li><li>error\_wasm\_internal\_failure\_5</li></ul> | SDK couldn’t generate the container. Try again   |
| error\_wasm\_internal\_failure\_1000                                                                                                    | Any other error not from the list above          |


---

# 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://doc.ozforensics.com/oz-knowledge/guides/developer-guide/sdk/oz-liveness-websdk/using-ozcapsula-data-container-in-web-sdk.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.
