Detección de Vitalidad
Endpoint
POST https://api.verifik.co/v2/face-recognition/liveness
Detecta si una imagen facial enviada proviene de una persona en vivo o de un spoof (foto, reproducción de pantalla, copia impresa). Retorna un puntaje de vitalidad y un resultado de aprobado/rechazado basado en un umbral de puntaje mínimo.
Headers
| Name | Value |
|---|---|
| Content-Type | application/json |
| Authorization | Bearer <token> |
Parámetros
| Name | Type | Required | Description |
|---|---|---|---|
os | string | Sí | Origen de captura. Sugerido: DESKTOP, IOS, ANDROID. |
image | string | Sí | Datos de imagen Base64 (data URI o base64 crudo). Si se proporciona una URL https, será descargada y convertida internamente. |
collection_id | string | No | Colección opcional para asociar con el intento de vitalidad. |
liveness_min_score | number | No | Umbral para aprobado/rechazado. Por defecto: 0.6. |
Solicitud
- Node.js
- PHP
- Python
- Go
const fetch = require("node-fetch");
async function run() {
const res = await fetch("https://api.verifik.co/v2/face-recognition/liveness", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.VERIFIK_TOKEN}`,
},
body: JSON.stringify({
os: "DESKTOP",
image: "<base64 or https url>",
liveness_min_score: 0.6,
}),
});
console.log(await res.json());
}
run();
<?php
$ch = curl_init("https://api.verifik.co/v2/face-recognition/liveness");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer " . getenv("VERIFIK_TOKEN")
]);
$body = json_encode([
"os" => "DESKTOP",
"image" => "<base64 or https url>",
"liveness_min_score" => 0.6
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
import os, requests
url = "https://api.verifik.co/v2/face-recognition/liveness"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {os.getenv('VERIFIK_TOKEN')}"
}
payload = {
"os": "DESKTOP",
"image": "<base64 or https url>",
"liveness_min_score": 0.6
}
r = requests.post(url, json=payload, headers=headers)
print(r.json())
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
payload := map[string]interface{}{
"os": "DESKTOP",
"image": "<base64 or https url>",
"liveness_min_score": 0.6,
}
b, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://api.verifik.co/v2/face-recognition/liveness", bytes.NewBuffer(b))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+os.Getenv("VERIFIK_TOKEN"))
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
var out map[string]interface{}
json.NewDecoder(resp.Body).Decode(&out)
fmt.Println(out)
}
Respuesta
- 200
- 401/403
- 409
- 500
{
"id": "JQ4RM",
"data": {
"passed": true,
"min_score": 0.6,
"liveness_score": 0.98
},
"signature": {
"message": "Certified by Verifik.co",
"dateTime": "January 16, 2024 3:44 PM"
}
}
{
"message": "Authentication required",
"code": "UNAUTHORIZED"
}
o
{
"message": "token_expired",
"code": "FORBIDDEN"
}
{
"message": "\"os\" is required",
"code": "MissingParameter"
}
{
"message": "internal_error",
"code": "ERROR"
}
Notas
- Asegúrate de que
Authorization: Bearer <token>esté presente; de lo contrario recibirás 401/403. imagepuede ser base64 o una URLhttps. Si es URL, el servicio la descarga y convierte internamente.- Aprobado/rechazado se determina por
liveness_score > min_score(elmin_scorepor defecto es 0.6, configurable vialiveness_min_score). - El
collection_idopcional se valida para el cliente autenticado.