# OzCapsula Data Container

## Configuring Oz API

The main change in interaction with API is that you require to send data with another content type, as data container is a binary file: `Content-Type` = `application/octet-stream`. We've added support for this content type along with container functionality.

Also, Instant API now requires client’s private and public keys to function. The paths to these keys should be specified in `OZ_JWT_PRIVATE_KEY_PATH` and `OZ_JWT_PUBLIC_KEY_PATH` in the configuration file.

To generate them, use commands as listed below.

```bash
# Generate private key:
openssl ecparam -name secp384r1 -genkey -noout | openssl pkcs8 -topk8 -nocrypt -out ./jwt.key
# Generate public key:
openssl ec -in ./jwt.key -pubout -out ./jwt.pub
```

### Examples

`POST api/folders`:

```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'
```

`POST api/instant/folders`:

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

### **Exceptions**

| **Error code** | **Error message**                                                                                                                                                             | **Description**                                                  |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| 13             | No data container provided                                                                                                                                                    | API didn’t receive the container                                 |
| 14             | <ul><li>Data container unpacking failed</li><li>Invalid Data Container</li><li>Invalid signature</li><li>Invalid SummingHash</li><li>Invalid or empty Session Token</li></ul> | The container appears to contain errors and can’t be unpackaged. |

## Obtaining a Session Token

Before you start with SDK, obtain a session token:

1. (Optional, only if you use stateful API) Authorize as any non-OPERATOR role.
2. Call `GET {{host}}/api/authorize/session_token`.

**Example request**

```bash
curl -L 'https://{{host}}/api/authorize/session_token' \
-H 'X-Forensic-Access-Token: <token>' \
-H 'Content-Type: application/json'
```

**Example response**

```bash
{
    "session_token": "<session_token>"
}
```

<figure><img src="https://2532558063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5g6dgsxRbyrCvB0uAf8f%2Fuploads%2FJ5Q2cNvuJyoh0C3p6EoG%2Fsession%20token.png?alt=media&#x26;token=8579a2cf-ebca-4f1d-8061-094b3c4e5ce7" alt=""><figcaption></figcaption></figure>
