API Documentation

Everything you need to integrate FaceGuard into your application.

Introduction

FaceGuard is a REST API that provides face recognition, liveness detection, and facial analysis. All endpoints accept multipart/form-data image uploads and return structured JSON.

High Performance

Sub-second response times. All models run in parallel.

Simple Auth

One API key header. No OAuth, no tokens to refresh.

Zero Retention

Images processed in memory and immediately discarded.

Base URL: https://api.faceguard.io

🔑 Authentication

All API requests require your API key in the X-API-Key request header.

X-API-Key: fg_live_your_key_here

⚠ Security Warning

Never expose API keys in client-side code, mobile apps, or public repositories. Always proxy requests through your own backend server.

Manage your API keys from your FaceGuard dashboard. Test keys are prefixed fg_test_ and limited to 50 requests.

⚡ Quickstart

Make your first API call in under 2 minutes. This example checks if a person is live and not a spoof.

cURL
curl -X POST https://api.faceguard.io/api/v1/liveness/check \
  -H "X-API-Key: fg_live_your_key_here" \
  -F "file=@selfie.jpg"
200 OKresponse.json
{
  "is_live": true,
  "confidence": 0.97,
  "spoof_type": null,
  "processing_time_ms": 420
}

⚡ Performance Tips

Response time is directly affected by image file size. Images under 500KB consistently respond within 1–2 seconds.

Image SizeTypical ResponseRecommendation
< 500 KB~1–2s✓ Optimal
500 KB – 1 MB~2–4s⚠ Consider compressing
> 1 MB4s+✗ Not recommended

⚠ Error Handling

FaceGuard uses standard HTTP status codes. All errors return a JSON body with detail containing the error information.

CodeMessageReason
400Bad RequestMissing file or invalid parameters
401UnauthorizedMissing or invalid API key
422UnprocessableNo face detected in the image
429Too Many RequestsMonthly request limit reached
500Server ErrorInternal processing error

GET /api/v1/health

Check that the FaceGuard API is online and responding. No API key required.

cURL
curl https://api.faceguard.io/api/v1/health
200 OKresponse.json
{ "status": "ok", "version": "1.0.0" }

POST /api/v1/liveness/check

Determine whether a face in an image is from a live person or a spoof attack. Fuses ONNX MiniFASNet and DeepFace with majority voting.

Parameters

filemultipart/form-data — face image (JPG, PNG, WebP)
cURL
curl -X POST https://api.faceguard.io/api/v1/liveness/check \
  -H "X-API-Key: fg_live_your_key_here" \
  -F "file=@face.jpg"
200 OKresponse.json
{
  "is_live": true,
  "confidence": 0.97,
  "spoof_type": null,
  "models": {
    "onnx": { "is_live": true, "score": 0.96 },
    "deepface": { "is_live": true, "score": 0.98 }
  },
  "processing_time_ms": 420
}

POST /api/v1/face/detect

Detect face presence and bounding boxes in an image.

cURL
curl -X POST https://api.faceguard.io/api/v1/face/detect \
  -H "X-API-Key: fg_live_your_key_here" \
  -F "file=@image.jpg"
200 OKresponse.json
{
  "faces_detected": 1,
  "faces": [{ "bbox": [120, 80, 280, 320], "confidence": 0.99 }]
}

POST /api/v1/face/verify

Compare two face images. Returns a verified/not-verified decision based on 4-model majority voting.

cURL
curl -X POST https://api.faceguard.io/api/v1/face/verify \
  -H "X-API-Key: fg_live_your_key_here" \
  -F "file1=@person_a.jpg" \
  -F "file2=@person_b.jpg"
200 OKresponse.json
{
  "verified": true,
  "confidence": 0.91,
  "models": {
    "ArcFace":    { "verified": true,  "distance": 0.28 },
    "Facenet512": { "verified": true,  "distance": 0.35 },
    "buffalo_l":  { "verified": true,  "distance": 0.31 },
    "buffalo_sc": { "verified": false, "distance": 0.42 }
  }
}

POST /api/v1/face/similarity

Return a similarity score (0–1) between two faces without a binary verdict.

cURL
curl -X POST https://api.faceguard.io/api/v1/face/similarity \
  -H "X-API-Key: fg_live_your_key_here" \
  -F "file1=@a.jpg" \
  -F "file2=@b.jpg"
200 OKresponse.json
{ "similarity": 0.84, "distance": 0.29, "threshold": 0.40 }

POST /api/v1/face/analyze

Extract age, gender, dominant emotion, and ethnicity from a single face image.

cURL
curl -X POST https://api.faceguard.io/api/v1/face/analyze \
  -H "X-API-Key: fg_live_your_key_here" \
  -F "file=@face.jpg"
200 OKresponse.json
{
  "age": 28,
  "gender": { "value": "Man", "confidence": 0.94 },
  "emotion": { "dominant": "happy", "scores": { "happy": 0.87, "neutral": 0.10 } },
  "ethnicity": { "dominant": "asian", "confidence": 0.76 }
}

POST /api/v1/face/enroll

Extract and return base64-encoded face embedding vectors for a user.

cURL
curl -X POST https://api.faceguard.io/api/v1/face/enroll \
  -H "X-API-Key: fg_live_your_key_here" \
  -F "file=@user_photo.jpg" \
  -F "user_id=emp_001"
200 OKresponse.json
{
  "user_id": "emp_001",
  "embeddings": {
    "ArcFace": "base64_encoded_vector...",
    "buffalo_l": "base64_encoded_vector..."
  },
  "face_detected": true
}

POST /api/v1/face/identify

Match a probe face against a list of enrolled users.

cURL
curl -X POST https://api.faceguard.io/api/v1/face/identify \
  -H "X-API-Key: fg_live_your_key_here" \
  -F "file=@probe.jpg" \
  -F 'candidates=[{"user_id":"emp_001","embeddings":{"ArcFace":"...","buffalo_l":"..."}}]'
200 OKresponse.json
{
  "matched": true,
  "best_match": { "user_id": "emp_001", "distance": 0.29, "threshold": 0.40 }
}

POST /api/v1/face/embeddings

Extract raw embedding vectors without enrolling a user.

cURL
curl -X POST https://api.faceguard.io/api/v1/face/embeddings \
  -H "X-API-Key: fg_live_your_key_here" \
  -F "file=@face.jpg"
200 OKresponse.json
{
  "embeddings": {
    "ArcFace": "base64_encoded_vector...",
    "buffalo_l": "base64_encoded_vector..."
  },
  "face_detected": true
}