← Back to Blog
Tutorial2 min read

Adding Liveness Detection to Your Identity Verification Flow

Tutorial: add passive and active liveness detection to your identity verification system using a REST API — prevent spoofing in KYC and onboarding.

Why Add Liveness Detection?

Without liveness detection, your face verification system can be fooled by a printed photo or a screen displaying someone else's face. Liveness detection closes this vulnerability.

Option 1: Passive Liveness (Simplest)

Passive liveness requires no user interaction — just analyze the image:

python
import requests

response = requests.post(
    "https://faceapi.arsa.technology/api/v1/face_liveness",
    headers={"x-key-secret": "YOUR_API_KEY"},
    files={"face_image": open("selfie.jpg", "rb")}
)
result = response.json()
is_real = result["faces"][0]["is_real_face"]
confidence = result["faces"][0]["liveness_confidence"]

if not is_real:
    print("Spoofing detected! Rejecting verification.")

Learn more about how passive liveness works.

Option 2: Active Liveness (Higher Security)

Active liveness asks the user to perform head movements on video:

python
# Step 1: Request a challenge
challenge = requests.post(
    "https://faceapi.arsa.technology/api/v1/face_liveness_active/request?difficulty=medium",
    headers={"x-key-secret": "YOUR_API_KEY"}
).json()

instructions = challenge["instructions"]  # ["up", "left"]
job_uuid = challenge["job_uuid"]
print(f"Ask user to look: {', '.join(instructions)}")

# Step 2: Record video and submit
result = requests.post(
    f"https://faceapi.arsa.technology/api/v1/face_liveness_active/submit?job_uuid={job_uuid}",
    headers={"x-key-secret": "YOUR_API_KEY"},
    files={"video": open("recording.mp4", "rb")}
).json()

if result["passed"]:
    print("Liveness confirmed!")

Combining Liveness with Face Verification

The recommended flow for KYC onboarding:

python
# 1. Check liveness on the selfie
liveness = check_passive_liveness("selfie.jpg")
if not liveness["is_real"]:
    reject("Liveness check failed")

# 2. Compare selfie to ID photo
verification = verify_faces("selfie.jpg", "id_photo.jpg")
if not verification["match_result"]:
    reject("Face mismatch")

# 3. Approved!
approve_user()

Which Liveness Level to Use?

| Risk Level | Approach |

|-----------|----------|

| Low (newsletter signup) | No liveness needed |

| Medium (account creation) | Passive liveness |

| High (KYC, banking) | Passive + ID verification |

| Very high (regulated finance) | Active liveness + ID verification |

Read active vs passive liveness detection for a detailed comparison.

Start building with 100 free API calls, or read the docs.

Ready to get started?

Try ARSA Face Recognition API free with 100 API calls/month.

Start Free Trial