POST /api/biometric/attendance

Submit worker check-in/check-out events with device information, health data, and automatic worker matching.

Authentication

All requests require an API key passed in one of these ways:

  • Header: X-API-Key: your_api_key
  • Query Parameter: ?api_key=your_api_key
Note: Contact your system administrator to obtain your API credentials.

Request Format

Single Event

Send a single attendance event:

{
  "scanId": "SCAN_001_20241201_001",
  "employeeId": "EMP001",
  "eventType": "check_in",
  "timestamp": "2024-12-01T08:30:00Z",
  "statusCode": 200,
  "temperature": 36.5,
  "maskDetected": true,
  "confidenceScore": 95.5
}

Batch Events

Send multiple events with device information:

{
  "device_info": {
    "device_id": "DEV001",
    "device_name": "Main Gate Scanner",
    "location": "Main Entrance",
    "temperature": 36.5,
    "mask_detected": true
  },
  "events": [
    {
      "scanId": "SCAN_001_20241201_001",
      "employeeId": "EMP001",
      "eventType": "check_in",
      "timestamp": "2024-12-01T08:30:00Z",
      "temperature": 36.5,
      "maskDetected": true
    },
    {
      "scanId": "SCAN_001_20241201_002",
      "employeeId": "EMP001",
      "eventType": "check_out",
      "timestamp": "2024-12-01T17:30:00Z",
      "temperature": 36.2,
      "maskDetected": true
    }
  ]
}

Parameters

Parameter Type Required Description
scanId string Yes Unique identifier for the biometric scan
employeeId string Yes Worker's employee ID or worker ID
eventType string Yes Either "check_in" or "check_out"
timestamp string Yes ISO 8601 timestamp of the event
statusCode integer No HTTP-like status code (default: 200)
temperature number No Body temperature reading in Celsius
maskDetected boolean No Whether a mask was detected
confidenceScore number No Biometric confidence score (0-100)

Response Format

Success Response

{
  "success": true,
  "message": "Attendance data processed successfully",
  "processed": 2,
  "successful": 2,
  "failed": 0,
  "results": [
    {
      "success": true,
      "message": "Attendance recorded successfully",
      "worker_id": "W001",
      "worker_name": "John Doe",
      "assignment_id": 123,
      "event_type": "check_in"
    },
    {
      "success": true,
      "message": "Attendance recorded successfully",
      "worker_id": "W001",
      "worker_name": "John Doe",
      "assignment_id": 123,
      "event_type": "check_out"
    }
  ]
}

Error Response

{
  "success": false,
  "message": "Processing failed: Missing required field: scanId"
}

Interactive Demo

Click "Test API" to see the response here

Code Examples

curl -X POST "https://your-domain.com/api/biometric/attendance" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your_api_key" \
  -d '{
    "events": [{
      "scanId": "SCAN_001_20241201_001",
      "employeeId": "EMP001",
      "eventType": "check_in",
      "timestamp": "2024-12-01T08:30:00Z",
      "temperature": 36.5,
      "maskDetected": true
    }]
  }'
const response = await fetch('/api/biometric/attendance', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'your_api_key'
  },
  body: JSON.stringify({
    device_info: {
      device_id: 'DEV001',
      device_name: 'Main Gate Scanner',
      location: 'Main Entrance'
    },
    events: [{
      scanId: 'SCAN_001_20241201_001',
      employeeId: 'EMP001',
      eventType: 'check_in',
      timestamp: new Date().toISOString(),
      temperature: 36.5,
      maskDetected: true
    }]
  })
});

const result = await response.json();
console.log(result);
import requests
import json
from datetime import datetime

url = "https://your-domain.com/api/biometric/attendance"
headers = {
    "Content-Type": "application/json",
    "X-API-Key": "your_api_key"
}

data = {
    "device_info": {
        "device_id": "DEV001",
        "device_name": "Main Gate Scanner",
        "location": "Main Entrance"
    },
    "events": [{
        "scanId": "SCAN_001_20241201_001",
        "employeeId": "EMP001",
        "eventType": "check_in",
        "timestamp": datetime.now().isoformat(),
        "temperature": 36.5,
        "maskDetected": True
    }]
}

response = requests.post(url, headers=headers, json=data)
result = response.json()
print(result)

Error Handling

HTTP Status Error Type Description
400 Bad Request Invalid JSON, missing required fields, or validation errors
401 Unauthorized Invalid or missing API key
405 Method Not Allowed Only POST requests are accepted
500 Internal Server Error Server-side processing error

Rate Limiting

Rate Limits:
  • Maximum 1000 requests per hour per API key
  • Maximum 10,000 requests per day per API key
  • Bulk operations limited to 100 events per request