Skip to main content

Liveness Detection

Check that a selfie comes from a live face, not a print or screen.

Base URL​

https://use.api.co.id

Send a selfie to POST /liveness/detect as multipart/form-data (field face1, optional reference_id) with the x-api-co-id header. The response contains transaction_id, result (whether liveness was detected), score, and the provider message.

Request fields​

FieldRequiredRule
face1yesSelfie photo JPG/JPEG/PNG, max 2 MB
reference_idnoCustomer reference, max 64 characters

You don't send transaction_id. API.CO.ID generates it automatically, forwards it to the provider as trId, and returns it in the response.

curl -X POST "https://use.api.co.id/liveness/detect" \
-H "x-api-co-id: YOUR_API_KEY" \
-F "face1=@/absolute/path/to/selfie.jpg" \
-F "reference_id=customer-reference-001"

Image guidance​

  • Use a clear photo of a human face.
  • Avoid backlit or overly dark images.
  • Use JPG, JPEG, or PNG.
  • Keep the file at 2 MB or less.
  • Avoid images containing multiple faces.

Results​

Liveness detected:

{
"is_success": true,
"message": "Success",
"data": {
"transaction_id": "LIVE20260815093000A1B2C3",
"result": true,
"score": "100.0000",
"message": "Liveness detection successfully"
}
}

Liveness not detected:

{
"is_success": true,
"message": "Success",
"data": {
"transaction_id": "LIVE20260815093000D4E5F6",
"result": false,
"score": "0.0000",
"message": "Liveness detection successfully"
}
}

result: false still returns HTTP 200 because the provider processed the request successfully; liveness just wasn't detected. It is a valid business result.

Access & billing​

API.CO.ID checks access in this order:

  1. Valid API key.
  2. Enough balance/subscription for liveness-detection.
  3. Customer eKYC approved.
  4. Request forwarded to the provider.
  5. Points charged if the provider processes the request.

If a request is rejected before reaching the provider (wrong API key, insufficient balance, KYC not approved, missing file, file too large, or unsupported file type), no points are charged.

Common errors​

HTTPCondition
400Bad Requestface1 file missing, empty, unsupported type, or invalid image
401UnauthorizedAPI key missing or wrong
402Payment RequiredInsufficient balance/subscription
403ForbiddeneKYC not approved, pending, rejected, or expired
413Payload Too Largeface1 file larger than 2 MB
422UnprocessableRequest rejected by provider validation
429Too Many RequestsProduct quota exhausted when a subscription quota is active
502Bad GatewayProvider auth/server/response error
503UnavailableProvider quota unavailable
504Gateway TimeoutProvider timeout
Was this page helpful?