---
updatedAt: 2025-09-16T00:57:20.000Z
agentTools:
  projectIndex: https://docs.verihubs.com/llms.txt
---

# Middleware

# Create Middleware

| Version      | 1.4.0                              |
| ------------ | ---------------------------------- |
| Owner        | PT Verihubs Inteligensia Nusantara |
| Release Date | 2 September 2024                   |
| Approved By  | Edwin Layani, Gisela Swastika      |

* [Overview](#overview)
  * [Technical Design](#technical-design)
* [Getting Started](#getting-started)
  * [Python](#python)

# Overview

Verihubs SDK makes verification easy. Find the documentation and sample code you need to build what you\
want exactly. We will handle the global regulations.

## Technical Design

The main purpose to build SDK Proxy is to isolate the credentials information from the client and combine it\
with your own business needs.

# Getting Started

Choose your programming language and dive in. We have got Quickstarts to get you integrate with our\
Liveness / Deepfake service in your app.

> For forwarding the response, please do not change the response value from Verihubs Liveness\
> Service. Additional json field might be added, so please ignore them while checking the\
> existing fields.

## Python

```python
# Import the required libraries, we are using fastapi for this example
import os
import requests

from fastapi import FastAPI
from fastapi.responses import Response
from fastapi import Request

# Find your Application ID and API Key at <https://app.verihubs.com>
# and set as the Environment variables.
VERIHUBS_APP_ID = os.getenv("VERIHUBS_APP_ID")
VERIHUBS_API_KEY = os.getenv("VERIHUBS_API_KEY")

# Create the POST Request for integrating with Verihubs Service.
# Forward exactly the response from the Verihubs Service to avoid invalid
schema exception.

app = FastAPI()

@app.post("/liveness")
async def liveness(
    request: Request
):
    request_body = await request.body()
    headers = dict(request.headers)
    response = requests.post(
        "https://api.verihubs.com/v1/face/liveness",
        headers={
            "Accept": "application/json",
            "Content-Type": "application/json",
            "App-ID": VERIHUBS_APP_ID,
            "Api-Key": VERIHUBS_API_KEY,
            "X-VH-SDKVER": headers.get("x-vh-sdkver"),
            "X-VH-CHECKSUM": headers.get("x-vh-checksum"),
            "X-Session-ID": headers.get("x-session-id"),
        },
        data=request_body,
    )
    return Response(
        status_code=response.status_code,
        headers=dict(response.headers),
        content=response.content,
    )

@app.post("/deepfake")
async def deepfake(request: Request):
    request_body = await request.body()
    headers = dict(request.headers)
    response = requests.post(
        "https://api.verihubs.com/v1/face/deepfake",
        headers={
            "Accept": "application/json",
            "Content-Type": "application/json",
            "App-ID": VERIHUBS_APP_ID,
            "Api-Key": VERIHUBS_API_KEY,
            "X-VH-PROCID": headers.get("x-vh-procid"),
            "X-VH-SDKVER": headers.get("x-vh-sdkver"),
            "X-VH-CHECKSUM": headers.get("x-vh-checksum"),
            "X-Session-ID": headers.get("x-session-id"),
        },
        data=request_body,
    )
    return Response(
        status_code=response.status_code,
        headers=dict(response.headers),
        content=response.content,
    )

@app.post("/{license_id}/check")
async def license(
    license_id: str,
    request: Request,
):
    response = requests.post(
        "https://api.verihubs.com/v1/license/{license_id}/check".format(license_id=license_id),
        headers={
            "App-ID": VERIHUBS_APP_ID,
            "Api-Key": VERIHUBS_API_KEY,
        },
        json=await request.json(),
    )
    return Response(
        status_code=response.status_code,
        headers=dict(response.headers),
        content=response.content,
    )

@app.post("/generate-key")
async def generate_key(
    request: Request
):
    response = requests.post(
        "https://api.verihubs.com/v1/encryption/generate-key",
        headers={
            "App-ID": VERIHUBS_APP_ID,
            "Api-Key": VERIHUBS_API_KEY,
        },
        json=await request.json(),
    )
    return Response(
        status_code=response.status_code,
        headers=dict(response.headers),
        content=response.content,
    )

```