Developer ResourcesAiFace Protocol Documentation
Download PDF

AiFace BS Communication Protocol Documentation

This document defines the communication specification between AiFace facial recognition devices and backend servers. The core feature is a unified JSON command set that operates over three transport layers: WebSocket, MQTT, and HTTP.

⚠️ Protocol Role Note: In the BS communication protocol, the device acts as a client that actively connects to the backend server; the server acts as the service endpoint, receiving and responding to the device's connections and requests. Therefore, the BS protocol supports Wide Area Network (WAN) deployment — devices can communicate with remote servers across network segments and geographic locations.
🔴 Transport Recommendation: WebSocket (WS/WSS) is strongly recommended. MQTT/MQTTS and HTTP/HTTPS are not recommended for the following reasons:
- WebSocket (WS/WSS): Long-lived connection, server can push commands in real time with lowest latency and minimal resource usage. This is the preferred solution.
- HTTP/HTTPS: Short-lived connections with no push capability. Devices must rely on heartbeat polling to fetch commands, which severely consumes device memory and CPU resources, while also placing heavy load on the server. Real-time performance cannot be guaranteed.
- MQTT/MQTTS: Requires deploying an additional MQTT Broker server, increasing deployment complexity and operational costs, with real-time performance inferior to direct WebSocket connections.

1. Transport Protocol Specifications

1.1 WebSocket / WSS (WebSocket Secure)

Connection URL Format:

ws://<server_ip>:<port>/<path>
wss://<server_ip>:<port>/<path>

Default Configuration:

Authentication Flow:

  1. Device initiates TCP/TLS connection to the server
  2. On MG_EV_WS_OPEN event, device immediately sends the reg command (Device Registration)
  3. Server responds with ret="reg" containing authorization result and time sync
  4. If authorization succeeds, reg_success = TRUE; device begins normal operations

Data Format:

Heartbeat Mechanism:

Reconnection Logic:


2. Protocol Differences Summary

FeatureWebSocket / WSSHTTP / HTTPSMQTT / MQTTS
Connection TypeLong-lived persistentShort-lived per requestLong-lived persistent
HeartbeatPING/PONG frames (10s interval, 30s timeout)checklive command pollingMQTT KeepAlive (60s)
Data Sendingmg_ws_sendHTTP POST bodymg_mqtt_pub
Data ReceivingMG_EV_WS_MSG eventHTTP response bodyMG_EV_MQTT_MSG event
Subscribe TopicN/AN/Aaiface//pub
Publish TopicN/AN/Aaiface//sub
RegistrationSent on WS openSent on HTTP connectSent on MQTT open
QoSN/AN/ALevel 1 (default)

3. JSON Command Format

3.1 General Request Format

JSON{
  "cmd": "<command_name>",
  "sn": "<device_serial_number>",
  ...additional parameters...
}

3.2 General Response Format

Success:

JSON{
  "ret": "<command_name>",
  "sn": "<device_serial_number>",
  "result": true,
  ...additional fields...
}

Failure:

JSON{
  "ret": "<command_name>",
  "sn": "<device_serial_number>",
  "result": false,
  "reason": <error_code>,
  "msg": "<error_message>"
}

3.3 Error Codes (reason field)

Different commands use different error code systems. Common patterns:

reason valueMeaning
1Generic failure / parameter error
2MD5/check error
3Operation failed
4Invalid format
5No data / not found
6-12Specific validation failures

4. backupnum Reference Table

The backupnum field identifies the type of biometric or credential data associated with a user.

backupnumData TypeEncodingDescription
0-9Fingerprinthex (with 0 compression)Fingerprint slot N (0=first finger, 1=second, etc.). Requires a fingerprint model. Each finger: ~810 bytes.
10PasswordnumberUser PIN/password
11Card NumbernumberRFID card number
40Palm Vein (left)base64Left palm vein. Requires a palm vein model
41Palm Vein (right)base64Right palm vein. Requires a palm vein model
50Face Photobase64 (JPG)Face photo image. Used when bFace_template = 0
51Face Featurebase64 (02 30 + feat)Face feature template. Used when bFace_template = 1

Fingerprint 0-Compression Format:

Fingerprint data uses a special compression scheme. Consecutive 0x00 bytes are encoded as (N) where N is the count:


5. Device Registration — `reg` Command

5.1 Device → Server (Registration Request)

Also known as Active_send_reg. The device sends this command automatically immediately after establishing a connection (WS open, HTTP connect, or MQTT open).

Request Example:

JSON{
  "cmd": "reg",
  "sn": "LF00000001",
  "devinfo": {
    "modelname": "AiFace",
    "manufacturer": "AiFace Inc.",
    "usersize": 10000,
    "facesize": 10000,
    "avatarsize": 0,
    "fpsize": 10000,
    "palmsize": 10000,
    "cardsize": 10000,
    "pwdsize": 10000,
    "logsize": 300000,
    "useduser": 100,
    "usedface": 50,
    "usedavatar": 0,
    "usedfp": 20,
    "usedpalm": 0,
    "usedcard": 10,
    "usedpwd": 5,
    "usedlog": 1000,
    "usednewlog": 500,
    "usedrtlog": 3,
    "netinuse": 1,
    "usb4g": 0,
    "fpalgo": "thbio3.0",
    "firmware": "1.0.0",
    "time": "2025-01-01 08: 00: 00",
    "intercom": 0,
    "floors": 0,
    "acces_stimes": 0,
    "charid": 0,
    "useosdp": 0,
    "facetemplate": 0,
    "dislanguage": 0,
    "curip": "192.168.001.100",
    "ntp": 1,
    "timezone": "UTC+8",
    "cpu_temp": 45,
    "bandwidth_up": "100Kbps",
    "bandwidth_down": "1Mbps",
    "battery": 100,
    "disksize": 1024.0,
    "useddisk": 512.0,
    "mac": "AA-BB-CC-DD-EE-FF"
  }
}

devinfo Field Descriptions:

FieldTypeDescription
modelnamestringDevice model name (e.g., "AiFace")
manufacturerstringManufacturer name
usersizenumberMaximum number of users
facesizenumberMaximum face templates
avatarsizenumberMaximum avatar photos
fpsizenumberMaximum fingerprints
palmsizenumberMaximum palm veins
cardsizenumberMaximum card numbers
pwdsizenumberMaximum passwords
logsizenumberMaximum log records
usedusernumberCurrently enrolled users
usedfacenumberUsed face templates
usedavatarnumberUsed avatar photos
usedfpnumberUsed fingerprints
usedpalmnumberUsed palm veins
usedcardnumberRegistered cards
usedpwdnumberRegistered passwords
usedlognumberStored log records
usednewlognumberNew (unread) log records
usedrtlognumberReal-time log records
netinusenumberNetwork in use (1=wired, 2=wifi, 3=4g)
usb4gnumberUSB 4G module status (0=not used, 1=used)
fpalgostringFingerprint algorithm version
firmwarestringFirmware version
timestringDevice current time "YYYY-MM-DD HH:MM:SS"
intercomnumberVideo intercom capability (0=none, 1=supported)
floorsnumberNumber of floors (for elevator control)
acces_stimesnumberAccess times limit
charidnumberCharacter ID / encoding
useosdpnumberOSDP protocol support
facetemplatenumberFace template format (0=photo, 1=feature)
dislanguagenumberDisplay language setting
curipstringCurrent IP address
ntpnumberNTP enabled flag
timezonestringTimezone (e.g., "UTC+8")
cpu_tempnumberCPU temperature (Celsius)
bandwidth_upstringUpload bandwidth
bandwidth_downstringDownload bandwidth
batterynumberBattery level (%)
disksizenumberStorage size (MB)
useddisknumberUsed storage (MB)
macstringMAC address

5.2 Server → Device (Registration Response)

Success Response:

JSON{
  "ret": "reg",
  "tryseconds": 10,
  "result": true,
  "cloudtime": "2025-01-01 08: 00: 00",
  "nosenduser": false,
  "nosendlog": false,
  "nosendimage": false
}
FieldTypeDescription
trysecondsnumberPeriodic re-registration interval (seconds)
resultbooleanAuthorization result
cloudtimestringServer time for synchronization
nosenduserbooleanIf true, device should not send user change notifications
nosendlogbooleanIf true, device should not send log records
nosendimagebooleanIf true, device should not send images in logs

Failure Response:

JSON{
  "ret": "reg",
  "tryseconds": 30,
  "result": false,
  "reason": "Device not authorized"
}

Periodic Re-registration:


6. User Management Commands

6.1 setuserinfo — Set User Information

Downloads and sets user profile information including biometrics.

Request Parameters:

ParameterTypeDescription
enrollidnumber/stringUser ID
aliasidstringUser alias ID
birthdaystringBirthday "MM-DD" or "MM-DD*"
verifymodenumberVerification mode (values in Appendix B)
cardnumber/stringRFID card number
pwdnumberPassword
shiftidnumberShift ID
zoneidnumberTime zone ID
groupidnumberGroup ID
access_timesnumberMaximum access times (max 30000)
postidnumberPosition/Post ID
departmentstringDepartment name (auto-converted to postid)
enablenumberEnable flag (1=enabled, 0=disabled)
starttimestringValidity start "YYYY-MM-DD HH:MM:SS"
endtimestringValidity end "YYYY-MM-DD HH:MM:SS"
backupnumnumberBiometric data type (see backupnum table)
adminnumberAdmin privilege level
namestringUser name
userprofilestringCustom user profile (JSON string)
recordstring/numberBiometric data (base64 or hex per backupnum type)

Request Example:

JSON{
  "cmd": "setuserinfo",
  "sn": "LF00000001",
  "enrollid": 123,
  "aliasid": "USR001",
  "name": "John Doe",
  "birthday": "01-15",
  "verifymode": 0,
  "card": 12345,
  "pwd": 0,
  "shiftid": 0,
  "zoneid": 0,
  "groupid": 0,
  "access_times": 0,
  "postid": 1,
  "department": "Engineering",
  "enable": 1,
  "starttime": "2025-01-01 00: 00: 00",
  "endtime": "2025-12-31 23: 59: 59",
  "backupnum": 50,
  "admin": 0,
  "userprofile": "{}",
  "record": "base64_encoded_face_data"
}

Success Response:

JSON{
  "ret": "setuserinfo",
  "enrollid": 123,
  "sn": "LF00000001",
  "backupnum": 50,
  "result": true,
  "aliasid": "USR001"
}

Failure Response:

JSON{
  "ret": "setuserinfo",
  "enrollid": 123,
  "sn": "LF00000001",
  "backupnum": 50,
  "result": false,
  "reason": 1,
  "msg": "space overflow",
  "aliasid": "USR001"
}

6.2 deleteuser — Delete User

Deletes a user or specific biometric data for a user.

Request Parameters:

ParameterTypeDescription
enrollidnumber/stringUser ID
aliasidstringUser alias ID
backupnumnumberData type to delete

backupnum Values for Deletion:

Request Example:

JSON{
  "cmd": "deleteuser",
  "sn": "LF00000001",
  "enrollid": 123,
  "aliasid": "USR001",
  "backupnum": 12
}

Success Response:

JSON{
  "ret": "deleteuser",
  "enrollid": 123,
  "sn": "LF00000001",
  "backupnum": 12,
  "result": true,
  "aliasid": "USR001"
}

6.3 cleanuser — Clear All Users

Deletes all users from the device. No parameters.

Request Example:

JSON{
  "cmd": "cleanuser",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "cleanuser",
  "sn": "LF00000001",
  "result": true
}

6.4 setusername — Batch Set User Names

Request Parameters:

ParameterTypeDescription
countnumberNumber of records
birthdaystringBirthday (applied globally)
recordarrayArray of {enrollid, aliasid, name, verifymode}

Request Example:

JSON{
  "cmd": "setusername",
  "sn": "LF00000001",
  "count": 2,
  "birthday": "06-15",
  "record": [
    {"enrollid": 100, "aliasid": "U100", "name": "Alice", "verifymode": 0},
    {"enrollid": 101, "aliasid": "U101", "name": "Bob", "verifymode": 0}
  ]
}

Success Response:

JSON{
  "ret": "setusername",
  "sn": "LF00000001",
  "result": true
}

Failure Response:

JSON{
  "ret": "setusername",
  "sn": "LF00000001",
  "result": false,
  "reason": 1,
  "msg": "set username fail"
}

6.5 getusername — Get User Name

Request Parameters:

ParameterTypeDescription
enrollidnumber/stringUser ID
aliasidstringUser alias ID

Request Example:

JSON{
  "cmd": "getusername",
  "sn": "LF00000001",
  "enrollid": 123,
  "aliasid": "USR001"
}

Success Response:

JSON{
  "ret": "getusername",
  "sn": "LF00000001",
  "result": true,
  "record": "John Doe"
}

Failure Response:

JSON{
  "ret": "getusername",
  "sn": "LF00000001",
  "result": false,
  "reason": 1,
  "msg": "can not find this name"
}

6.6 getuserlist — Get User ID List (Paginated)

Retrieves a paginated list of user IDs. Use stn=1 to reset pagination and start a new query.

Request Parameters:

ParameterTypeDescription
stnnumber1 = start new query (reset pagination index)

Pagination Behavior:

Request Example:

JSON{
  "cmd": "getuserlist",
  "sn": "LF00000001",
  "stn": 1
}

Success Response (with data):

JSON{
  "ret": "getuserlist",
  "sn": "LF00000001",
  "result": true,
  "count": 500,
  "from": 0,
  "to": 100,
  "record": [
    {"enrollid": 123, "admin": 0, "backupnum": 50, "enable": 1, "aliasid": "USR001"},
    {"enrollid": 124, "admin": 1, "backupnum": 51, "enable": 1, "aliasid": "USR002"}
  ]
}

Success Response (empty):

JSON{
  "ret": "getuserlist",
  "sn": "LF00000001",
  "result": true,
  "count": 0,
  "from": 0,
  "to": 0,
  "record": []
}

6.7 getuserids — Get All User IDs

Returns all user IDs in a single response (no pagination).

Request Parameters:

None.

Request Example:

JSON{
  "cmd": "getuserids",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "getuserids",
  "sn": "LF00000001",
  "result": true,
  "count": 100,
  "record": ["123", "456", "USR001", "USR002"]
}
Returns user IDs as strings. Alias IDs are used when available, otherwise numeric ID strings.

6.8 getunuserdid — Get Next Available User ID

Returns the next available unused user ID.

Request Parameters:

None.

Request Example:

JSON{
  "cmd": "getunuserdid",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "getunuserdid",
  "sn": "LF00000001",
  "result": true,
  "enrollid": "100"
}

6.9 checkuserid — Check If User ID Exists

Request Parameters:

ParameterTypeDescription
enrollidnumber/stringUser ID or alias ID to check

Request Example:

JSON{
  "cmd": "checkuserid",
  "sn": "LF00000001",
  "enrollid": 123
}

Success Response (exists):

JSON{
  "ret": "checkuserid",
  "sn": "LF00000001",
  "result": true,
  "exists": true
}

Success Response (not found):

JSON{
  "ret": "checkuserid",
  "sn": "LF00000001",
  "result": true,
  "exists": false
}

6.10 getuserinfo — Get User Detailed Information

Request Parameters:

ParameterTypeDescription
enrollidnumber/stringUser ID
aliasidstringUser alias ID
backupnumnumber(Optional) Specific biometric type to retrieve

Without backupnum — returns full user profile (without raw biometric data):

Request Example:

JSON{
  "cmd": "getuserinfo",
  "sn": "LF00000001",
  "enrollid": 123,
  "aliasid": "USR001"
}

Success Response:

JSON{
  "ret": "getuserinfo",
  "result": true,
  "sn": "LF00000001",
  "enrollid": 123,
  "name": "John Doe",
  "department": "Engineering",
  "admin": 0,
  "aliasid": "USR001",
  "photourl": "/photos/LF00000123.jpg",
  "card": 12345,
  "pwd": 0,
  "fpflag": 3,
  "fpcnt": 2,
  "palmflag": 0,
  "palmcnt": 0,
  "faceflag": 1,
  "enable": 1,
  "birthday": "01-15",
  "shiftid": 0,
  "verifymode": 0,
  "zoneid": 0,
  "groupid": 0,
  "access_times": 0,
  "postid": 1,
  "starttime": "2025-01-01 00: 00: 00",
  "endtime": "2025-12-31 23: 59: 59",
  "userprofile": "{}"
}

With backupnum — returns raw biometric data:

backupnumReturns
0-9Fingerprint data (hex)
10Password (number)
11Card number (number)
50Face photo (base64 JPG)
51Face feature (base64)

Request Example (face photo):

JSON{
  "cmd": "getuserinfo",
  "sn": "LF00000001",
  "enrollid": 123,
  "aliasid": "USR001",
  "backupnum": 50
}

Success Response:

JSON{
  "ret": "getuserinfo",
  "result": true,
  "sn": "LF00000001",
  "enrollid": 123,
  "name": "John Doe",
  "backupnum": 50,
  "record": "base64_encoded_face_photo_data"
}

Failure Response:

JSON{
  "ret": "getuserinfo",
  "result": false,
  "sn": "LF00000001",
  "enrollid": 123,
  "reason": 1,
  "msg": "can not find this user",
  "aliasid": "USR001"
}

6.11 getallusers — Get All User Data (Paginated, Multi-Record)

Returns all user data in paginated format. Each user may return multiple records (one per biometric type). Use stn=true to start a new query.

Request Parameters:

ParameterTypeDescription
stnbooleantrue = start new query (reset pagination)

Request Example:

JSON{
  "cmd": "getallusers",
  "sn": "LF00000001",
  "stn": true
}

Response (password record, backupnum=10):

JSON{
  "ret": "getallusers",
  "sn": "LF00000001",
  "result": true,
  "count": 500,
  "index": 0,
  "enrollid": 123,
  "backupnum": 10,
  "admin": 0,
  "enable": 1,
  "record": 12345,
  "aliasid": "USR001"
}

Response (card record, backupnum=11):

JSON{
  "ret": "getallusers",
  "sn": "LF00000001",
  "result": true,
  "count": 500,
  "index": 1,
  "enrollid": 123,
  "backupnum": 11,
  "admin": 0,
  "enable": 1,
  "record": 1234567890,
  "aliasid": "USR001"
}

Response (face photo, backupnum=50):

JSON{
  "ret": "getallusers",
  "sn": "LF00000001",
  "result": true,
  "count": 500,
  "index": 2,
  "enrollid": 123,
  "backupnum": 50,
  "admin": 0,
  "enable": 1,
  "record": "base64_jpg_data",
  "aliasid": "USR001"
}

Response (face feature, backupnum=51):

JSON{
  "ret": "getallusers",
  "sn": "LF00000001",
  "result": true,
  "count": 500,
  "index": 3,
  "enrollid": 123,
  "backupnum": 51,
  "admin": 0,
  "enable": 1,
  "record": "base64_feat_data",
  "aliasid": "USR001"
}

Response (fingerprint, backupnum=0):

JSON{
  "ret": "getallusers",
  "sn": "LF00000001",
  "result": true,
  "count": 500,
  "index": 5,
  "enrollid": 123,
  "backupnum": 0,
  "admin": 0,
  "enable": 1,
  "record": "hex_fp_data",
  "aliasid": "USR001"
}

Response (palm vein, backupnum=40):

JSON{
  "ret": "getallusers",
  "sn": "LF00000001",
  "result": true,
  "count": 500,
  "index": 10,
  "enrollid": 123,
  "backupnum": 40,
  "admin": 0,
  "enable": 1,
  "record": "base64_palm_data",
  "aliasid": "USR001"
}

Failure Response:

JSON{
  "ret": "getallusers",
  "sn": "LF00000001",
  "backupnum": 50,
  "result": false,
  "reason": 1,
  "msg": "this photo is too big"
}

6.12 adduser — Add User (Device-Side Registration)

Initiates user enrollment on the device. The device processes biometric capture and reports progress.

Request Parameters:

ParameterTypeDescription
cancelbooleantrue = cancel the enrollment process
enrollidnumber/stringUser ID
aliasidstringUser alias ID
backupnumnumberEnrollment type: 0-9(fingerprint), 10(password), 11(card), 40/41(palm), 50(face)
adminnumberAdmin privilege level
flagnumberFlags
namestringUser name

Request Example (start enrollment):

JSON{
  "cmd": "adduser",
  "sn": "LF00000001",
  "enrollid": 123,
  "aliasid": "USR001",
  "backupnum": 50,
  "admin": 0,
  "flag": 0,
  "name": "John Doe"
}

Success Response:

JSON{
  "ret": "adduser",
  "enrollid": 123,
  "sn": "LF00000001",
  "backupnum": 50,
  "result": true,
  "aliasid": "USR001"
}

Failure Response:

JSON{
  "ret": "adduser",
  "enrollid": 123,
  "sn": "LF00000001",
  "backupnum": 50,
  "result": false,
  "reason": 1,
  "msg": "userid can not empty"
}

Cancel Enrollment:

JSON{
  "cmd": "adduser",
  "sn": "LF00000001",
  "cancel": true
}

Cancel Response:

JSON{
  "ret": "adduser",
  "result": true,
  "cancel": true
}

6.13 checkregstatus — Check Device-Side Registration Status

Queries the current enrollment progress on the device.

Request Parameters:

None.

Request Example:

JSON{
  "cmd": "checkregstatus",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "checkregstatus",
  "sn": "LF00000001",
  "result": true,
  "status": 1,
  "msg": "Enrollment progress message",
  "image": "base64..."
}
status: 0 = waiting, >=0 = success (value corresponds to backupnum), <0 = failure

6.14 canceladduser — Cancel User Enrollment

Cancels the current user enrollment process. No parameters.

Request Example:

JSON{
  "cmd": "canceladduser",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "canceladduser",
  "result": true
}

6.15 enableuser — Enable/Disable User

Request Parameters:

ParameterTypeDescription
enrollidnumber/stringUser ID
aliasidstringUser alias ID
enflagbooleantrue = enable, false = disable

Request Example:

JSON{
  "cmd": "enableuser",
  "sn": "LF00000001",
  "enrollid": 123,
  "aliasid": "USR001",
  "enflag": false
}

Success Response:

JSON{
  "ret": "enableuser",
  "enrollid": 123,
  "sn": "LF00000001",
  "result": true,
  "aliasid": "USR001"
}

6.16 getuserprofile — Get User Custom Profile

Request Parameters:

ParameterTypeDescription
enrollidnumber/stringUser ID
aliasidstringUser alias ID

Request Example:

JSON{
  "cmd": "getuserprofile",
  "sn": "LF00000001",
  "enrollid": 123,
  "aliasid": "USR001"
}

Success Response:

JSON{
  "ret": "getuserprofile",
  "sn": "LF00000001",
  "result": true,
  "record": "{...json...}"
}

Failure Response:

JSON{
  "ret": "getuserprofile",
  "sn": "LF00000001",
  "result": false,
  "reason": 1,
  "msg": "userprofile can not empty"
}

6.17 setuserprofile — Set User Custom Profile

Request Parameters:

ParameterTypeDescription
enrollidnumber/stringUser ID
aliasidstringUser alias ID
profilestringConfiguration JSON string
durationnumberDisplay duration (only when nID=0)
colornumberColor (only when nID=0)

Request Example:

JSON{
  "cmd": "setuserprofile",
  "sn": "LF00000001",
  "enrollid": 123,
  "aliasid": "USR001",
  "profile": "{\"key\": \"value\"}",
  "duration": 5,
  "color": 1
}

Success Response:

JSON{
  "ret": "setuserprofile",
  "enrollid": 123,
  "sn": "LF00000001",
  "result": true,
  "aliasid": "USR001"
}

Failure Response:

JSON{
  "ret": "setuserprofile",
  "enrollid": 123,
  "sn": "LF00000001",
  "result": false,
  "reason": 1,
  "msg": "setuserprofile fail"
}

7. Log Management Commands

7.1 getnewlog — Get New Records

Retrieves new (unread) attendance/access log records with pagination.

Request Parameters:

ParameterTypeDescription
stnnumber1 = start new query (reset index)
logphotonumber1 = include photo data in logs

Request Example:

JSON{
  "cmd": "getnewlog",
  "sn": "LF00000001",
  "stn": 1,
  "logphoto": 1
}

Success Response:

JSON{
  "ret": "getnewlog",
  "sn": "LF00000001",
  "result": true,
  "count": 500,
  "from": 0,
  "to": 100,
  "record": [
    {
      "enrollid": 123,
      "name": "John Doe",
      "time": "2025-01-01 08: 00: 00",
      "mode": 1,
      "inout": 0,
      "event": 0,
      "aliasid": "USR001",
      "image": "base64...",
      "note": ""
    }
  ]
}

Empty Response:

JSON{
  "ret": "getnewlog",
  "sn": "LF00000001",
  "result": true,
  "count": 0,
  "from": 0,
  "to": 0,
  "record": []
}

Record Fields:

FieldTypeDescription
enrollidnumberUser ID
namestringUser name
timestringEvent time "YYYY-MM-DD HH:MM:SS"
modenumberVerification mode (1=face, 2=fingerprint, 4=card, 8=password, etc.)
inoutnumberDirection (0=in, 1=out)
eventnumberEvent type
aliasidstringUser alias ID
imagestringPhoto base64 (if logphoto=1)
notestringNote/comment

7.2 getalllog — Get All Records

Retrieves all log records with optional filtering and pagination.

Request Parameters:

ParameterTypeDescription
stnnumber1 = start new query
enrollidnumber/string(Optional) Filter: number = by user ID; string = by alias ID (aliasid)
fromstringStart date "YYYY-MM-DD"
tostringEnd date "YYYY-MM-DD"
logphotonumber1 = include photo data

Request Example:

JSON{
  "cmd": "getalllog",
  "sn": "LF00000001",
  "stn": 1,
  "enrollid": 123,
  "from": "2025-01-01",
  "to": "2025-12-31",
  "logphoto": 0
}

Success Response:

JSON{
  "ret": "getalllog",
  "sn": "LF00000001",
  "result": true,
  "count": 1000,
  "from": 0,
  "to": 100,
  "record": [
    {
      "enrollid": 123,
      "name": "John Doe",
      "time": "2025-01-01 08: 00: 00",
      "mode": 1,
      "inout": 0,
      "event": 0,
      "aliasid": "USR001",
      "image": "base64...",
      "note": ""
    }
  ]
}

7.3 cleanlog — Clear All Logs

Deletes all log records from the device. No parameters.

Request Example:

JSON{
  "cmd": "cleanlog",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "cleanlog",
  "sn": "LF00000001",
  "result": true
}

7.4 cleanlogphoto — Clear Log Photos

Deletes all photos associated with log records. No parameters.

Request Example:

JSON{
  "cmd": "cleanlogphoto",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "cleanlogphoto",
  "sn": "LF00000001",
  "result": true
}

8. Device Management Commands

8.1 getdevinfo — Get Device System Parameters

Reads all system parameters. No parameters.

Request Example:

JSON{
  "cmd": "getdevinfo",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "getdevinfo",
  "sn": "LF00000001",
  "result": true,
  "param1": "value1",
  "param2": "value2"
}
Returns all parameters from DI_FIRST to DI_END enumeration as key-value pairs.

8.2 setdevinfo — Set Device System Parameters

Sets one or more system parameters.

Request Parameters:

ParameterTypeDescription
nowtimenumberCurrent Unix timestamp (seconds)
(dynamic)variesAny parameter from DI_FIRST~DI_END enumeration as key-value pairs

Request Example:

JSON{
  "cmd": "setdevinfo",
  "sn": "LF00000001",
  "nowtime": 1735689600,
  "DI_SERVERIP": "192.168.1.100",
  "DI_SERVERPORT": 7788
}

Success Response:

JSON{
  "ret": "setdevinfo",
  "sn": "LF00000001",
  "result": true
}
Note: Modifying domain name, IP, or port parameters triggers a connection re-establishment (need_close_connection = TRUE).

8.3 getdevcap — Get Device Capacity

Returns device storage capacity information. No parameters.

Request Example:

JSON{
  "cmd": "getdevcap",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "getdevcap",
  "sn": "LF00000001",
  "result": true,
  "usersize": 10000,
  "facesize": 10000,
  "avatarsize": 0,
  "fpsize": 10000,
  "palmsize": 10000,
  "cardsize": 10000,
  "pwdsize": 10000,
  "logsize": 300000,
  "useduser": 100,
  "usedface": 50,
  "usedavatar": 0,
  "usedfp": 20,
  "usedpalm": 0,
  "usedcard": 10,
  "usedpwd": 5,
  "usedlog": 1000,
  "usednewlog": 500,
  "usedrtlog": 3
}
FieldDescription
usersizeMaximum number of users
facesizeMaximum face templates
avatarsizeMaximum avatar photos
fpsizeMaximum fingerprints
palmsizeMaximum palm veins
cardsizeMaximum card numbers
pwdsizeMaximum passwords
logsizeMaximum log records
used*Currently used count for each type
usednewlogNumber of unread new logs
usedrtlogReal-time log queue size

8.4 gettime — Get Device Time

Gets the current device time. No parameters.

Request Example:

JSON{
  "cmd": "gettime",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "gettime",
  "sn": "LF00000001",
  "time": "2025-01-01 08: 00: 00"
}

8.5 settime — Set Device Time

Request Parameters:

ParameterTypeDescription
cloudtimestringCloud/server time "YYYY-MM-DD HH:MM:SS"
nowtimenumberUnix timestamp in seconds

Request Example:

JSON{
  "cmd": "settime",
  "sn": "LF00000001",
  "cloudtime": "2025-01-01 08: 00: 00",
  "nowtime": 1735689600
}

Success Response:

JSON{
  "ret": "settime",
  "sn": "LF00000001",
  "result": true
}

Failure Response:

JSON{
  "ret": "settime",
  "sn": "LF00000001",
  "result": false,
  "reason": 1,
  "msg": "time format wrong"
}

8.6 initsys — Factory Reset

Performs a factory reset: clears all users and logs, restores default settings, backs up WiFi configuration. No parameters.

Request Example:

JSON{
  "cmd": "initsys",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "initsys",
  "sn": "LF00000001",
  "result": true
}

8.7 initmenu — Reset Menu Settings

Restores default menu settings. Preserves language and backs up WiFi configuration. No parameters.

Request Example:

JSON{
  "cmd": "initmenu",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "initmenu",
  "sn": "LF00000001",
  "result": true
}

8.8 cleandatebase — Clear Database

Clears the entire database. Device must be rebooted after this operation. No parameters.

Request Example:

JSON{
  "cmd": "cleandatebase",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "cleandatebase",
  "sn": "LF00000001",
  "result": true
}

8.9 cleanadmin — Clear All Administrators

Removes all administrator privileges. No parameters.

Request Example:

JSON{
  "cmd": "cleanadmin",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "cleanadmin",
  "sn": "LF00000001",
  "result": true
}

8.10 cleaninactiveuser — Clear Inactive Users

Removes users who have not been active (no attendance records). No parameters.

Request Example:

JSON{
  "cmd": "cleaninactiveuser",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "cleaninactiveuser",
  "sn": "LF00000001",
  "result": true
}

8.11 reboot — Reboot Device

Triggers an immediate device reboot. No response is sent (device restarts).

Request Example:

JSON{
  "cmd": "reboot",
  "sn": "LF00000001"
}

Behavior: No response. Device reboots immediately.


8.12 disabledevice — Disable Device Recognition

Pauses all face, card, fingerprint, and palm detection. No parameters.

Request Example:

JSON{
  "cmd": "disabledevice",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "disabledevice",
  "sn": "LF00000001",
  "result": true
}

8.13 enabledevice — Enable Device Recognition

Resumes all face, card, fingerprint, and palm detection. No parameters.

Request Example:

JSON{
  "cmd": "enabledevice",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "enabledevice",
  "sn": "LF00000001",
  "result": true
}

8.14 getreg — Get Device Registration Information

Retrieves full device registration and capability information. No parameters.

Request Example:

JSON{
  "cmd": "getreg",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "getreg",
  "sn": "LF00000001",
  "result": true,
  "devinfo": {
    "modelname": "AiFace",
    "manufacturer": "AiFace Inc.",
    "usersize": 10000,
    "facesize": 10000,
    "avatarsize": 0,
    "fpsize": 10000,
    "palmsize": 10000,
    "cardsize": 10000,
    "pwdsize": 10000,
    "logsize": 300000,
    "useduser": 100,
    "usedface": 50,
    "usedavatar": 0,
    "usedfp": 20,
    "usedpalm": 0,
    "usedcard": 10,
    "usedpwd": 5,
    "usedlog": 1000,
    "usednewlog": 500,
    "usedrtlog": 3,
    "netinuse": 1,
    "usb4g": 0,
    "fpalgo": "thbio3.0",
    "firmware": "1.0.0",
    "time": "2025-01-01 08: 00: 00",
    "intercom": 0,
    "floors": 0,
    "acces_stimes": 0,
    "charid": 0,
    "useosdp": 0,
    "facetemplate": 0,
    "dislanguage": 0,
    "curip": "192.168.001.100",
    "ntp": 1,
    "timezone": "UTC+8",
    "cpu_temp": 45,
    "bandwidth_up": "100Kbps",
    "bandwidth_down": "1Mbps",
    "battery": 100,
    "disksize": 1024.0,
    "useddisk": 512.0,
    "mac": "AA-BB-CC-DD-EE-FF"
  }
}

8.15 checklive — Heartbeat Check (Server-Issued)

A server-initiated heartbeat command to verify device connectivity. Device responds to confirm it is alive and provide server time for synchronization.

Server → Device Request:

JSON{
  "cmd": "checklive",
  "sn": "LF00000001"
}

Device → Server Response:

JSON{
  "ret": "checklive",
  "sn": "LF00000001",
  "result": true
}

9. Access Control Commands

9.1 opendoor — Remote Door Open

Remotely unlocks the door. Optionally sends user ID via Wiegand and displays a message.

Request Parameters:

ParameterTypeDescription
enrollidnumberUser ID (sent via Wiegand output)
floornumberFloor number (requires elevator control enabled)
msgstringDisplay message on device screen

Request Example:

JSON{
  "cmd": "opendoor",
  "sn": "LF00000001",
  "enrollid": 123,
  "floor": 0,
  "msg": "Welcome"
}

Success Response:

JSON{
  "ret": "opendoor",
  "sn": "LF00000001",
  "result": true
}

9.2 lockctrl — Door Lock Control

Controls the door lock state directly.

Request Parameters:

ParameterTypeDescription
fucnumber1 = unlock/open, 2 = lock/close

Request Example:

JSON{
  "cmd": "lockctrl",
  "sn": "LF00000001",
  "fuc": 1
}

Success Response:

JSON{
  "ret": "lockctrl",
  "sn": "LF00000001",
  "result": true
}

9.3 getdoorstatus — Get Door Status

Returns the current door sensor status. No parameters.

Request Example:

JSON{
  "cmd": "getdoorstatus",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "getdoorstatus",
  "doorstatus": 0,
  "sn": "LF00000001",
  "result": true
}
doorstatus: 0 = closed, 1 = open (depends on door sensor configuration)

9.4 setdevlock — Set Door Access Parameters

Configures door access control parameters including timing, zones, and Wiegand settings.

Request Parameters:

ParameterTypeDescription
opendelaynumberDoor open delay (seconds)
doorsensornumberDoor sensor type
alarmdelaynumberAlarm trigger delay
InputAlarmnumberFire alarm input
antpassnumberAnti-passback enabled
interlocknumberInterlock mode
mutiopennumberMulti-person unlock requirement
tryalarmnumberFailed attempt alarm threshold
punchtimesnumberPunch/clock times
access_timesnumberMaximum access times
serververifytimeoutnumberServer verification timeout (seconds)
tampernumberTamper detection enabled
wgformatnumberWiegand output format: 0=26bit, 1=34bit, 2=42bit, 3=50bit, 4=58bit, 5=66bit, 6=37bit
wgoutputnumberWiegand output mode
cardformatnumberCard display format
wgportnumberWiegand port
dayzonearrayDate time zones [{"day": [{"section": "HH:MM~HH:MM"}]}]
weekzonearrayWeekly time zones [{"week": [{"day": 1}]}]
lockgrouparrayLock group matching [{"group": 1}]
nopentimearrayNo-pass time periods [{"day": 0}]
visitortimearrayVisitor time periods [{"day": 0}]

Request Example:

JSON{
  "cmd": "setdevlock",
  "sn": "LF00000001",
  "opendelay": 5,
  "doorsensor": 0,
  "alarmdelay": 30,
  "InputAlarm": 0,
  "antpass": 0,
  "interlock": 0,
  "mutiopen": 0,
  "tryalarm": 5,
  "access_times": 0,
  "punchtimes": 0,
  "tamper": 0,
  "wgformat": 0,
  "wgoutput": 0,
  "cardformat": 0,
  "wgport": 0
}

Success Response:

JSON{
  "ret": "setdevlock",
  "sn": "LF00000001",
  "result": true
}

9.5 getdevlock — Get Door Access Parameters

Reads the current door access control configuration. No parameters.

Request Example:

JSON{
  "cmd": "getdevlock",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "getdevlock",
  "sn": "LF00000001",
  "result": true,
  "opendelay": 5,
  "doorsensor": 0,
  "alarmdelay": 30,
  "InputAlarm": 0,
  "antpass": 0,
  "interlock": 0,
  "mutiopen": 0,
  "tryalarm": 5,
  "access_times": 0,
  "punchtimes": 0,
  "tamper": 0,
  "wgformat": 0,
  "wgoutput": 0,
  "cardformat": 0,
  "wgport": 0,
  "dayzone": [],
  "weekzone": [],
  "lockgroup": [],
  "nopentime": [],
  "visitortime": []
}

9.6 getuserlock — Get User Door Access Parameters

Request Parameters:

ParameterTypeDescription
enrollidnumber/stringUser ID
aliasidstringUser alias ID

Request Example:

JSON{
  "cmd": "getuserlock",
  "sn": "LF00000001",
  "enrollid": 123,
  "aliasid": "USR001"
}

Success Response:

JSON{
  "ret": "getuserlock",
  "sn": "LF00000001",
  "result": true,
  "enrollid": 123,
  "birthday": "01-15",
  "verifymode": 0,
  "enable": 1,
  "weekzone": 0,
  "group": 0,
  "access_times": 0,
  "starttime": "2025-01-01 00: 00: 00",
  "endtime": "2025-12-31 23: 59: 59",
  "aliasid": "USR001"
}

Failure Response:

JSON{
  "ret": "getuserlock",
  "enrollid": 123,
  "sn": "LF00000001",
  "result": false,
  "reason": 1,
  "msg": "can not find the user"
}

9.7 setuserlock — Batch Set User Door Access Parameters

Request Parameters:

ParameterTypeDescription
countnumberNumber of records
birthdaystringBirthday (applied globally)
recordarrayArray of {enrollid, aliasid, verifymode, weekzone, group, access_times, starttime, endtime}

Request Example:

JSON{
  "cmd": "setuserlock",
  "sn": "LF00000001",
  "count": 2,
  "birthday": "06-15",
  "record": [
    {"enrollid": 100, "aliasid": "U100", "verifymode": 0, "weekzone": 0, "group": 0, "access_times": 0, "starttime": "2025-01-01 00: 00: 00", "endtime": "2025-12-31 23: 59: 59"},
    {"enrollid": 101, "aliasid": "U101", "verifymode": 0, "weekzone": 1, "group": 1, "access_times": 10, "starttime": "2025-01-01 00: 00: 00", "endtime": "2025-12-31 23: 59: 59"}
  ]
}

Success Response:

JSON{
  "ret": "setuserlock",
  "sn": "LF00000001",
  "result": true
}

Failure Response:

JSON{
  "ret": "setuserlock",
  "sn": "LF00000001",
  "result": false,
  "reason": 1,
  "msg": "setuserlock fail"
}

9.8 deleteuserlock — Delete User Door Access Parameters

Request Parameters:

ParameterTypeDescription
enrollidnumber/stringUser ID
aliasidstringUser alias ID

Request Example:

JSON{
  "cmd": "deleteuserlock",
  "sn": "LF00000001",
  "enrollid": 123,
  "aliasid": "USR001"
}

Success Response:

JSON{
  "ret": "deleteuserlock",
  "enrollid": 123,
  "sn": "LF00000001",
  "result": true,
  "aliasid": "USR001"
}

9.9 cleanuserlock — Clear All User Door Access Parameters

Removes door access time zones and restrictions for all users. No parameters.

Request Example:

JSON{
  "cmd": "cleanuserlock",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "cleanuserlock",
  "sn": "LF00000001",
  "result": true
}

10. Attendance Management Commands

10.1 getshift — Get Shift Schedule

Reads the configured shift/roster schedule. No parameters.

Request Example:

JSON{
  "cmd": "getshift",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "getshift",
  "sn": "LF00000001",
  "result": true,
  "shifts": [
    {
      "name": "Day Shift",
      "cutoftime": "09: 00",
      "sections": [
        {"start": "08: 00", "end": "12: 00", "type": 0},
        {"start": "13: 00", "end": "17: 00", "type": 1},
        {"start": "17: 00", "end": "18: 00", "type": 2}
      ]
    }
  ]
}
Maximum 8 shifts, each with up to 3 time sections.
Section type: 0=work, 1=rest, 2=overtime

10.2 setshift — Set Shift Schedule

Request Parameters:

ParameterTypeDescription
shiftsarrayArray of shift objects, each containing name, cutoftime, sections[]

Request Example:

JSON{
  "cmd": "setshift",
  "sn": "LF00000001",
  "shifts": [
    {
      "name": "Day Shift",
      "cutoftime": "09: 00",
      "sections": [
        {"start": "08: 00", "end": "12: 00", "type": 0},
        {"start": "13: 00", "end": "17: 00", "type": 1}
      ]
    },
    {
      "name": "Night Shift",
      "cutoftime": "21: 00",
      "sections": [
        {"start": "20: 00", "end": "23: 59", "type": 0},
        {"start": "00: 00", "end": "06: 00", "type": 0}
      ]
    }
  ]
}

Success Response:

JSON{
  "ret": "setshift",
  "sn": "LF00000001",
  "result": true
}

10.3 getbelltime — Get Bell Schedule

Reads configured bell/doorbell time schedules. No parameters.

Request Example:

JSON{
  "cmd": "getbelltime",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "getbelltime",
  "sn": "LF00000001",
  "result": true,
  "belltimes": [
    {"time": "08: 00", "flag": 127},
    {"time": "12: 00", "flag": 127}
  ]
}
flag is a bitmask where each bit represents a day of the week (127 = all days)

10.4 setbelltime — Set Bell Schedule

Request Parameters:

ParameterTypeDescription
belltimesarrayArray of {time: "HH:MM", flag: number} objects

Request Example:

JSON{
  "cmd": "setbelltime",
  "sn": "LF00000001",
  "belltimes": [
    {"time": "08: 00", "flag": 127},
    {"time": "12: 00", "flag": 127},
    {"time": "18: 00", "flag": 65}
  ]
}

Success Response:

JSON{
  "ret": "setbelltime",
  "sn": "LF00000001",
  "result": true
}

10.5 setholiday — Set Holiday Schedule

Request Parameters:

ParameterTypeDescription
holidaysarrayArray of holiday objects

Holiday Object Fields:

FieldTypeDescription
namestringHoliday name
shiftnumberAssigned shift ID
dayzonenumberTime zone ID
startdaystringStart date "MM-DD"
enddaystringEnd date "MM-DD"

Request Example:

JSON{
  "cmd": "setholiday",
  "sn": "LF00000001",
  "holidays": [
    {"name": "Spring Festival", "startday": "01-28", "endday": "02-03", "shift": 0, "dayzone": 0},
    {"name": "National Day", "startday": "10-01", "endday": "10-07", "shift": 1, "dayzone": 0}
  ]
}

Success Response:

JSON{
  "ret": "setholiday",
  "sn": "LF00000001",
  "result": true
}

10.6 getholiday — Get Holiday Schedule

Reads configured holiday schedule. No parameters.

Request Example:

JSON{
  "cmd": "getholiday",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "getholiday",
  "sn": "LF00000001",
  "result": true,
  "holidays": [
    {"name": "Spring Festival", "startday": "01-28", "endday": "02-03", "shift": 0, "dayzone": 0},
    {"name": "National Day", "startday": "10-01", "endday": "10-07", "shift": 1, "dayzone": 0}
  ]
}

11. Device Active Report Commands

These commands are initiated by the device and sent to the server. The server processes them and sends back a response.

11.1 sendlog — Device Reports Attendance Logs

Device proactively sends attendance/access log records to the server.

Device → Server (Request):

JSON{
  "cmd": "sendlog",
  "sn": "LF00000001",
  "count": 10,
  "logindex": 0,
  "record": [
    {
      "enrollid": 123,
      "name": "John Doe",
      "time": "2025-01-01 08: 00: 00",
      "mode": 1,
      "inout": 0,
      "event": 0,
      "aliasid": "USR001",
      "image": "base64...",
      "note": ""
    }
  ]
}

Server → Device (Response):

JSON{
  "ret": "sendlog",
  "result": true,
  "count": 10,
  "logindex": 0,
  "mark": true,
  "access": 1,
  "message": "Welcome",
  "fontsize": 24,
  "text_color": [255, 0, 0],
  "voice": "tts_url",
  "voiceindex": 0,
  "name": "John Doe",
  "questionnaire": true
}

Server Response Fields:

FieldTypeDescription
resultbooleanWhether log was accepted
countnumberNumber of log records received
logindexnumberLog index for acknowledgment
markbooleanWhether to mark logs as read
accessnumberAccess decision: 1 = grant, 0 = deny
messagestringDisplay message on device
fontsizenumberMessage font size
text_colorarrayRGB color [R, G, B]
voicestringTTS voice URL to play
voiceindexnumberVoice index number
namestringUser name for display
questionnairebooleanWhether to show questionnaire

11.2 senduser — Device Reports User Data Changes

Device proactively sends user enrollment/modification data when biometrics or credentials are enrolled on the device.

Device → Server (Request) — Password Change (backupnum=10):

JSON{
  "cmd": "senduser",
  "sn": "LF00000001",
  "enrollid": 123,
  "name": "John Doe",
  "backupnum": 10,
  "admin": 0,
  "record": 12345,
  "aliasid": "USR001",
  "card": 0,
  "pwd": 12345,
  "fpflag": 0,
  "palmflag": 0,
  "faceflag": 1,
  "enable": 1,
  "birthday": "01-15",
  "shiftid": 0,
  "verifymode": 0,
  "zoneid": 0,
  "groupid": 0,
  "access_times": 0,
  "postid": 0,
  "starttime": "2025-01-01 00: 00: 00",
  "endtime": "2025-12-31 23: 59: 59",
  "profile": "{}"
}

Device → Server (Request) — Card Change (backupnum=11):

JSON{
  "cmd": "senduser",
  "sn": "LF00000001",
  "enrollid": 123,
  "name": "John Doe",
  "backupnum": 11,
  "admin": 0,
  "record": 1234567890,
  "aliasid": "USR001"
}

Device → Server (Request) — Face Photo (backupnum=50):

JSON{
  "cmd": "senduser",
  "sn": "LF00000001",
  "enrollid": 123,
  "name": "John Doe",
  "backupnum": 50,
  "admin": 0,
  "record": "base64_jpg_data",
  "aliasid": "USR001"
}

Device → Server (Request) — Face Feature (backupnum=51):

JSON{
  "cmd": "senduser",
  "sn": "LF00000001",
  "enrollid": 123,
  "name": "John Doe",
  "backupnum": 51,
  "admin": 0,
  "record": "base64_feat_data",
  "aliasid": "USR001"
}

Device → Server (Request) — Fingerprint (backupnum=0-9):

JSON{
  "cmd": "senduser",
  "sn": "LF00000001",
  "enrollid": 123,
  "name": "John Doe",
  "backupnum": 0,
  "admin": 0,
  "record": "hex_fp_data_with_compression",
  "aliasid": "USR001"
}

Device → Server (Request) — Palm Vein (backupnum=40/41):

JSON{
  "cmd": "senduser",
  "sn": "LF00000001",
  "enrollid": 123,
  "name": "John Doe",
  "backupnum": 40,
  "admin": 0,
  "record": "base64_palm_data",
  "aliasid": "USR001"
}

Server → Device (Response):

JSON{
  "ret": "senduser",
  "result": true,
  "enrollid": 123,
  "backupnum": 10
}

11.3 sendpin — Device Reports PIN Input

Device reports when a user enters a PIN code on the device keypad.

Device → Server (Request):

JSON{
  "cmd": "sendpin",
  "sn": "LF00000001",
  "pin": "123456",
  "time": "2025-01-01 08: 00: 00"
}

Server → Device (Response):

JSON{
  "ret": "sendpin",
  "result": true,
  "access": 1,
  "message": "Welcome",
  "fontsize": 24,
  "text_color": [255, 0, 0],
  "voice": "tts_url",
  "voiceindex": 0,
  "aliasid": "USR001",
  "name": "John Doe"
}

Failure Response:

JSON{
  "ret": "sendpin",
  "result": false
}

11.4 sendqrcode — Device Reports QR Code Scan

Device reports when a user scans a QR code.

Device → Server (Request):

JSON{
  "cmd": "sendqrcode",
  "sn": "LF00000001",
  "record": "qrcode_data_string"
}

Server → Device (Response):

JSON{
  "ret": "sendqrcode",
  "result": true,
  "access": 1,
  "enrollid": 123,
  "username": "John Doe",
  "message": "Welcome",
  "fontsize": 24,
  "text_color": [255, 0, 0],
  "voice": "tts_url",
  "voiceindex": 0
}

Failure Response:

JSON{
  "ret": "sendqrcode",
  "result": false
}

11.5 sendgps — Device Reports GPS Location [Requires USE_USB4G]

Device proactively sends GPS location data when a USB 4G module is available.

Device → Server (Request):

JSON{
  "cmd": "sendgps",
  "sn": "LF00000001",
  "satellites": 8,
  "location": "latitude,longitude",
  "timeStamp": 1704067200
}

Request Fields:

FieldTypeDescription
satellitesnumberNumber of GPS satellites in view
locationstringGPS location information string
timeStampnumberUnix timestamp in seconds
Note: The server processes this data but does not send a specific response back to the device.

11.6 otacheck — OTA Update Check

Device checks if a firmware update is available.

Device → Server (Request):

JSON{
  "cmd": "otacheck",
  "sn": "LF00000001",
  "fwname": "ai230_device",
  "version": "1.0.0"
}

Server → Device (Response) — Update Available:

JSON{
  "ret": "otacheck",
  "result": true,
  "filesize": 1048576,
  "filename": "update.pkg",
  "md5": "abc123def456..."
}

Server → Device (Response) — No Update:

JSON{
  "ret": "otacheck",
  "result": false
}

11.7 otaget — OTA File Download

Device requests a chunk of the OTA firmware file.

Device → Server (Request):

JSON{
  "cmd": "otaget",
  "sn": "LF00000001",
  "filename": "update.pkg",
  "index": 0,
  "count": 102400
}
ParameterTypeDescription
filenamestringFirmware filename
indexnumberByte offset to start reading
countnumberNumber of bytes to read

Server → Device (Response):

JSON{
  "ret": "otaget",
  "result": true,
  "index": 0,
  "count": 102400,
  "record": "base64_encoded_firmware_chunk"
}

Failure Response:

JSON{
  "ret": "otaget",
  "result": false
}

12. File Management Commands

12.1 getdir — List Directory Files

Lists files in a specified directory.

Request Parameters:

ParameterTypeDescription
pathstringDirectory path (must start with /data/)

Request Example:

JSON{
  "cmd": "getdir",
  "sn": "LF00000001",
  "path": "/data/photos"
}

Success Response:

JSON{
  "ret": "getdir",
  "sn": "LF00000001",
  "result": true,
  "files": ["file1.jpg", "file2.txt", "photo3.jpg"]
}

Failure Response:

JSON{
  "ret": "getdir",
  "sn": "LF00000001",
  "result": false
}

12.2 getfile — Read File

Reads the contents of a file and returns it as base64.

Request Parameters:

ParameterTypeDescription
pathstringFull file path

Request Example:

JSON{
  "cmd": "getfile",
  "sn": "LF00000001",
  "path": "/data/photos/user123.jpg"
}

Success Response:

JSON{
  "ret": "getfile",
  "sn": "LF00000001",
  "result": true,
  "base64": "base64_encoded_file_content"
}

Failure Response:

JSON{
  "ret": "getfile",
  "sn": "LF00000001",
  "result": false
}

12.3 writefile — Write File

Writes base64-encoded content to a file.

Request Parameters:

ParameterTypeDescription
pathstringDestination file path
base64stringFile content in base64 encoding

Request Example:

JSON{
  "cmd": "writefile",
  "sn": "LF00000001",
  "path": "/data/config/settings.json",
  "base64": "base64_encoded_json_data"
}

Success Response:

JSON{
  "ret": "writefile",
  "sn": "LF00000001",
  "result": true
}

Failure Response:

JSON{
  "ret": "writefile",
  "sn": "LF00000001",
  "result": false
}

13. Other Commands

13.1 upgrade — Firmware Upgrade via Server

Uploads firmware upgrade data to the device in chunks.

Request Parameters:

ParameterTypeDescription
filenamestringTarget filename (.zip or .pkg)
md5stringFile MD5 checksum
allcountnumberTotal file size in bytes
indexnumberCurrent byte offset
countnumberSize of this data chunk in bytes
recordstringBase64-encoded file data chunk

Request Example (first chunk):

JSON{
  "cmd": "upgrade",
  "sn": "LF00000001",
  "filename": "update.pkg",
  "md5": "abc123def456...",
  "allcount": 10485760,
  "index": 0,
  "count": 102400,
  "record": "base64_encoded_chunk_data"
}

Success Response:

JSON{
  "ret": "upgrade",
  "sn": "LF00000001",
  "result": true
}

Failure Responses:

reasonMessage
1is not this machine upgrade file / disk space insufficient
2md5 check error
3move the zip file error
4need zip or pkg
JSON{
  "ret": "upgrade",
  "sn": "LF00000001",
  "result": false,
  "reason": 1,
  "msg": "is not this machine upgrade file"
}

13.2 forceota — Force OTA Update

Triggers an immediate OTA update check and download. No parameters.

Request Example:

JSON{
  "cmd": "forceota",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "forceota",
  "sn": "LF00000001",
  "result": true
}

13.3 setotaserver — Set OTA Server Address

Request Parameters:

ParameterTypeDescription
addressstringOTA server address (URL or IP)

Request Example:

JSON{
  "cmd": "setotaserver",
  "sn": "LF00000001",
  "address": "https://ota.example.com"
}

Success Response:

JSON{
  "ret": "setotaserver",
  "sn": "LF00000001",
  "result": true
}

Failure Response:

JSON{
  "ret": "setotaserver",
  "sn": "LF00000001",
  "result": false
}

13.4 getotaserver — Get OTA Server Address

Reads the configured OTA server address. No parameters.

Request Example:

JSON{
  "cmd": "getotaserver",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "getotaserver",
  "sn": "LF00000001",
  "result": true,
  "address": "https://ota.example.com"
}

13.5 setscreensaver — Set Screensaver

Configures the device screensaver with an image.

Request Parameters:

ParameterTypeDescription
filenamestringScreensaver filename
photostringImage data as base64
durationnumberDisplay duration in seconds
removebooleantrue = delete the specified file
removeallbooleantrue = delete all screensavers

Request Example:

JSON{
  "cmd": "setscreensaver",
  "sn": "LF00000001",
  "filename": "screensaver1.jpg",
  "photo": "base64_encoded_image",
  "duration": 30,
  "remove": false,
  "removeall": false
}

Success Response:

JSON{
  "ret": "setscreensaver",
  "sn": "LF00000001",
  "result": true
}

13.6 setvoice — Set Custom Voice

Uploads and optionally plays a custom voice file.

Request Parameters:

ParameterTypeDescription
indexnumberVoice file index number
voicestringWAV file data as base64
playbooleantrue = play immediately
repeat_secondsnumberRepeat interval in seconds

Request Example:

JSON{
  "cmd": "setvoice",
  "sn": "LF00000001",
  "index": 10,
  "voice": "base64_encoded_wav_data",
  "play": true,
  "repeat_seconds": 60
}

Success Response:

JSON{
  "ret": "setvoice",
  "sn": "LF00000001",
  "result": true
}

13.7 keypad — Control On-Screen Keypad

Activates or deactivates the on-screen numeric keypad.

Request Parameters:

ParameterTypeDescription
passwordbooleanWhether password is required
keepbooleantrue = persist, false = temporary
timeoutnumberTimeout in seconds
onbooleantrue = activate, false = deactivate

Request Example:

JSON{
  "cmd": "keypad",
  "sn": "LF00000001",
  "password": true,
  "keep": false,
  "timeout": 30,
  "on": true
}

Success Response:

JSON{
  "ret": "keypad",
  "sn": "LF00000001",
  "result": true
}

13.8 verify — Biometric Verification

Performs face or fingerprint verification on the server side.

Request Parameters:

ParameterTypeDescription
enrollidnumber/stringUser ID to verify against
cardnumber/stringRFID card number
pwdnumberPassword
namestringUser name
facestringFace photo as base64
fingerstringFingerprint data as hex (with compression)
finger2stringSecond fingerprint as hex
profilestringUser profile JSON

Request Example:

JSON{
  "cmd": "verify",
  "sn": "LF00000001",
  "enrollid": 123,
  "card": 12345,
  "pwd": 0,
  "name": "John Doe",
  "face": "base64_face_photo",
  "finger": "",
  "finger2": "",
  "profile": "{}"
}

Success Response:

JSON{
  "ret": "verify",
  "enrollid": 123,
  "aliasid": "USR001",
  "sn": "LF00000001",
  "result": true
}

Failure Responses (reason codes):

reasonMessage
1base64 decode error
2File too large (>512KB)
3File size is 0
5No face detected in image
6More than 1 face in image
7Image dimensions too large
8Face too large
9Face too small
10Image quality too low
11Face position offset too large
12No valid data (no face and no fingerprint)
JSON{
  "ret": "verify",
  "enrollid": 123,
  "aliasid": "USR001",
  "sn": "LF00000001",
  "result": false,
  "reason": 5,
  "msg": "no face in picture"
}

13.9 setdepartment — Set Department List

Request Parameters:

ParameterTypeDescription
deletebooleantrue = clear all departments
namearrayArray of department names

Request Example (set departments):

JSON{
  "cmd": "setdepartment",
  "sn": "LF00000001",
  "delete": false,
  "name": ["Engineering", "Sales", "HR", "Finance", "Operations"]
}

Request Example (clear all):

JSON{
  "cmd": "setdepartment",
  "sn": "LF00000001",
  "delete": true
}

Success Response:

JSON{
  "ret": "setdepartment",
  "sn": "LF00000001",
  "result": true
}

13.10 getdepartment — Get Department List

Reads the configured department list. No parameters.

Request Example:

JSON{
  "cmd": "getdepartment",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "getdepartment",
  "sn": "LF00000001",
  "result": true,
  "count": 5,
  "name": ["Engineering", "Sales", "HR", "Finance", "Operations"]
}

Failure Response:

JSON{
  "ret": "getdepartment",
  "sn": "LF00000001",
  "result": false,
  "reason": 1,
  "msg": "can not find department file"
}

13.11 setcompanyname — Set Company Name

Request Parameters:

ParameterTypeDescription
namestringCompany name

Request Example:

JSON{
  "cmd": "setcompanyname",
  "sn": "LF00000001",
  "name": "Acme Corporation"
}

Success Response:

JSON{
  "ret": "setcompanyname",
  "sn": "LF00000001",
  "result": true
}

13.12 getcompanyname — Get Company Name

Reads the configured company name. No parameters.

Request Example:

JSON{
  "cmd": "getcompanyname",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "getcompanyname",
  "sn": "LF00000001",
  "result": true,
  "name": "Acme Corporation"
}

13.13 setquestionnaire — Set Questionnaire

Configures a questionnaire/survey that is displayed to users after verification.

Request Parameters:

ParameterTypeDescription
titlestringQuestionnaire title
voicestringVoice prompt filename
errmsgstringError message text
radiobooleanSingle-choice mode
optionflagnumberOption flags
itemsarrayArray of option strings (max 16)
schedulesarrayDisplay schedules ["HH:MM-HH:MM*N"]
usequestionbooleanEnable questionnaire
useschedulebooleanEnable schedule
cardnumber/stringAssociated card number
switch_cardnumber/stringSwitching card number
enrollidnumber/stringAssociated user ID
openbooleanOpen immediately

Request Example:

JSON{
  "cmd": "setquestionnaire",
  "sn": "LF00000001",
  "title": "Health Declaration",
  "voice": "health.wav",
  "errmsg": "Please complete the survey",
  "radio": true,
  "optionflag": 0,
  "items": ["Option A", "Option B", "Option C"],
  "schedules": ["08: 00-18: 00*1"],
  "usequestion": true,
  "useschedule": false,
  "card": 0,
  "switch_card": 0,
  "enrollid": 0,
  "open": false
}

Success Response:

JSON{
  "ret": "setquestionnaire",
  "sn": "LF00000001",
  "result": true
}

13.14 getquestionnaire — Get Questionnaire

Reads the current questionnaire configuration. No parameters.

Request Example:

JSON{
  "cmd": "getquestionnaire",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "getquestionnaire",
  "sn": "LF00000001",
  "result": true,
  "title": "Health Declaration",
  "voice": "health.wav",
  "errmsg": "Please complete the survey",
  "radio": true,
  "optionflag": 0,
  "usequestion": true,
  "useschedule": false,
  "card": 0,
  "switch_card": 0,
  "items": ["Option A", "Option B", "Option C"],
  "schedules": ["08: 00-18: 00*1"]
}

Not Configured Response:

JSON{
  "ret": "getquestionnaire",
  "sn": "LF00000001",
  "result": false
}

13.15 cleanquestionnaire — Clear Questionnaire

Removes the questionnaire configuration. No parameters.

Request Example:

JSON{
  "cmd": "cleanquestionnaire",
  "sn": "LF00000001"
}

Success Response:

JSON{
  "ret": "cleanquestionnaire",
  "sn": "LF00000001",
  "result": true
}

14. Video Intercom Commands

Note: These commands require the VIDEO_INTERCOM feature to be enabled on the device.

14.1 enablewebrtc — Enable WebRTC

Configures and enables WebRTC video intercom capabilities.

Request Parameters:

ParameterTypeDescription
intercombooleanEnable voice/video intercom
monitorbooleanEnable monitoring
waitsecondsnumberWait timeout in seconds
inputmodenumberInput mode: 0=direct call (no input dialog), 1=enroll/ID number, 2=phone number, 3=room number, 4=visual selection menu
audioonlynumber / booleanAudio-only intercom: 1/true = audio only, 0/false = audio + video (also controls video on/off)
stunserverstringSTUN server URL
turnserverstringTURN server URL
turnusernamestringTURN authentication username
turnpasswordstringTURN authentication password

Request Example:

JSON{
  "cmd": "enablewebrtc",
  "sn": "LF00000001",
  "intercom": true,
  "monitor": true,
  "waitseconds": 30,
  "inputmode": 0,
  "stunserver": "stun:stun.example.com: 3478",
  "turnserver": "turn:turn.example.com: 3478",
  "turnusername": "user",
  "turnpassword": "password"
}

Success Response:

JSON{
  "ret": "enablewebrtc",
  "sn": "LF00000001",
  "result": true
}

Failure Response:

JSON{
  "ret": "enablewebrtc",
  "sn": "LF00000001",
  "result": false,
  "reason": 1,
  "msg": "this device have not this function"
}

14.2 callaccept — Accept or Reject Call

Server-side response to an incoming intercom call from the device.

Request Parameters:

ParameterTypeDescription
resultbooleantrue = accept, false = reject
sessionidstringCall session ID

Request Example (accept):

JSON{
  "cmd": "callaccept",
  "sn": "LF00000001",
  "result": true,
  "sessionid": "session_abc123"
}

Device Response — Sends WebRTC Offer:

JSON{
  "cmd": "offer",
  "sn": "LF00000001",
  "sessionid": "session_abc123",
  "type": "offer",
  "sdp": "v=0\r\no=..."
}

14.3 viewready — Monitor Ready

Server indicates it is ready to receive video monitoring stream.

Request Parameters:

ParameterTypeDescription
sessionidstringSession ID

Request Example:

JSON{
  "cmd": "viewready",
  "sn": "LF00000001",
  "sessionid": "session_abc123"
}

Device Response — Sends WebRTC Offer:

JSON{
  "cmd": "offer",
  "sn": "LF00000001",
  "sessionid": "session_abc123",
  "type": "offer",
  "sdp": "v=0\r\no=..."
}

14.4 answer — Process WebRTC Answer

Server sends the WebRTC answer SDP to the device.

Request Parameters:

ParameterTypeDescription
sessionidstringSession ID
sdpstringSDP answer content

Request Example:

JSON{
  "cmd": "answer",
  "sn": "LF00000001",
  "sessionid": "session_abc123",
  "sdp": "v=0\r\no=..."
}

Behavior: No direct response. Device processes the answer internally and may retry sending offer if needed.


14.5 icecandidate — Process ICE Candidate

Server sends an ICE candidate to the device for NAT traversal.

Request Parameters:

ParameterTypeDescription
sessionidstringSession ID
candidatestringICE candidate content

Request Example:

JSON{
  "cmd": "icecandidate",
  "sn": "LF00000001",
  "sessionid": "session_abc123",
  "candidate": "candidate: 1 1 UDP 123456 192.168.1.100 12345 typ host"
}

Behavior: No direct response. Device adds the ICE candidate internally.


14.6 callcancel — Cancel Call

Cancels an active or pending intercom call.

Request Parameters:

ParameterTypeDescription
sessionidstringSession ID
typenumber1 = intercom, 2 = monitoring

Request Example:

JSON{
  "cmd": "callcancel",
  "sn": "LF00000001",
  "sessionid": "session_abc123",
  "type": 1
}

Behavior: No direct response.


14.7 talklock — Door Control During Call

Controls the door lock during an active intercom call.

Request Parameters:

ParameterTypeDescription
typenumber1 = open door, 2 = trigger alarm

Request Example:

JSON{
  "cmd": "talklock",
  "sn": "LF00000001",
  "type": 1
}

Success Response:

JSON{
  "ret": "talklock",
  "sn": "LF00000001",
  "result": true
}

14.8 monitorcall — Start Monitoring

Server initiates a monitoring session to view the device's video feed.

Request Parameters:

ParameterTypeDescription
forcebooleantrue = force disconnect any existing monitoring session
sessionidstringSession ID

Request Example:

JSON{
  "cmd": "monitorcall",
  "sn": "LF00000001",
  "force": false,
  "sessionid": "session_abc123"
}

Success Response:

JSON{
  "ret": "monitorcall",
  "sn": "LF00000001",
  "lanscape": 1,
  "result": true,
  "sessionid": "session_abc123"
}

Busy Response:

JSON{
  "ret": "monitorcall",
  "sn": "LF00000001",
  "lanscape": 1,
  "result": false,
  "reason": 1,
  "msg": "another user have monitored",
  "sessionid": "session_abc123",
  "monitoring": "other_session_id"
}

14.9 setviselection — Set Visual Selection Menu

Configures the interactive visual selection menu displayed on the device's touchscreen.

Each page (building) is either/or: send only items[] (flat mode) or only floors[] (floor mode). Do not send both in the same page.

Request Parameters:

ParameterTypeDescription
titlestringMenu title (top title bar)
voicestringVoice prompt content (TTS text, not a filename)
pagesarrayPage array (max 6 pages, one page = one building)
pages[].itemtitlestringTab title, e.g. "Building 1"
Flat mode (either/or)
pages[].itemsarrayFlat room list (max 500), mutually exclusive with floors
items[].sectionstringButton label, e.g. "101"
items[].keynumnumberKey number (call target)
Floor mode (either/or)
pages[].floorsarrayFloor array (max 100), mutually exclusive with items
floors[].floortitlestringFloor label, e.g. "Floor 1"
floors[].itemsarrayRoom list of this floor (max 50 per floor)
floors[].items[].sectionstringRoom label, e.g. "101"
floors[].items[].keynumnumberRoom key number (call target)

Request Example (Mode 1: Flat / legacy):

JSON{
  "cmd": "setviselection",
  "sn": "LF00000001",
  "title": "Visitor Menu",
  "voice": "Please select a room",
  "pages": [
    {
      "itemtitle": "Building 1",
      "items": [
        {"section": "101", "keynum": 101},
        {"section": "102", "keynum": 102}
      ]
    }
  ]
}

Request Example (Mode 2: Floors / new):

JSON{
  "cmd": "setviselection",
  "sn": "LF00000001",
  "title": "Visitor Menu",
  "voice": "Please select a floor",
  "pages": [
    {
      "itemtitle": "Building 1",
      "floors": [
        {
          "floortitle": "Floor 1",
          "items": [
            {"section": "101", "keynum": 101},
            {"section": "102", "keynum": 102}
          ]
        },
        {
          "floortitle": "Floor 2",
          "items": [
            {"section": "201", "keynum": 201}
          ]
        }
      ]
    }
  ]
}

Success Response:

JSON{
  "ret": "setviselection",
  "sn": "LF00000001",
  "result": true
}

14.10 talkcall — Device Initiates Call

Device proactively initiates an intercom call to the server.

Device → Server (Request):

JSON{
  "cmd": "talkcall",
  "sn": "LF00000001",
  "inputnum": 0,
  "inputmode": 0,
  "landscape": 1
}

Server → Device (Response):

JSON{
  "ret": "talkcall",
  "result": true,
  "sessionid": "session_abc123"
}

Failure Response (reason codes):

reasonMeaning
1Subscriber list is empty
2Subscriber is offline
3No permission
4Call rejected by subscriber
5Subscriber is busy
6Subscriber state is incorrect
JSON{
  "ret": "talkcall",
  "result": false,
  "reason": 1
}

14.11 vicheckonline — Check Online Status

Device checks if subscribers are online.

Device → Server (Request):

JSON{
  "cmd": "vicheckonline",
  "sn": "LF00000001"
}

Server → Device (Response):

JSON{
  "ret": "vicheckonline",
  "result": true,
  "count": 1,
  "online": "key1,key2"
}

14.12 WebRTC DataChannel Extension

After a WebRTC connection is established, the device and its peer (indoor unit / outdoor unit / App) open two additional WebRTC DataChannels for peer-to-peer real-time control commands (they do not go through the server and do not use the WebSocket/MQTT channel):

ChannelPurpose
intercom_channelIntercom session (during call / talk)
monitor_channelMonitor session (during monitoring)

1) Peer → Device (received by the device):

CommandFieldTypeRequiredDescription
opendoorcmdstringyesFixed value "opendoor"
typenumberyes1 = unlock; any other value = trigger alarm
enrollidnumbernoCard / user ID used for Wiegand output; defaults to 99999997
floornumbernoFloor number, effective only when elevator control is enabled; monitor_channel requires floor > 0
talkcmdstringyesFixed value "talk" (monitor_channel only)
enablenumber / booleanyes1/true = start talking (device plays the peer audio); 0/false = stop
msgmsgstringyesNo cmd; a top-level msg key identifies this message. Shows a prompt on the device screen for 3 seconds; max 127 bytes (buffer limit, not validated, longer input overflows)

Example (unlock, on intercom_channel or monitor_channel):

JSON{"cmd":"opendoor","type": 1,"enrollid": 123456,"floor": 5}

Example (talk switch during monitoring, monitor_channel only):

JSON{"cmd":"talk","enable": 1}

Example (screen message):

JSON{"msg":"Please wait"}

2) Device → Peer (sent by the device):

CommandFieldTypeDescription
opendoorretstringFixed value "opendoor"
resultbooleanWhether the action was executed
typenumberEchoes the type from the request
JSON{"ret":"opendoor","result": true,"type": 1}
intercom_channel and monitor_channel share exactly the same message format; only the session type differs. talk is valid on monitor_channel only.

15. Appendix

Appendix A: backupnum Value Reference

backupnumData TypeEncodingMax CapacityDescription
0Fingerprint #1hex10000First fingerprint slot
1Fingerprint #2hex10000Second fingerprint slot
2-9Fingerprint #3-10hex10000 eachAdditional fingerprint slots
10Passwordnumber10000User PIN/password
11Card Numbernumber10000RFID card number
12Full User Delete——Delete entire user (same as 13)
13Full User Delete——Delete entire user (same as 12)
40Palm Vein (Left)base6410000Left palm vein
41Palm Vein (Right)base6410000Right palm vein
50Face Photobase64 (JPG)10000Face photograph
51Face Featurebase6410000Face feature template

Appendix B: verifymode Reference

verifymode selects the verification method(s) a user may use. Every method — including combinations such as "face + card" — has a fixed value; use one of the values below.

verifymodeVerification methodNotes
0Any methodDefault; no restriction
1FingerprintRequires fingerprint model
2Password—
3Card—
4Fingerprint + cardRequires fingerprint model
5Fingerprint + passwordRequires fingerprint model
6Password + fingerprintRequires fingerprint model
7Card + fingerprintRequires fingerprint model
8FaceRequires camera model
9Face + passwordRequires camera model
10Face + cardRequires camera model
11Card + password—
12Face + fingerprintRequires camera and fingerprint model
13QR codeRequires QR code support
14Face + (card or password)Requires camera model
15ID card (SFZ)Requires ID card reader
16Palm veinRequires palm vein model
191:N automatic matchSet by the device itself; normally not sent by the platform
20Any biometric of the personAny biometric or combination of the person
21Palm vein + faceRequires palm vein model
22Fingerprint + palm veinRequires fingerprint and palm vein model
23Card + palm veinRequires palm vein model
24Palm vein + passwordRequires palm vein model
25Card + face + passwordRequires camera model

Notes:

Appendix C: mode Field in Log Records

The mode field of a log record reports the verification method actually used and uses the same values as verifymode:

mode valueVerification method
0Any method
1Fingerprint
2Password
3Card
4Fingerprint + card
5Fingerprint + password
6Password + fingerprint
7Card + fingerprint
8Face
9Face + password
10Face + card
11Card + password
12Face + fingerprint
13QR code
14Face + (card or password)
15ID card (SFZ)
16Palm vein
191:N automatic match
20Any biometric of the person
21Palm vein + face
22Fingerprint + palm vein
23Card + palm vein
24Palm vein + password
25Card + face + password
The event field of a record reports access-control events (door open/close, duress, ...) and is a different field from mode.
In exported xls reports the text of this column is derived by the device itself, so a few methods may appear under a similar name; values read through the API are always the raw values.

Appendix D: Device Capacity Field Descriptions

FieldDescription
usersizeMaximum number of user profiles
facesizeMaximum number of enrolled face templates
avatarsizeMaximum number of avatar photos
fpsizeMaximum number of fingerprints
palmsizeMaximum palm vein templates
cardsizeMaximum RFID card numbers
pwdsizeMaximum passwords
logsizeMaximum log record storage
useduserNumber of currently enrolled users
usedfaceNumber of enrolled face templates in use
usedavatarNumber of avatar photos in use
usedfpNumber of fingerprints in use
usedpalmNumber of palm veins in use
usedcardNumber of registered cards
usedpwdNumber of registered passwords
usedlogTotal number of log records stored
usednewlogNumber of unread/new log records
usedrtlogNumber of real-time log queue entries

Appendix E: Unknown Command Default Response

When a command is not recognized by the device:

JSON{
  "ret": "<original_command>",
  "sn": "LF00000001",
  "result": false,
  "reason": 1,
  "msg": "can not find this command"
}

Command Summary Table

CategoryCommands
User Managementsetuserinfo, deleteuser, cleanuser, setusername, getusername, getuserlist, getuserids, getunuserdid, checkuserid, getuserinfo, getallusers, adduser, checkregstatus, canceladduser, enableuser, getuserprofile, setuserprofile
Log Managementgetnewlog, getalllog, cleanlog, cleanlogphoto
Device Managementgetdevinfo, setdevinfo, getdevcap, gettime, settime, initsys, initmenu, cleandatebase, reboot, disabledevice, enabledevice, cleanadmin, cleaninactiveuser, checklive, getreg
Access Controlopendoor, lockctrl, getdoorstatus, setdevlock, getdevlock, getuserlock, setuserlock, deleteuserlock, cleanuserlock
Attendancegetshift, setshift, getbelltime, setbelltime, setholiday, getholiday
Device Active Reportssendlog, senduser, sendpin, sendqrcode, sendgps, otacheck, otaget
File Managementgetdir, getfile, writefile
System / Otherupgrade, forceota, setotaserver, getotaserver, setscreensaver, setvoice, keypad, verify, setdepartment, getdepartment, setcompanyname, getcompanyname, setquestionnaire, getquestionnaire, cleanquestionnaire
Video Intercomenablewebrtc, callaccept, viewready, answer, icecandidate, callcancel, talklock, monitorcall, setviselection, talkcall, vicheckonline
Device Registrationreg (Active_send_reg)
Total Unique Commands83

Document Version: 1.0

Last updated: 2026-09-22 — corrected the verifymode value reference, added the value table and fixed the example values

Compatible with AiFace Firmware: 1.0.0+

AiFace Device Web API Protocol Documentation (English)

Version: 1.0

Based on: webserver.cpp source code analysis

Protocol: HTTP + JSON

⚠️ Protocol Role Note: In the WebServer API, the device acts as an HTTP server, and browsers or other clients access the device as requesters. Therefore, this protocol is restricted to Local Area Network (LAN) use only — clients must be on the same network segment as the device to access it.

1. Overview

This document describes the HTTP API protocol of the embedded web server in AiFace facial recognition access control devices.

1.1 Server Architecture

ModePortDescription
HTTP80 (default) or customStandard HTTP

2. Connection & Authentication

2.1 Login Flow

Except for the getlang command, all /api commands require a password field in the request. The password is configured in the device's settings menu (mapped to DI_WEBSERVER_PWD).

Note: If no password has been set on the device (empty password), all password-required endpoints will return an error.

2.2 Request Endpoint

All JSON API requests are sent to:

POST http://<device_IP>:<port>/api
Content-Type: application/json

3. Common Request Format

JSON{
  "cmd": "<command_name>",
  "password": "<device_password>",
  // ... command-specific parameters
}
FieldTypeRequiredDescription
cmdstringYesCommand name
passwordstringYes (except getlang)Device management password

4. Common Response Format

JSON{
  "ret": "<command_name>",
  "sn": "<device_serial_number>",
  "result": true/false,
  // ... command-specific response data
}
FieldTypeDescription
retstringEchoes the request command name
snstringDevice serial number
resultboolWhether the operation succeeded
reasonnumberFailure reason code (only on failure)
msgstringFailure description text (only on failure)

5. Error Codes

reasonDescription
1User not found / Parameter format error
2Password incorrect / Password is empty
3Device busy (e.g., enrollment in progress)
5No face detected in image
6Multiple faces detected in image
7Image resolution too large
8Face area too large
9Face area too small
10Image quality too low
11Face position too off-center
12Duplicate face (already registered to another user)

6. HTTP Route Endpoints

EndpointMethodDescription
/apiPOSTMain JSON API entry point
/api/firmware/uploadPOSTChunked firmware upload
/download/reportGETDownload summary report (.xls)
/download/rawrecordGETDownload raw attendance records (.xls)
/photos/GETAccess user enrollment photos
/logphotos/GETAccess attendance log snapshot photos
/GETStatic file server (from /usr/webserver or /data/res/webserver)

7. JSON API Command Reference

7.1 Authentication & Device Info


7.1.1 `getlang` — Get Current Language

No password required

Request:

JSON{ "cmd": "getlang" }

Response:

JSON{
  "ret": "getlang",
  "sn": "SN123456",
  "result": true,
  "lang": "English"
}
FieldTypeDescription
langstringCurrent language name

7.1.2 `getlangoption` — Get Available Language List

Request:

JSON{ "cmd": "getlangoption", "password": "xxx" }

Response:

JSON{
  "ret": "getlangoption",
  "sn": "SN123456",
  "result": true,
  "lang": "English",
  "langs": [
    { "lvalue": 0, "ltitle": "English" },
    { "lvalue": 1, "ltitle": "简体中文" }
  ]
}
FieldTypeDescription
langstringCurrently active language
langsarrayAvailable language list (only languages enabled in device settings)
langs[].lvaluenumberLanguage code
langs[].ltitlestringLanguage display name

7.1.3 `login` — Login Verification

Request:

JSON{
  "cmd": "login",
  "username": "admin",
  "password": "xxx"
}
FieldTypeRequiredDescription
usernamestringYesMust be "admin"
passwordstringYesDevice password

Response (success):

JSON{
  "ret": "login",
  "sn": "SN123456",
  "result": true
}

Response (failure):

JSON{
  "ret": "login",
  "sn": "SN123456",
  "result": false,
  "reason": 1,
  "msg": "username error"
}

7.1.4 `reg` — Get Full Device Registration Info

Request:

JSON{ "cmd": "reg", "password": "xxx" }

Response devinfo field breakdown:

FieldTypeDescription
modelnamestringDevice model name
manufacturerstringManufacturer
fpalgostringFingerprint algorithm version (e.g., "thbio3.0")
firmwarestringFirmware version
timestringCurrent device time YYYY-MM-DD HH:MM:SS
curipstringCurrent IP address
macstringMAC address
timezonestringTimezone string
bandwidth_upstringUpload bandwidth
bandwidth_downstringDownload bandwidth
disksizestringTotal disk capacity (MB)
useddiskstringUsed disk space (MB)
deviceidnumberDevice ID
usersizenumberMax user capacity
facesizenumberMax face enrollment capacity
avatarsizenumberMax avatar capacity
fpsizenumberMax fingerprint capacity
palmsizenumberMax palm print capacity
cardsizenumberMax card capacity
pwdsizenumberMax password capacity
logsizenumberMax log capacity
usedusernumberCurrent enrolled user count
usedfacenumberCurrent enrolled face count
usedavatarnumberCurrent enrolled avatar count
usedfpnumberCurrent enrolled fingerprint count
usedpalmnumberCurrent enrolled palm print count
usedcardnumberCurrent enrolled card count
usedpwdnumberCurrent enrolled password count
usedlognumberTotal log count
usednewlognumberNew (unread) log count
usedrtlognumberReal-time log count
netinusenumberActive network: 0=none, 1=wired, 2=WiFi, 3=4G
usb4gnumberUSB 4G dongle present: 0/1
batterynumberBattery level
cpu_tempnumberCPU temperature (°C)
intercomnumberIntercom supported: 0/1
elevator_controlnumberElevator control enabled: 0/1
floorsnumberTotal floor count
base_floornumberBase floor number
have_g_floornumberHas G (ground) floor: 0/1
acces_stimesnumberAccess times
charidnumberCharacter ID
useosdpnumberOSDP protocol in use: 0/1
facetemplatenumberFace template mode
usequestionnumberQuestionnaire enabled: 0/1
onlinedebugnumberOnline debug mode: 0/1
dislanguagenumberDisabled language bitmask
ntpnumberNTP enabled: 0/1
station_mccnumberStation MCC
station_mncnumberStation MNC
station_lacnumberStation LAC
station_cidnumberStation CID
gprsipstring4G module IP
gprsmacstring4G module MAC
gprsversionstring4G module model
gprsimeistring4G module IMEI

7.1.5 `getdevinfo` — Get Device Configuration Parameters

Request:

JSON{ "cmd": "getdevinfo", "password": "xxx" }

Response: Returns all DI_* configuration key-value pairs.

Response Example:

JSON{
  "ret": "getdevinfo",
  "sn": "SN123456",
  "result": true,
  "deviceid": 1,
  "language": 0,
  "managers": 1,
  "verifymode": 0,
  "volume": 80,
  "netipaddress": "192.168.1.100",
  "serverip": "192.168.1.200",
  "wlan_ssid": "MyWiFi",
  "door_opentime": 5,
  "live_detect": 1,
  "fcmatch_level": 60
}

Complete Configuration Parameter List:

##### General Settings

FieldTypeDescription
deviceidnumberDevice ID
languagenumberLanguage
managersnumberNumber of administrators
verifymodenumberVerification mode (see Appendix 10)
volumenumberVolume
video_claritynumberVideo clarity
micvolumenumberMicrophone volume
intercomvolumenumberIntercom volume
date_formatnumberDate format
label_stylenumberLabel style
keyboardnumberKeyboard settings
usegpsnumberUse GPS
time_formatnumberTime format
use_dstnumberUse daylight saving time
dst_startnumberDST start time
dst_endnumberDST end time
show_avatarnumberShow avatar
show_batterynumberShow battery
use_qrcodenumberEnable QR code
screensavertimenumberScreen saver timeout (seconds)
showresulttimenumberVerification result display time (seconds)
sleeptimenumberSleep time (seconds)
screensaver_wakeupnumberScreen saver wake-up mode
stranger_photonumberStranger photo
stranger_locknumberStranger lock
verifyfail_hintnumberVerification failure hint
userid_formatnumberUser ID format
rfid_free_regnumberRFID free registration
rfid_auto_regnumberRFID auto registration
shift_weekend_otnumberShift weekend overtime
rfid_module_typenumberRFID module type
filllightnumberFill light
filllight_periodnumberFill light period
accept_dosenumberAccept dose
face_double_checknumberFace double check
glog_warningnumberGate log warning threshold
slog_warningnumberSystem log warning threshold
reverifytimenumberRe-verification interval (seconds)
use_logphotonumberUse log photo
tts_voicenumberTTS voice
online_debugnumberOnline debug
hide_otanumberHide OTA upgrade
multifacesnumberMulti-face recognition
disable_menunumberDisable menu
server_keypadnumberServer keypad
keypad_pwdnumberKeypad password
reverify_nolocknumberRe-verify without lock
default_shiftnumberDefault shift
saturday_attendnumberSaturday attendance
sunday_attendnumberSunday attendance
allow_latetimenumberAllowed late time (minutes)
allow_earlytimenumberAllowed early leave time (minutes)
auto_signnumberAuto sign-in
shift_weekendnumberShift weekend
excel_passwordstringExcel export password
nosavelognumberDo not save logs
hide_privacynumberPrivacy protection
reboottime1numberScheduled reboot time 1
reboottime2numberScheduled reboot time 2
reboottime3numberScheduled reboot time 3
reg_card_1numberRegistration card 1
reg_card_2numberRegistration card 2
reg_card_3numberRegistration card 3
selfchecklognumberSelf-check log
questionnairenumberQuestionnaire
questionnaire_cardnumberQuestionnaire card
questionnaire_switch_cardnumberQuestionnaire switch card
event_schedulenumberEvent schedule 0
event_schedule1numberEvent schedule 1
event_schedule2numberEvent schedule 2
event_schedule3numberEvent schedule 3
event_schedule4numberEvent schedule 4
event_schedule5numberEvent schedule 5
event_schedule6numberEvent schedule 6
event_schedule7numberEvent schedule 7
event_schedule8numberEvent schedule 8
bellcountnumberBell count
belloutputnumberBell output
ring_stylenumberRing style

##### Biometric Settings

FieldTypeDescription
live_detectnumberLiveness detection switch
live_levelnumberLiveness detection level
fcmatch_levelnumberFace matching threshold
identify_distancenumberIdentification distance
fpmatch_levelnumberFingerprint matching threshold
palm_vein_levelnumberPalm vein level
palm_det_levelnumberPalm detection level
fps_perusernumberFingerprints per user
disable_facenumberDisable face
enable_palmnumberEnable palm

##### Serial & Network Settings

FieldTypeDescription
usedcomnumberSerial port in use
combauratenumberSerial baud rate
netipaddressIPEthernet IP address
netmaskIPSubnet mask
netgatewayIPGateway
use_eth_dhcpnumberUse Ethernet DHCP
commpasswordnumberCommunication password
netportnumnumberNetwork port number
rs485_funnumberRS485 function
use_wlannumberUse WiFi
use_wlan_dhcpnumberUse WiFi DHCP
wlan_ip_addressIPWiFi IP address
wlan_net_maskIPWiFi subnet mask
wlan_gatewayIPWiFi gateway
wlan_ssidstringWiFi SSID
wlan_pwdstringWiFi password
gprs_apnstringGPRS APN
gps_durationnumberGPS report interval
gprs_ipaddressnumberGPRS IP address
gprs_macaddressnumberGPRS MAC address

##### Server Settings

FieldTypeDescription
serveripIPServer IP address
serverportnumberServer port
webserverportnumberWeb server port
server_response_timenumberServer response timeout
user_add_enablenumberAllow adding users
use_bsnumberUse backend service
use_webservernumberUse web server
bs_domain_namestringBackend service domain name
use_domain_namenumberUse domain name
dns_server_ipIPDNS server IP
server_dns_namestringServer domain name
server_verifynumberServer verification mode
server_verify_timeoutnumberServer verification timeout
use_ntpnumberUse NTP
ntp_timezonenumberNTP timezone

##### Door Access Settings

FieldTypeDescription
door_opentimenumberDoor open time (seconds)
door_sensor_typenumberDoor sensor type
door_alarm_timenumberDoor alarm time
door_firealarminnumberFire alarm input
door_interlocknumberDoor interlock
door_mutiopennumberMulti-door open
door_trycountnumberAttempt count alarm
access_timesnumberAccess times
door_antipassnumberAnti-passback
multiusersnumberMulti-user verification
door_passwordnumberDoor password
timezone_punchsnumberTimezone punch
access_denied_nolognumberAccess denied without log
outof_notimzone_deniednumberDeny out-of-timezone
elevator_controlnumberElevator control
floor_numbernumberFloor number
base_floornumberBase floor
have_g_floornumberHas G floor
elevator_keypadnumberElevator keypad
maintenance_cardnumberMaintenance card

##### Wiegand Settings

FieldTypeDescription
wiegand_output_modenumberWiegand output mode
card_disp_formatnumberCard display format
card_reversalnumberCard reversal
wg_reversalnumberWiegand reversal
wiegand_output_bitnumberWiegand output bits
wiegand_outside_inputnumberWiegand outside input
alarm_outputnumberAlarm output
outwg_shotnumberWiegand output trigger
wiegand_portnumberWiegand port

##### Card & Security Settings

FieldTypeDescription
bio_to_cardnumberBiometric to card number
bio_verify_waivernumberBiometric verify waiver
bio_deletionnumberBiometric deletion
bio_user_deletionnumberUser biometric deletion
cpucard_keystringCPU card key
qrcode_pwdstringQR code password
webserver_pwdstringWeb server password

##### Other Settings

FieldTypeDescription
threatnumberThreat level
hide_ipnumberHide IP display
key_locknumberKey lock
face_wakeup_secondsnumberFace wake-up time (seconds)
Type Notes: number = numeric, IP = IP address string (e.g. "192.168.1.100"), string = plain string.

7.1.6 `setdevinfo` — Set Device Configuration Parameters

Request:

JSON{
  "cmd": "setdevinfo",
  "password": "xxx",
  "nowtime": 1700000000,
  "deviceid": 1,
  "volume": 80,
  "live_detect": 1,
  "fcmatch_level": 60
}
FieldTypeRequiredDescription
nowtimenumberNoUnix timestamp (seconds) for time sync
Other fields-NoAny DI_* configuration key-value pairs; only include items you want to modify
Type Rules:
- IP-type fields (e.g. netipaddress, serverip, etc.) accept IP address strings like "192.168.1.100"
- String-type fields (e.g. wlan_ssid, excel_password, cpucard_key, etc.) accept string values
- All other fields are numeric and accept numbers

7.1.7 `getdevcap` — Get Device Capacity Info

Request:

JSON{ "cmd": "getdevcap", "password": "xxx" }

Response:

JSON{
  "ret": "getdevcap",
  "sn": "SN123456",
  "result": true,
  "usersize": 10000,
  "facesize": 10000,
  "avatarsize": 10000,
  "fpsize": 30000,
  "palmsize": 30000,
  "cardsize": 10000,
  "pwdsize": 10000,
  "logsize": 100000,
  "useduser": 150,
  "usedface": 148,
  "usedavatar": 100,
  "usedfp": 10,
  "usedpalm": 0,
  "usedcard": 50,
  "usedpwd": 20,
  "usedlog": 5000,
  "usednewlog": 100,
  "usedrtlog": 5
}
FieldTypeDescription
usersizenumberMax user capacity
facesizenumberMax face enrollment capacity
avatarsizenumberMax avatar capacity
fpsizenumberMax fingerprint capacity
palmsizenumberMax palm print capacity
cardsizenumberMax card capacity
pwdsizenumberMax password capacity
logsizenumberMax log capacity
usedusernumberCurrent enrolled user count
usedfacenumberCurrent enrolled face count
usedavatarnumberCurrent enrolled avatar count
usedfpnumberCurrent enrolled fingerprint count
usedpalmnumberCurrent enrolled palm print count
usedcardnumberCurrent enrolled card count
usedpwdnumberCurrent enrolled password count
usedlognumberTotal log count
usednewlognumberNew (unread) log count
usedrtlognumberReal-time log count

7.2 User Management


7.2.1 `getuserlist` — Get User List (Paginated)

Request:

JSON{
  "cmd": "getuserlist",
  "password": "xxx",
  "stn": 1
}
FieldTypeDescription
stnnumber1 = start from beginning; 0 = continue to next page

Response:

JSON{
  "ret": "getuserlist",
  "sn": "SN123456",
  "result": true,
  "count": 100,
  "to": 50,
  "record": [
    {
      "id": "1001",
      "name": "John Doe",
      "department": "Engineering",
      "shift": 0,
      "admin": 0,
      "fingerprint": 2,
      "palm": 0,
      "face": 1,
      "password": 0,
      "card": 12345678,
      "weekzone": 0,
      "group": 0,
      "access_times": 0,
      "verifymode": 0,
      "enable": 1,
      "birthday": "01-15",
      "starttime": "2024-01-01 00: 00",
      "endtime": "2025-12-31 23: 59",
      "photourl": "/photos/LF00001001.jpg"
    }
  ]
}
FieldTypeDescription
countnumberTotal user count
tonumberNumber of records returned (0 if no more data)
record[]arrayArray of user objects (max 50 per page)
record[].idstringUser ID
record[].namestringUser name
record[].departmentstringDepartment
record[].shiftnumberShift ID
record[].adminnumberAdmin flag (0=user, 1=admin)
record[].fingerprintnumberEnrolled fingerprint count
record[].palmnumberEnrolled palm print count
record[].facenumberEnrolled face count
record[].passwordnumberPassword set flag
record[].cardnumberCard ID
record[].weekzonenumberWeek zone ID
record[].groupnumberGroup ID
record[].access_timesnumberAllowed access times
record[].verifymodenumberVerification mode (see Appendix 10)
record[].enablenumberEnable flag (1=enabled, 0=disabled)
record[].birthdaystringBirthday "MM-DD" (append * for lunar)
record[].starttimestringValid start time
record[].endtimestringValid end time
record[].photourlstringPhoto URL (if available)
record[].userprofilestringUser profile string (conditional)
Returns up to 50 records per call. Call repeatedly with stn=0 until to >= count or to == 0.

7.2.2 `getuserids` — Get All User IDs

Request:

JSON{ "cmd": "getuserids", "password": "xxx" }

Response:

JSON{
  "ret": "getuserids",
  "sn": "SN123456",
  "result": true,
  "count": 3,
  "record": ["1001", "1002", "1003"]
}
FieldTypeDescription
countnumberTotal user count
recordarrayArray of user ID strings

7.2.3 `getunuserdid` — Get Next Available User ID

Request:

JSON{ "cmd": "getunuserdid", "password": "xxx" }

Response:

JSON{
  "ret": "getunuserdid",
  "sn": "SN123456",
  "result": true,
  "enrollid": "1004"
}
FieldTypeDescription
enrollidstringNext unused user ID

7.2.4 `checkuserid` — Check If User ID Exists

Request:

JSON{
  "cmd": "checkuserid",
  "password": "xxx",
  "enrollid": "1001"
}
FieldTypeDescription
enrollidstring/numberUser ID to check

Response:

JSON{
  "ret": "checkuserid",
  "sn": "SN123456",
  "result": true,
  "exists": true
}
FieldTypeDescription
existsboolWhether the user ID exists

7.2.5 `getuserinfo` — Get Single User Details

Request:

JSON{
  "cmd": "getuserinfo",
  "password": "xxx",
  "enrollid": "1001",
  "backupnum": 50
}
FieldTypeDescription
enrollidstring/numberUser ID or alias ID
backupnumnumberOptional — retrieve specific biometric data (see Appendix)

Response (with face photo, backupnum=50):

JSON{
  "ret": "getuserinfo",
  "sn": "SN123456",
  "result": true,
  "enrollid": "1001",
  "name": "John Doe",
  "department": "Engineering",
  "admin": 0,
  "pwd": 0,
  "card": 12345678,
  "fpflag": 3,
  "fpcnt": 2,
  "palmflag": 1,
  "palmcnt": 1,
  "faceflag": 1,
  "birthday": "01-15",
  "starttime": "2024-01-01 00: 00: 00",
  "endtime": "2025-12-31 23: 59: 59",
  "photourl": "/photos/LF00001001.jpg",
  "backupnum": 50,
  "record": "<Base64-encoded face photo>"
}

Response (user not found):

JSON{
  "ret": "getuserinfo",
  "sn": "SN123456",
  "result": false,
  "reason": 1,
  "msg": "can not find the user",
  "enrollid": "1001"
}
FieldTypeDescription
enrollidstringUser ID
namestringUser name
departmentstringDepartment
adminnumberAdmin flag
pwdnumberPassword flag
cardnumberCard ID (conditional)
fpflagnumberFingerprint flag bitmask (conditional)
fpcntnumberEnrolled fingerprint count (conditional)
palmflagnumberPalm print flag (conditional)
palmcntnumberEnrolled palm print count (conditional)
faceflagnumberFace flag (conditional)
enablenumberUser enabled flag (conditional)
birthdaystringBirthday "MM-DD" (conditional)
shiftidnumberShift ID (conditional)
verifymodenumberVerification mode (conditional; see Appendix 10)
zoneidnumberTime zone ID (conditional)
groupidnumberGroup ID (conditional)
access_timesnumberAllowed access times (conditional)
postidnumberDepartment/post ID (conditional)
starttimestringValid start time (conditional)
endtimestringValid end time (conditional)
userprofilestringUser profile string (conditional)
backupnumnumberRequested backupnum (conditional)
recordstringBase64 biometric data (conditional, varies by backupnum)
photourlstringPhoto URL (conditional)

record format by backupnum:

backupnumrecord formatDescription
0–9stringFingerprint template — hex with zero run-length compression ((N) = N consecutive 0x00 bytes), 810 bytes after decoding. Omitted when the slot is empty.
10numberUser password
11numberCard number
40 / 41stringPalm vein template — Base64, 1548 bytes after decoding
50stringFace JPEG photo — Base64
51stringFace feature + key points — Base64, 1074 bytes after decoding (2-byte header + 1072-byte feature)
An exported record can be pushed verbatim to another device with setuserinfo (using the same backupnum) to migrate biometric templates.

7.2.6 `setuserinfo` — Add or Update User Information

Request:

JSON{
  "cmd": "setuserinfo",
  "password": "xxx",
  "enrollid": "1001",
  "name": "John Doe",
  "admin": 0,
  "pwd": 123456,
  "card": 12345678,
  "department": "Engineering",
  "birthday": "01-15",
  "starttime": "2024-01-01 00: 00: 00",
  "endtime": "2025-12-31 23: 59: 59",
  "verifymode": 0,
  "shiftid": 1,
  "zoneid": 1,
  "groupid": 0,
  "access_times": 0,
  "enable": 1,
  "face": "<Base64-encoded face photo>"
}
FieldTypeDescription
enrollidstring/numberUser ID (string or number)
namestringFull name
adminnumberPrivilege: 0=regular user, 1=administrator
pwdnumberPassword (numeric)
cardnumber/stringRFID card ID
departmentstringDepartment name (auto-created if not found)
postidnumberDepartment/post ID
birthdaystringBirthday in MM-DD format (append * for lunar calendar)
starttimestringValid start datetime YYYY-MM-DD HH:MM:SS
endtimestringValid end datetime YYYY-MM-DD HH:MM:SS
verifymodenumberUser verification mode (0 = any method; see Appendix 10)
shiftidnumberShift ID
zoneidnumberTime zone ID
groupidnumberGroup ID
access_timesnumberAllowed pass count (0=unlimited, max 30000)
enablenumberUser enabled: 0/1
facestringBase64-encoded face image (JPEG, ≤512KB)
backupnumnumberBiometric slot index (see Appendix 9)
recordstringBiometric template data; encoding depends on backupnum (see below)
userprofilestringUser profile string

How each biometric type is pushed:

BiometricbackupnumData fieldrecord encodingLength after decoding
Face photoomitted (or 50)faceBase64 (JPEG)≤ 512KB
Fingerprint0–9 (finger index)recordHex + zero run-length compression (not Base64)810 bytes
Palm vein / palm print40 = left, 41 = rightrecordBase641548 bytes
Face feature + key points51recordBase641074 bytes (2-byte header + 1072-byte feature)
⚠️ The fingerprint record is not Base64 — it is a "hex + zero run-length" text string. Only palm vein and face feature use Base64. The decoded length must match the table exactly, otherwise the device replies "xxx data error".

record encoding rules:

backupnumEncoding rule
0–9 fingerprintEach byte as 2 lowercase hex digits; runs of N 0x00 bytes are compressed to (N). E.g. 00 00 00 → (3), and bytes 0a 1f 00 00 2b → 0a1f(2)2b. Must decode to exactly 810 bytes.
40 / 41 palm veinStandard Base64, must decode to exactly 1548 bytes (Base64 string is always 2064 characters).
51 face featureStandard Base64, must decode to exactly 1074 bytes: 2-byte template header (08 06 on regular platforms, 08 10 on BOARD_CORE_810) followed by the 1072-byte feature vector, which already contains 10 float face key points and the normalization parameters.
50 face photoReturned as Base64 JPEG by getuserinfo only; push photos with the face field.

Recommended call order: create the user first with a setuserinfo call that carries no biometric data, then push each template by backupnum. Pushing backupnum=51 for a non-existent user fails with "face error".

Response (success):

JSON{
  "ret": "setuserinfo",
  "sn": "SN123456",
  "result": true,
  "enrollid": "1001",
  "backupnum": 50
}

Response (failure):

JSON{
  "ret": "setuserinfo",
  "sn": "SN123456",
  "result": false,
  "reason": 5,
  "msg": "no face",
  "enrollid": "1001"
}

Face enrollment failure reason codes:

reasonDescription
1Image file too large
5No face detected
6Multiple faces detected
7Image dimensions too large
8Face region too large
9Face region too small
10Image quality too low
11Face position too off-center
12Duplicate face (already registered to another user ID, e.g. face is double,id=1002)

Example 1 — push a face photo (face field, device extracts the feature on site):

JSON{
  "cmd": "setuserinfo",
  "password": "xxx",
  "enrollid": "1001",
  "name": "John Doe",
  "face": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL..."
}
JSON{
  "ret": "setuserinfo",
  "sn": "SN123456",
  "result": true,
  "enrollid": "1001"
}

Example 2 — push a fingerprint (slot 0, backupnum=0, record is the compressed hex string):

JSON{
  "cmd": "setuserinfo",
  "password": "xxx",
  "enrollid": "1001",
  "backupnum": 0,
  "record": "0a1f2b(807)"
}
The sample above is a complete, format-valid payload: 3 hex bytes followed by (807) (807 0x00 bytes), which decodes to exactly 810 bytes. Minimal testable payload: "record": "(810)", which decodes to 810 0x00 bytes and passes format validation. To push a real template, export the same encoding from an enrolled device with getuserinfo (backupnum=0) or bioread.

Example 3 — push a palm vein template (left hand, backupnum=40; right hand is 41):

JSON{
  "cmd": "setuserinfo",
  "password": "xxx",
  "enrollid": "1001",
  "backupnum": 40,
  "record": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA..."
}
record is standard Base64 and must decode to exactly 1548 bytes (the Base64 string is always 2064 characters). Minimal testable payload: Base64 of 1548 0x00 bytes (2064 A characters).

Example 4 — push a face feature with key points (backupnum=51, record is Base64):

JSON{
  "cmd": "setuserinfo",
  "password": "xxx",
  "enrollid": "1001",
  "backupnum": 51,
  "record": "CAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA..."
}
record is standard Base64 and must decode to exactly 1074 bytes. Minimal testable payload: 08 06 + 1072 0x00 bytes, i.e. a Base64 string starting with CAYA followed by 1428 A characters (1432 characters in total); on BOARD_CORE_810 use the 08 10 header instead (Base64 starts with CBAA). Export real features from an enrolled device with getuserinfo (backupnum=51) and feed them back to other devices unchanged.

Response (success):

JSON{
  "ret": "setuserinfo",
  "sn": "SN123456",
  "result": true,
  "enrollid": "1001",
  "backupnum": 51
}
The response echoes backupnum whenever it was present in the request.

Response (failures):

JSON{
  "ret": "setuserinfo",
  "sn": "SN123456",
  "result": false,
  "reason": 12,
  "msg": "finger already used,id=1002",
  "finger": 0,
  "enrollid": "1001",
  "backupnum": 0
}
JSON{
  "ret": "setuserinfo",
  "sn": "SN123456",
  "result": false,
  "reason": 1,
  "msg": "palm data error",
  "palm": 0,
  "enrollid": "1001",
  "backupnum": 40
}
reasonmsgDescription
1space overflowFace or fingerprint database is full
1base64 wrongface field failed Base64 decoding
3file size=0Image byte count is 0
1record can not emptybackupnum 0–9 but record is missing
1finger data errorFingerprint string is malformed or does not decode to 810 bytes
1palm data errorPalm vein Base64 is malformed or does not decode to 1548 bytes
1palm save failedPalm vein could not be written to the device
1face errorFace feature could not be written (user missing or feature DB full)
12finger already used,id=xxxFingerprint duplicated with another user (response carries finger)
12palm already used,id=xxxPalm vein duplicated with another user (response carries palm)
12face is double,id=xxxFace duplicated with another user
12card already used,id=xxxCard number already owned by another user (response carries card)
5/6/7/8/9/10/11see table aboveFace photo extraction failed on device
The reason=12 duplicate checks (face / fingerprint / palm vein / card) are controlled by the device duplicate-check switch; when it is off, no check is made and the data overwrites the existing entry.

7.2.7 `deleteuser` — Delete User or Specific Biometric Data

Request:

JSON{
  "cmd": "deleteuser",
  "password": "xxx",
  "enrollid": "1001",
  "backupnum": 12
}
FieldTypeDescription
enrollidstring/numberUser ID or alias ID
backupnumnumberAction type (see table below)
backupnumAction
12 or 13Delete entire user
0-9Delete fingerprint at specified index
10Clear password
11Clear card
40/41Delete left/right palm print
50 or 51Delete face

Response:

JSON{
  "ret": "deleteuser",
  "sn": "SN123456",
  "result": true,
  "backupnum": 12,
  "enrollid": "1001"
}
FieldTypeDescription
backupnumnumberEchoed backupnum value
enrollidstringUser ID

7.2.8 `deleteuserface` — Delete User Face

Request:

JSON{
  "cmd": "deleteuserface",
  "password": "xxx",
  "enrollid": "1001"
}
FieldTypeDescription
enrollidstring/numberUser ID or alias ID

Response:

JSON{
  "ret": "deleteuserface",
  "sn": "SN123456",
  "result": true,
  "enrollid": "1001"
}

7.2.9 `deleteuserfp` — Delete All User Fingerprints

Request:

JSON{
  "cmd": "deleteuserfp",
  "password": "xxx",
  "enrollid": "1001"
}
FieldTypeDescription
enrollidstring/numberUser ID or alias ID

Response:

JSON{
  "ret": "deleteuserfp",
  "sn": "SN123456",
  "result": true,
  "enrollid": "1001"
}

7.2.10 `deleteuserpalm` — Delete All User Palm Prints

Request:

JSON{
  "cmd": "deleteuserpalm",
  "password": "xxx",
  "enrollid": "1001"
}
FieldTypeDescription
enrollidstring/numberUser ID or alias ID

Response:

JSON{
  "ret": "deleteuserpalm",
  "sn": "SN123456",
  "result": true,
  "enrollid": "1001"
}

7.2.11 `deleteusers` — Batch Delete Users

Request:

JSON{
  "cmd": "deleteusers",
  "password": "xxx",
  "list": ["1001", "1002", "1003"]
}
FieldTypeDescription
listarrayArray of user IDs (string or number) to delete

Response:

JSON{
  "ret": "deleteusers",
  "sn": "SN123456",
  "result": true
}

7.2.12 `cleanuser` — Delete All Users

Request:

JSON{ "cmd": "cleanuser", "password": "xxx" }
⚠️ DESTRUCTIVE: Removes all enrolled users from the device.

Response:

JSON{
  "ret": "cleanuser",
  "sn": "SN123456",
  "result": true
}

7.2.13 `enableuser` — Enable or Disable a User

Request:

JSON{
  "cmd": "enableuser",
  "password": "xxx",
  "enrollid": "1001",
  "enflag": 1
}
FieldTypeDescription
enrollidstring/numberUser ID or alias ID
enflagnumber1=enable, 0=disable (default: 1)

Response:

JSON{
  "ret": "enableuser",
  "sn": "SN123456",
  "result": true,
  "enrollid": "1001"
}

7.3 Biometric Enrollment (Device-Side)


7.3.1 `adduser` — Trigger On-Device Biometric Enrollment

Triggers the device's local screen to perform fingerprint/palm/face enrollment.

Request:

JSON{
  "cmd": "adduser",
  "password": "xxx",
  "enrollid": "1001",
  "name": "John Doe",
  "admin": 0,
  "backupnum": 50,
  "flag": 0
}
FieldTypeDescription
cancelboolSet to true to cancel current enrollment
enrollidstring/numberUser ID
backupnumnumberEnrollment type (see Appendix)
adminnumberWhether to enroll as administrator
flagnumberFlag bits
namestringUser name

Response (success):

JSON{
  "ret": "adduser",
  "sn": "SN123456",
  "result": true,
  "backupnum": 50,
  "enrollid": "1001"
}

Response (cancel):

JSON{
  "ret": "adduser",
  "result": true,
  "cancel": true
}

Response (failure):

JSON{
  "ret": "adduser",
  "sn": "SN123456",
  "result": false,
  "reason": 3,
  "msg": "device busy",
  "backupnum": 50,
  "enrollid": "1001"
}

Failure reason codes:

reasonDescription
1Empty user ID
2Invalid backupnum
3Device busy (enrollment already in progress)

7.3.2 `checkregstatus` — Query Enrollment Status

Request:

JSON{ "cmd": "checkregstatus", "password": "xxx" }

Response:

JSON{
  "ret": "checkregstatus",
  "sn": "SN123456",
  "result": true,
  "status": 1,
  "msg": "success",
  "image": "<Base64-encoded preview image>"
}
FieldTypeDescription
statusnumberEnrollment status code (see table below)
msgstringOne-time status message (cleared after read)
imagestringBase64 preview image (conditional)
statusDescription
-1Idle / cancelled
0Enrollment in progress
1Enrollment succeeded
otherEnrollment failed

7.4 Log Management


7.4.1 `getlog` — Get Historical Logs (Paginated)

Request:

JSON{
  "cmd": "getlog",
  "password": "xxx",
  "index": 0,
  "enrollid": "1001",
  "from": "2024-06-01",
  "to": "2024-12-31"
}
FieldTypeDescription
indexnumberStart position (0 = begin new query)
enrollidstring/numberOptional — filter by specific user (only when index=0)
fromstringOptional — start date YYYY-MM-DD format
tostringOptional — end date YYYY-MM-DD format

Response (up to 50 records per page):

JSON{
  "ret": "getlog",
  "sn": "SN123456",
  "result": true,
  "count": 500,
  "from": 0,
  "to": 50,
  "record": [
    {
      "enrollid": "1001",
      "name": "John Doe",
      "time": "2024-06-01 09: 00: 00",
      "mode": 1,
      "inout": 1,
      "event": 0,
      "note": "remark",
      "photourl": "/logphotos/logimage123.jpg"
    }
  ]
}
FieldTypeDescription
countnumberTotal matching log count
fromnumberStart index of returned records
tonumberEnd index of returned records
record[]arrayLog record array (max 50 per page)
record[].enrollidstringUser ID
record[].namestringUser name
record[].timestringTimestamp
record[].modenumberVerification method (1=face, 2=fingerprint, 3=card, 4=password, etc.)
record[].inoutnumberDirection: 1=entry, 0=exit
record[].eventnumberEvent type code
record[].notestring/objectRemark or additional note (conditional)
record[].photourlstringSnapshot photo URL (conditional)
Call repeatedly with incrementing index until to >= count.

7.4.2 `getrtlog` — Get Real-Time Logs (Consumed on Read)

Request:

JSON{ "cmd": "getrtlog", "password": "xxx", "index": 0 }
FieldTypeDescription
indexnumberStart position (0 = begin new query)

Response:

JSON{
  "ret": "getrtlog",
  "sn": "SN123456",
  "result": true,
  "count": 25,
  "from": 0,
  "to": 20,
  "record": [
    {
      "enrollid": "1001",
      "name": "John Doe",
      "time": "2024-06-01 09: 00: 00",
      "mode": 1,
      "inout": 1,
      "event": 0,
      "note": "remark"
    }
  ]
}
FieldTypeDescription
countnumberTotal real-time log count in queue
fromnumberStart index
tonumberEnd index
record[]arrayLog record array (max 20 per page), same fields as getlog
Real-time logs are removed from the queue once read. Up to 20 records per page. Call repeatedly with incrementing index until to >= count.

7.4.3 `setlogs` — Mark Logs as Synced

Request:

JSON{
  "cmd": "setlogs",
  "password": "xxx",
  "records": [
    { "id": "1001", "event": 0, "mode": 1, "time": "2024-06-01 09: 00: 00" }
  ]
}
FieldTypeDescription
recordsarrayArray of log records to mark as synced
records[].idstring/numberUser ID
records[].eventnumberEvent type
records[].modenumberVerification mode
records[].timestringLog timestamp

Response:

JSON{
  "ret": "setlogs",
  "sn": "SN123456",
  "result": true
}

7.4.4 `cleanlog` — Clear All Logs

Request:

JSON{ "cmd": "cleanlog", "password": "xxx" }
⚠️ DESTRUCTIVE: Removes all historical attendance logs.

Response:

JSON{
  "ret": "cleanlog",
  "sn": "SN123456",
  "result": true
}

7.4.5 `cleanlogphoto` — Clear All Log Photos

Request:

JSON{ "cmd": "cleanlogphoto", "password": "xxx" }

Response:

JSON{
  "ret": "cleanlogphoto",
  "sn": "SN123456",
  "result": true
}

7.5 System Management


7.5.1 `gettime` — Get Device Time

Request:

JSON{ "cmd": "gettime", "password": "xxx" }

Response:

JSON{
  "ret": "gettime",
  "sn": "SN123456",
  "time": "2024-06-01 10: 00: 00"
}
FieldTypeDescription
timestringCurrent device time

7.5.2 `settime` — Set Device Time

Method 1 (string format):

JSON{
  "cmd": "settime",
  "password": "xxx",
  "cloudtime": "2024-06-01 10: 00: 00"
}

Method 2 (Unix timestamp in seconds):

JSON{
  "cmd": "settime",
  "password": "xxx",
  "nowtime": 1717200000
}
FieldTypeDescription
cloudtimestringTime string in YYYY-MM-DD HH:MM:SS format (use this or nowtime)
nowtimenumberUnix timestamp in seconds (use this or cloudtime)

Response (success):

JSON{
  "ret": "settime",
  "sn": "SN123456",
  "result": true
}

Response (failure):

JSON{
  "ret": "settime",
  "sn": "SN123456",
  "result": false,
  "reason": 1
}
Validates year >= 2021, month 1-12, day, hour, minute, second ranges. Returns reason 1 on failure.

7.5.3 `reboot` — Reboot Device

Request:

JSON{ "cmd": "reboot", "password": "xxx" }
⚠️ No response — the device reboots immediately. The HTTP connection will be dropped.

7.5.4 `disabledevice` — Disable Device (Pause Recognition)

Request:

JSON{ "cmd": "disabledevice", "password": "xxx" }

Response:

JSON{
  "ret": "disabledevice",
  "sn": "SN123456",
  "result": true
}
The response is sent first, then the device disables face/fingerprint/palm/ID card recognition.

7.5.5 `enabledevice` — Enable Device (Resume Recognition)

Request:

JSON{ "cmd": "enabledevice", "password": "xxx" }

Response:

JSON{
  "ret": "enabledevice",
  "sn": "SN123456",
  "result": true
}

7.5.6 `initsys` — Full System Initialization (Clear All Data)

⚠️ DESTRUCTIVE: Clears all users, logs, and settings (language setting is preserved). Also removes bell schedules, post data, attendance settings, and lock data. Backs up WiFi configuration.

Request:

JSON{ "cmd": "initsys", "password": "xxx" }

Response:

JSON{
  "ret": "initsys",
  "sn": "SN123456",
  "result": true
}

7.5.7 `initmenu` — Reset Menu Settings (Preserve User Data)

Request:

JSON{ "cmd": "initmenu", "password": "xxx" }

Response:

JSON{
  "ret": "initmenu",
  "sn": "SN123456",
  "result": true
}
Same as initsys but does NOT clear user database or log database.

7.5.8 `cleandatebase` — Clear Log Database

Request:

JSON{ "cmd": "cleandatebase", "password": "xxx" }
⚠️ DESTRUCTIVE: Clears entire database and sets a reboot flag. Device will reboot after this operation.

Response:

JSON{
  "ret": "cleandatebase",
  "sn": "SN123456",
  "result": true
}

7.5.9 `cleanadmin` — Remove All Administrator Privileges

Request:

JSON{ "cmd": "cleanadmin", "password": "xxx" }

Response:

JSON{
  "ret": "cleanadmin",
  "sn": "SN123456",
  "result": true
}

7.5.10 `cleaninactiveuser` — Remove Users Without Biometric Data

Request:

JSON{ "cmd": "cleaninactiveuser", "password": "xxx" }

Response:

JSON{
  "ret": "cleaninactiveuser",
  "sn": "SN123456",
  "result": true
}

7.5.11 `setscreensaver` — Set Screensaver Parameters

Request:

JSON{
  "cmd": "setscreensaver",
  "password": "xxx",
  "filename": "logo.jpg",
  "photo": "<Base64-encoded image>",
  "duration": 60,
  "remove": false,
  "removeall": false
}
FieldTypeDescription
filenamestringScreensaver image filename
photostringBase64-encoded image content
durationnumberDisplay duration (seconds)
removeboolRemove specific screensaver image
removeallboolRemove all screensaver images

Response:

JSON{
  "ret": "setscreensaver",
  "sn": "SN123456",
  "result": true
}

7.5.12 `upgrade` — Trigger OTA Firmware Upgrade via JSON API

Request:

JSON{
  "cmd": "upgrade",
  "password": "xxx",
  "filename": "ai230_product.zip",
  "md5": "d41d8cd98f00b204e9800998ecf8427e",
  "allcount": 100,
  "index": 0,
  "count": 50,
  "record": "<Base64-encoded firmware chunk>"
}
FieldTypeDescription
filenamestringFirmware filename (must match device model, .zip or .pkg)
md5stringFull file MD5 checksum (verified on last chunk)
allcountnumberTotal number of chunks
indexnumberCurrent chunk index (0-based)
countnumberNumber of chunks in this request
recordstringBase64-encoded firmware data chunk

Response (success):

JSON{
  "ret": "upgrade",
  "sn": "SN123456",
  "result": true
}

Response (failure):

JSON{
  "ret": "upgrade",
  "sn": "SN123456",
  "result": false,
  "reason": 1,
  "msg": "file mismatch or insufficient space"
}

Failure reason codes:

reasonDescription
1File mismatch or insufficient disk space
2MD5 checksum verification failed
3File move error
4Wrong file extension (must be .zip or .pkg)

7.5.13 `setvoice` — Configure Voice Prompts

Request:

JSON{
  "cmd": "setvoice",
  "password": "xxx",
  "index": 0,
  "voice": "<Base64-encoded WAV audio>",
  "play": true
}
FieldTypeDescription
indexnumberVoice prompt index
voicestringBase64-encoded WAV audio data (max 512KB)
playboolPlay the voice prompt immediately after setting

Response:

JSON{
  "ret": "setvoice",
  "sn": "SN123456",
  "result": true
}

7.5.14 `keypad` — Activate/Deactivate Keypad Mode

Request:

JSON{
  "cmd": "keypad",
  "password": "xxx",
  "password": true,
  "keep": false,
  "timeout": 30,
  "on": true
}
FieldTypeDescription
passwordboolEnable keypad password input
keepboolKeep keypad active after use
timeoutnumberKeypad timeout (seconds)
onboolTurn keypad on/off

Response:

JSON{
  "ret": "keypad",
  "sn": "SN123456",
  "result": true
}

7.6 Door Access Control


7.6.1 `opendoor` — Remote Door Open

Request:

JSON{
  "cmd": "opendoor",
  "password": "xxx",
  "enrollid": "1001",
  "floor": 3,
  "msg": "Welcome"
}
FieldTypeDescription
enrollidstring/numberOptional — associated user ID (for Wiegand output)
floornumberOptional — elevator control floor number
msgstringOptional — message to display on screen (for 3 seconds)

Response:

JSON{
  "ret": "opendoor",
  "sn": "SN123456",
  "result": true
}

7.6.2 `lockctrl` — Door Lock State Control

Request:

JSON{
  "cmd": "lockctrl",
  "password": "xxx",
  "fuc": 1
}
FieldTypeDescription
fucnumberLock control function code
fucDescription
1Normally Open (NO)
2Normally Closed (NC)
0Restore normal operation

Response:

JSON{
  "ret": "lockctrl",
  "sn": "SN123456",
  "result": true
}

7.6.3 `getdoorstatus` — Get Door Status

Request:

JSON{ "cmd": "getdoorstatus", "password": "xxx" }

Response:

JSON{
  "ret": "getdoorstatus",
  "sn": "SN123456",
  "result": true,
  "doorstatus": 1
}
FieldTypeDescription
doorstatusnumberCurrent door status code

7.6.4 `setdevlock` — Configure Door Access Parameters

Request (all fields optional):

JSON{
  "cmd": "setdevlock",
  "password": "xxx",
  "opendelay": 5,
  "doorsensor": 1,
  "alarmdelay": 30,
  "InputAlarm": 0,
  "antpass": 0,
  "interlock": 0,
  "mutiopen": 0,
  "tryalarm": 5,
  "access_times": 0,
  "punchtimes": 0,
  "tamper": 0,
  "wgformat": 26,
  "wgoutput": 0,
  "cardformat": 0,
  "dayzone": [],
  "weekzone": [],
  "lockgroup": [],
  "nopentime": [],
  "visitortime": []
}
FieldTypeDescription
opendelaynumberDoor open delay (seconds)
doorsensornumberDoor sensor type
alarmdelaynumberAlarm delay (seconds)
InputAlarmnumberInput alarm setting
antpassnumberAnti-passback mode
interlocknumberInterlock function
mutiopennumberMulti-user door open
tryalarmnumberFailed verification alarm threshold
access_timesnumberAccess times limit
punchtimesnumberPunch times limit
tampernumberTamper alarm setting
wgformatnumberWiegand format: 0=26bit, 1=34bit, 2=42bit, 3=50bit, 4=58bit, 5=66bit, 6=37bit
wgoutputnumberWiegand output mode
cardformatnumberCard format
dayzonearrayDay time zone schedule array
weekzonearrayWeek time zone schedule array
lockgrouparrayLock group array
nopentimearrayNo-open time array
visitortimearrayVisitor time array

Response:

JSON{
  "ret": "setdevlock",
  "sn": "SN123456",
  "result": true
}

7.6.5 `getdevlock` — Get Door Access Parameters

Request:

JSON{ "cmd": "getdevlock", "password": "xxx" }

Response:

JSON{
  "ret": "getdevlock",
  "sn": "SN123456",
  "result": true,
  "opendelay": 5,
  "doorsensor": 1,
  "alarmdelay": 30,
  "InputAlarm": 0,
  "antpass": 0,
  "interlock": 0,
  "mutiopen": 0,
  "tryalarm": 5,
  "access_times": 0,
  "tamper": 0,
  "wgformat": 26,
  "wgoutput": 0,
  "cardformat": 0,
  "dayzone": [],
  "weekzone": [],
  "lockgroup": [],
  "nopentime": [],
  "visitortime": []
}
FieldTypeDescription
opendelaynumberDoor open delay (seconds)
doorsensornumberDoor sensor type
alarmdelaynumberAlarm delay (seconds)
InputAlarmnumberInput alarm setting
antpassnumberAnti-passback mode
interlocknumberInterlock function
mutiopennumberMulti-user door open
tryalarmnumberFailed verification alarm threshold
access_timesnumberAccess times limit
tampernumberTamper alarm setting
wgformatnumberWiegand format: 0=26bit, 1=34bit, 2=42bit, 3=50bit, 4=58bit, 5=66bit, 6=37bit
wgoutputnumberWiegand output mode
cardformatnumberCard format
dayzonearrayDay time zone schedule
weekzonearrayWeek time zone schedule
lockgrouparrayLock group settings
nopentimearrayNo-open time schedule
visitortimearrayVisitor time schedule

7.6.6 `getuserlock` — Get User-Level Access Settings

Request:

JSON{
  "cmd": "getuserlock",
  "password": "xxx",
  "enrollid": "1001"
}
FieldTypeDescription
enrollidstring/numberUser ID or alias ID

Response (found):

JSON{
  "ret": "getuserlock",
  "sn": "SN123456",
  "result": true,
  "enrollid": "1001",
  "birthday": "01-15",
  "verifymode": 0,
  "enable": 1,
  "weekzone": 0,
  "group": 0,
  "access_times": 0,
  "starttime": "2024-01-01 00: 00: 00",
  "endtime": "2025-12-31 23: 59: 59"
}

Response (not found):

JSON{
  "ret": "getuserlock",
  "sn": "SN123456",
  "result": false,
  "reason": 1,
  "msg": "can not find the user",
  "enrollid": "1001"
}
FieldTypeDescription
enrollidstringUser ID
birthdaystringBirthday "MM-DD" format
verifymodenumberVerification mode (see Appendix 10)
enablenumberEnable flag (1=enabled, 0=disabled)
weekzonenumberWeek zone ID
groupnumberGroup ID
access_timesnumberAllowed access times
starttimestringValid start time
endtimestringValid end time

7.6.7 `setuserlock` — Set User-Level Access Parameters (Batch)

Request:

JSON{
  "cmd": "setuserlock",
  "password": "xxx",
  "count": 2,
  "record": [
    {
      "enrollid": "1001",
      "birthday": "01-15",
      "verifymode": 0,
      "weekzone": 0,
      "group": 0,
      "access_times": 0,
      "starttime": "2024-01-01 00: 00: 00",
      "endtime": "2025-12-31 23: 59: 59"
    },
    {
      "enrollid": "1002",
      "birthday": "06-20",
      "verifymode": 1,
      "weekzone": 1,
      "group": 0,
      "access_times": 5,
      "starttime": "2024-01-01 00: 00: 00",
      "endtime": "2025-12-31 23: 59: 59"
    }
  ]
}
FieldTypeDescription
countnumberNumber of records in the array
recordarrayArray of user access settings
record[].enrollidstring/numberUser ID
record[].birthdaystringBirthday "MM-DD" format
record[].verifymodenumberVerification mode (see Appendix 10)
record[].weekzonenumberWeek zone ID
record[].groupnumberGroup ID
record[].access_timesnumberAllowed access times
record[].starttimestringValid start time
record[].endtimestringValid end time

Response (success):

JSON{
  "ret": "setuserlock",
  "sn": "SN123456",
  "result": true
}

Response (failure):

JSON{
  "ret": "setuserlock",
  "sn": "SN123456",
  "result": false,
  "reason": 1,
  "msg": "setuserlock fail"
}

7.6.8 `deleteuserlock` — Delete User Access Settings

Request:

JSON{
  "cmd": "deleteuserlock",
  "password": "xxx",
  "enrollid": "1001"
}
FieldTypeDescription
enrollidstring/numberUser ID or alias ID

Response:

JSON{
  "ret": "deleteuserlock",
  "sn": "SN123456",
  "result": true,
  "enrollid": "1001"
}

7.6.9 `cleanuserlock` — Clear All User Access Settings

Request:

JSON{ "cmd": "cleanuserlock", "password": "xxx" }

Response:

JSON{
  "ret": "cleanuserlock",
  "sn": "SN123456",
  "result": true
}

7.6.10 `openallfloors` — Open All Floors

Request:

JSON{ "cmd": "openallfloors", "password": "xxx" }

Response:

JSON{
  "ret": "openallfloors",
  "sn": "SN123456",
  "result": true
}

7.6.11 `closeallfloors` — Close All Floors

Request:

JSON{ "cmd": "closeallfloors", "password": "xxx" }

Response:

JSON{
  "ret": "closeallfloors",
  "sn": "SN123456",
  "result": true
}

7.6.12 `openselectfloors` — Open Selected Floors

Request:

JSON{
  "cmd": "openselectfloors",
  "password": "xxx",
  "profile": "1,2,5"
}
FieldTypeDescription
profilestringComma-separated floor numbers to open (optional)

Response:

JSON{
  "ret": "openselectfloors",
  "sn": "SN123456",
  "result": true
}

7.6.13 `closeselectfloors` — Close Selected Floors

Request:

JSON{
  "cmd": "closeselectfloors",
  "password": "xxx",
  "profile": "3,4"
}
FieldTypeDescription
profilestringComma-separated floor numbers to close (optional)

Response:

JSON{
  "ret": "closeselectfloors",
  "sn": "SN123456",
  "result": true
}

7.7 Shifts & Attendance


7.7.1 `getshift` — Get Shift Configuration

Request:

JSON{ "cmd": "getshift", "password": "xxx" }

Response:

JSON{
  "ret": "getshift",
  "sn": "SN123456",
  "result": true,
  "shifts": [
    {
      "name": "Shift 1",
      "cutoftime": 10,
      "sections": [
        { "start": "09: 00", "end": "12: 00", "type": 0 },
        { "start": "13: 00", "end": "18: 00", "type": 0 },
        { "start": "", "end": "", "type": 0 }
      ]
    }
  ]
}
FieldTypeDescription
shiftsarrayArray of up to 8 shift definitions
shifts[].namestringShift name
shifts[].cutoftimenumberCutoff time (minutes) for late arrival
shifts[].sectionsarrayArray of 3 time sections per shift
shifts[].sections[].startstringSection start time "HH:MM"
shifts[].sections[].endstringSection end time "HH:MM"
shifts[].sections[].typenumberSection type

7.7.2 `setshift` — Set Shift Configuration

Request:

JSON{
  "cmd": "setshift",
  "password": "xxx",
  "shifts": [
    {
      "name": "Shift 1",
      "cutoftime": 10,
      "sections": [
        { "start": "09: 00", "end": "12: 00", "type": 0 },
        { "start": "13: 00", "end": "18: 00", "type": 0 },
        { "start": "", "end": "", "type": 0 }
      ]
    }
  ]
}
FieldTypeDescription
shiftsarrayArray of up to 8 shift definitions
shifts[].namestringShift name
shifts[].cutoftimenumberCutoff time (minutes)
shifts[].sectionsarrayArray of 3 time sections per shift
shifts[].sections[].startstringSection start time "HH:MM"
shifts[].sections[].endstringSection end time "HH:MM"
shifts[].sections[].typenumberSection type

Response:

JSON{
  "ret": "setshift",
  "sn": "SN123456",
  "result": true
}

7.7.3 `getbelltime` — Get Bell Schedule

Request:

JSON{ "cmd": "getbelltime", "password": "xxx" }

Response:

JSON{
  "ret": "getbelltime",
  "sn": "SN123456",
  "result": true,
  "belltimes": [
    { "time": "09: 00", "flag": 1 },
    { "time": "12: 00", "flag": 0 },
    { "time": "13: 00", "flag": 1 },
    { "time": "18: 00", "flag": 0 }
  ]
}
FieldTypeDescription
belltimesarrayBell schedule array
belltimes[].timestringBell time "HH:MM"
belltimes[].flagnumberBell type flag

7.7.4 `setbelltime` — Set Bell Schedule

Request:

JSON{
  "cmd": "setbelltime",
  "password": "xxx",
  "belltimes": [
    { "time": "09: 00", "flag": 1 },
    { "time": "12: 00", "flag": 0 },
    { "time": "13: 00", "flag": 1 },
    { "time": "18: 00", "flag": 0 }
  ]
}
FieldTypeDescription
belltimesarrayBell schedule array
belltimes[].timestringBell time "HH:MM"
belltimes[].flagnumberBell type flag

Response:

JSON{
  "ret": "setbelltime",
  "sn": "SN123456",
  "result": true
}

7.7.5 `getholiday` — Get Holiday Settings

Request:

JSON{ "cmd": "getholiday", "password": "xxx" }

Response:

JSON{
  "ret": "getholiday",
  "sn": "SN123456",
  "result": true,
  "holidays": [
    {
      "name": "New Year",
      "startday": "01-01",
      "endday": "01-03",
      "shift": 0,
      "dayzone": 0
    }
  ]
}
FieldTypeDescription
holidaysarrayArray of up to 30 holiday definitions
holidays[].namestringHoliday name
holidays[].startdaystringStart date "MM-DD"
holidays[].enddaystringEnd date "MM-DD"
holidays[].shiftnumberShift ID to apply
holidays[].dayzonenumberDay zone ID

7.7.6 `setholiday` — Set Holiday Settings

Request:

JSON{
  "cmd": "setholiday",
  "password": "xxx",
  "holidays": [
    {
      "name": "New Year",
      "startday": "01-01",
      "endday": "01-03",
      "shift": 0,
      "dayzone": 0
    }
  ]
}
FieldTypeDescription
holidaysarrayArray of up to 30 holiday definitions
holidays[].namestringHoliday name
holidays[].shiftnumberShift ID to apply
holidays[].dayzonenumberDay zone ID
holidays[].startdaystringStart date "MM-DD"
holidays[].enddaystringEnd date "MM-DD"

Response:

JSON{
  "ret": "setholiday",
  "sn": "SN123456",
  "result": true
}

7.8 Reports


7.8.1 `getreport` — Get Attendance Report Data

Request:

JSON{
  "cmd": "getreport",
  "password": "xxx",
  "enrollid": "1001",
  "from": "2024-01-01",
  "to": "2024-12-31"
}
FieldTypeDescription
enrollidstring/numberOptional — filter by specific user
fromstringStart date "YYYY-MM-DD"
tostringEnd date "YYYY-MM-DD"

Response (success):

JSON{
  "ret": "getreport",
  "sn": "SN123456",
  "result": true
}

Response (no logs found):

JSON{
  "ret": "getreport",
  "sn": "SN123456",
  "result": false,
  "reason": 1,
  "msg": "can not find logs"
}
Response contains dynamic report data fields depending on the report type and date range.

7.8.2 `generatereport` — Generate Report Files

Request:

JSON{
  "cmd": "generatereport",
  "password": "xxx",
  "enrollid": "1001",
  "from": "2024-01-01",
  "to": "2024-12-31"
}
FieldTypeDescription
enrollidstring/numberOptional — filter by specific user
fromstringStart date "YYYY-MM-DD"
tostringEnd date "YYYY-MM-DD"

Response (success):

JSON{
  "ret": "generatereport",
  "sn": "SN123456",
  "result": true,
  "msg": "Report generation started."
}

Response (busy):

JSON{
  "ret": "generatereport",
  "sn": "SN123456",
  "result": false,
  "reason": 3,
  "msg": "A report is already being generated. Please wait."
}
After generation completes, files can be downloaded via /download/report and /download/rawrecord.

7.8.3 `checkreportprogress` — Check Report Generation Progress

Request:

JSON{ "cmd": "checkreportprogress", "password": "xxx" }

Response (in progress):

JSON{
  "ret": "checkreportprogress",
  "sn": "SN123456",
  "result": true,
  "progress": 75,
  "status": "generating",
  "finished": false
}

Response (completed):

JSON{
  "ret": "checkreportprogress",
  "sn": "SN123456",
  "result": true,
  "progress": 100,
  "status": "completed",
  "finished": true,
  "file_exists": true
}
FieldTypeDescription
progressnumberGeneration progress percentage (0-100)
statusstringCurrent status description
finishedboolWhether generation is complete
file_existsboolWhether report file is available for download (only when finished)

7.9 Questionnaire & Notices


7.9.1 `setquestionnaire` — Configure Questionnaire

Request:

JSON{
  "cmd": "setquestionnaire",
  "password": "xxx",
  "title": "Health Declaration",
  "voice": "Please complete health declaration",
  "errmsg": "Declaration failed",
  "radio": true,
  "optionflag": 3,
  "items": ["Question 1", "Question 2"],
  "schedules": ["08: 00-09: 00", "12: 00-13: 00"],
  "usequestion": true,
  "useschedule": false,
  "card": 0,
  "switch_card": 0,
  "enrollid": "1001",
  "open": true
}
FieldTypeDescription
titlestringQuestionnaire title
voicestringVoice prompt text
errmsgstringError message text
radioboolUse radio button style (single select)
optionflagnumberOption flag
itemsarrayArray of up to 16 questionnaire items (strings)
schedulesarrayArray of up to 8 schedule strings
usequestionboolEnable questionnaire feature
usescheduleboolEnable schedule-based questionnaire
cardnumber/stringAssociated card ID
switch_cardnumber/stringSwitch card ID
enrollidstring/numberAssociated user ID
openboolOpen questionnaire for responses

Response:

JSON{
  "ret": "setquestionnaire",
  "sn": "SN123456",
  "result": true
}

7.9.2 `getquestionnaire` — Get Questionnaire Configuration

Request:

JSON{ "cmd": "getquestionnaire", "password": "xxx" }

Response (configured):

JSON{
  "ret": "getquestionnaire",
  "sn": "SN123456",
  "result": true,
  "title": "Health Declaration",
  "voice": "Please complete health declaration",
  "errmsg": "Declaration failed",
  "radio": true,
  "optionflag": 3,
  "usequestion": true,
  "useschedule": false,
  "card": 0,
  "switch_card": 0,
  "items": ["Question 1", "Question 2"],
  "schedules": ["08: 00-09: 00", "12: 00-13: 00"]
}

Response (not configured):

JSON{
  "ret": "getquestionnaire",
  "sn": "SN123456",
  "result": false
}
FieldTypeDescription
titlestringQuestionnaire title
voicestringVoice prompt text
errmsgstringError message text
radioboolRadio button mode
optionflagnumberOption flag
usequestionboolQuestionnaire enabled
usescheduleboolSchedule mode enabled
cardnumberAssociated card ID
switch_cardnumberSwitch card ID
itemsarrayQuestionnaire items
schedulesarraySchedule strings

7.9.3 `cleanquestionnaire` — Clear Questionnaire Settings

Request:

JSON{ "cmd": "cleanquestionnaire", "password": "xxx" }

Response:

JSON{
  "ret": "cleanquestionnaire",
  "sn": "SN123456",
  "result": true
}

7.9.4 `setcompanyname` — Set Company Name

Request:

JSON{
  "cmd": "setcompanyname",
  "password": "xxx",
  "name": "ACME Corporation"
}
FieldTypeDescription
namestringCompany name (max 21 characters)

Response:

JSON{
  "ret": "setcompanyname",
  "sn": "SN123456",
  "result": true
}

7.9.5 `getcompanyname` — Get Company Name

Request:

JSON{ "cmd": "getcompanyname", "password": "xxx" }

Response:

JSON{
  "ret": "getcompanyname",
  "sn": "SN123456",
  "result": true,
  "name": "ACME Corporation"
}
FieldTypeDescription
namestringCurrent company name

7.10 Video Intercom (WebRTC)


7.10.1 `enablewebrtc` — Initiate Video Call

Request:

JSON{
  "cmd": "enablewebrtc",
  "password": "xxx",
  "intercom": true,
  "monitor": true,
  "inputmode": 0,
  "waitseconds": 30,
  "stunserver": "stun:stun.l.google.com: 19302",
  "turnserver": "",
  "turnusername": "",
  "turnpassword": ""
}
FieldTypeDescription
intercomboolEnable intercom mode
monitorboolEnable monitor mode
inputmodenumberInput mode: 0=direct call (no input dialog), 1=enroll/ID number, 2=phone number, 3=room number, 4=visual selection menu
audioonlynumber / boolAudio-only intercom: 1/true = audio only, 0/false = audio + video (also controls video on/off)
waitsecondsnumberWait timeout (seconds)
stunserverstringSTUN server URL
turnserverstringTURN server URL
turnusernamestringTURN server username
turnpasswordstringTURN server password

Response (success):

JSON{
  "ret": "enablewebrtc",
  "sn": "SN123456",
  "result": true,
  "lanscape": 0
}

Response (hardware not supported):

JSON{
  "ret": "enablewebrtc",
  "sn": "SN123456",
  "result": false,
  "reason": 1,
  "msg": "this device have not this function"
}
FieldTypeDescription
lanscapenumberScreen orientation (landscape flag)

7.10.2 `getwebrtc` — Get WebRTC Signaling Status

Request:

JSON{ "cmd": "getwebrtc", "password": "xxx" }

Response (success):

JSON{
  "ret": "getwebrtc",
  "sn": "SN123456",
  "result": true,
  "intercom": true,
  "monitor": false,
  "inputmode": 0,
  "waitseconds": 30,
  "stunserver": "stun:stun.l.google.com: 19302",
  "turnserver": "",
  "turnusername": "",
  "turnpassword": ""
}

Response (hardware not supported):

JSON{
  "ret": "getwebrtc",
  "sn": "SN123456",
  "result": false,
  "reason": 1,
  "msg": "this device have not this function"
}
FieldTypeDescription
intercomboolIntercom enabled
monitorboolMonitor enabled
inputmodenumberAudio input mode
waitsecondsnumberWait timeout (seconds)
stunserverstringSTUN server URL
turnserverstringTURN server URL
turnusernamestringTURN server username
turnpasswordstringTURN server password

7.10.3 `checklive` — Check Live Stream Status

Request:

JSON{ "cmd": "checklive", "password": "xxx" }

Response (ICE candidate available):

JSON{
  "sn": "SN123456",
  "cmd": "icecandidate",
  "candidate": "<ICE candidate string>"
}

Response (call cancelled on device):

JSON{
  "sn": "SN123456",
  "cmd": "talkcancel"
}

Response (no activity):

(null — no response)
This command has non-standard response format. Returns ICE candidate data when available, cancellation notice if call was ended on the device side, or no response at all when idle.

7.10.4 `answer` — SDP Answer

Request:

JSON{
  "cmd": "answer",
  "password": "xxx",
  "sdp": "<SDP string>"
}
FieldTypeDescription
sdpstringSDP answer string

Response (success):

JSON{
  "ret": "answer",
  "sn": "SN123456",
  "result": true
}

Response (failure):

JSON{
  "ret": "answer",
  "sn": "SN123456",
  "result": false,
  "reason": 1,
  "msg": "device error"
}

Failure reason codes:

reasonDescription
1Device error
2SDP parameter missing

7.10.5 `icecandidate` — ICE Candidate Exchange

Request:

JSON{
  "cmd": "icecandidate",
  "password": "xxx",
  "candidate": "<ICE candidate string>"
}
FieldTypeDescription
candidatestringICE candidate string

Response:

JSON{
  "ret": "icecandidate",
  "sn": "SN123456",
  "result": true
}

7.10.6 `callcancel` — Cancel Call

Request:

JSON{ "cmd": "callcancel", "password": "xxx" }

Response:

JSON{
  "ret": "callcancel",
  "sn": "SN123456",
  "result": true
}

7.10.7 `monitorcall` — Monitor Mode Call

Request:

JSON{ "cmd": "monitorcall", "password": "xxx" }

Response (offer SDP):

JSON{
  "cmd": "offer",
  "sn": "SN123456",
  "type": "offer",
  "sdp": "<SDP offer string>"
}

Response (failure):

JSON{
  "ret": "monitorcall",
  "sn": "SN123456",
  "result": false,
  "reason": 1,
  "msg": "device busy"
}

Failure reason codes:

reasonDescription
1Device busy (another call in progress)
2Offer generation failed

7.11 Biometric Verification


7.11.1 `verify` — Remote Biometric Verification

Performs remote biometric verification on the device using provided biometric data.

Request:

JSON{
  "cmd": "verify",
  "password": "xxx",
  "enrollid": "1001",
  "card": "12345678",
  "pwd": 123456,
  "name": "John Doe",
  "face": "<Base64-encoded face JPEG>",
  "finger": "<Hex fingerprint template>",
  "finger2": "<Hex second fingerprint template>",
  "profile": "default"
}
FieldTypeDescription
enrollidstring/numberOptional — expected user ID for matching
cardstring/numberOptional — card number for verification
pwdnumberOptional — numeric password for verification
namestringOptional — user name
facestringOptional — Base64-encoded face image (JPEG)
fingerstringOptional — Hex-encoded fingerprint template
finger2stringOptional — Hex-encoded second fingerprint template
profilestringOptional — verification profile string

Response (success):

JSON{
  "ret": "verify",
  "sn": "SN123456",
  "result": true,
  "enrollid": "1001"
}

Response (failure):

JSON{
  "ret": "verify",
  "sn": "SN123456",
  "result": false,
  "reason": 1,
  "msg": "verification failed",
  "enrollid": "1001"
}

Failure reason codes:

reasonDescription
1User not found
2Password incorrect
3Card not found
4Fingerprint mismatch
5No face detected
6Multiple faces detected
7Image too large
8Face too large
9Face too small
10Image quality too low
11Face position off-center
12Face not matched

7.11.2 `biomatch` — Biometric Matching (OSDP Test)

Request:

JSON{ "cmd": "biomatch", "password": "xxx" }
Requires config_OSDP_TEST configuration.

Response:

JSON{
  "ret": "biomatch",
  "sn": "SN123456",
  "result": true
}

7.11.3 `bioread` — Read Raw Biometric Data (OSDP Test)

Request:

JSON{ "cmd": "bioread", "password": "xxx" }
Requires config_OSDP_TEST configuration.

Response:

JSON{
  "ret": "bioread",
  "sn": "SN123456",
  "result": true
}

7.12 File Operations


7.12.1 `getdir` — List Directory Contents

Request:

JSON{
  "cmd": "getdir",
  "password": "xxx",
  "path": "/data"
}
FieldTypeDescription
pathstringDirectory path to list

Response (success):

JSON{
  "ret": "getdir",
  "sn": "SN123456",
  "result": true,
  "files": ["config.txt", "photo.jpg", "logs/"]
}

Response (failure):

JSON{
  "ret": "getdir",
  "sn": "SN123456",
  "result": false
}
FieldTypeDescription
filesarrayArray of file/directory name strings

7.12.2 `getfile` — Get File Content (Base64 encoded)

Request:

JSON{
  "cmd": "getfile",
  "password": "xxx",
  "path": "/data/config.txt"
}
FieldTypeDescription
pathstringFile path to read

Response (success):

JSON{
  "ret": "getfile",
  "sn": "SN123456",
  "result": true,
  "base64": "<Base64-encoded file content>"
}

Response (failure):

JSON{
  "ret": "getfile",
  "sn": "SN123456",
  "result": false
}
FieldTypeDescription
base64stringBase64-encoded file content

7.12.3 `writefile` — Write File

Request:

JSON{
  "cmd": "writefile",
  "password": "xxx",
  "path": "/data/notice.txt",
  "base64": "<Base64-encoded content>"
}
FieldTypeDescription
pathstringFile path to write
base64stringBase64-encoded file content

Response (success):

JSON{
  "ret": "writefile",
  "sn": "SN123456",
  "result": true
}

Response (failure):

JSON{
  "ret": "writefile",
  "sn": "SN123456",
  "result": false
}

7.13 Firmware Upgrade

Firmware upgrades use a dedicated HTTP endpoint (not JSON API).

Endpoint: POST /api/firmware/upload

Query Parameters:

ParameterDescription
nameFirmware filename (must match device model, e.g., ai230_.zip or .pkg)
offsetCurrent chunk start offset (bytes)
totalTotal file size (bytes)
passwordDevice password
md5File MD5 checksum (verified on last chunk)

Chunked Transfer Logic:

  1. Each POST carries a file chunk as the request body
  2. offset=0 marks the first chunk — device clears /data/ota directory
  3. When data.len == 0 and offset >= total, MD5 is verified and processing completes
  4. Supported formats: .zip (system update) and .pkg (firmware package)

Success Response: "true" (text/plain)

Error Response (HTTP 500):

MessageDescription
error passwordWrong password
this file not this machine firmwareFirmware model mismatch
Insufficient disk spaceNot enough disk space
md5 check errorMD5 verification failed
need zip or pkgUnsupported file format

8. Static Resources & File Downloads

PathDescription
/photos/LF.jpgUser enrollment photo (by internal numeric ID)
/photos/CF_.jpgUser enrollment photo (by alias ID)
/logphotos/logimage.jpgAttendance log snapshot photo
/download/reportSummary attendance report (.xls, valid for 20s after generation)
/download/rawrecordRaw attendance records (.xls, valid for 20s after generation)
Static files are served from /data/res/webserver first; if not found, fallback to /usr/webserver.

9. Appendix: backupnum Reference

The backupnum field is used in getuserinfo, setuserinfo, deleteuser, adduser, deleteuserfp, deleteuserpalm and related commands to identify which biometric slot to operate on. Push commands (setuserinfo) additionally carry the template payload in record.

backupnumTypeDescriptionrecord encoding (push / export)Length after decoding
0-9FingerprintFingerprint at index 0-9 (up to 10 per user)Hex + zero run-length compression (N), not Base64810 bytes
10PasswordUser passwordNumber—
11CardRFID cardNumber—
12Full deleteDelete entire user record——
13Full deleteSame as 12——
40Left palmLeft hand palm vein templateBase641548 bytes
41Right palmRight hand palm vein templateBase641548 bytes
50Face photoFace JPEG imageBase64 (JPEG)≤ 512KB
51Face featureFace feature vector + 10 face key pointsBase64 (2-byte header + 1072-byte feature)1074 bytes

record quick reference:

Generating minimal testable payloads:

BASH# Fingerprint (810 zero bytes) -> use the literal string (810)
# Palm vein (1548 zero bytes) -> Base64 string of 2064 characters
python3 -c "import base64;print(base64.b64encode(bytes(1548)).decode())"
# Face feature (08 06 + 1072 zero bytes) -> Base64 starting with CAYA
python3 -c "import base64;print(base64.b64encode(b'\x08\x06'+bytes(1072)).decode())"
Fingerprint and palm vein templates are only available on models with the matching hardware (fingerprint module, or palm vein module); on unsupported models the corresponding backupnum is ignored.

10. Appendix: verifymode Reference

verifymode selects the verification method(s) a user may use (the device default uses the same values). Every method — including combinations such as "face + card" — has a fixed value; use one of the values below.

verifymodeVerification methodNotes
0Any methodDefault; no restriction
1FingerprintRequires fingerprint model
2Password—
3Card—
4Fingerprint + cardRequires fingerprint model
5Fingerprint + passwordRequires fingerprint model
6Password + fingerprintRequires fingerprint model
7Card + fingerprintRequires fingerprint model
8FaceRequires camera model
9Face + passwordRequires camera model
10Face + cardRequires camera model
11Card + password—
12Face + fingerprintRequires camera and fingerprint model
13QR codeRequires QR code support
14Face + (card or password)Requires camera model
15ID card (SFZ)Requires ID card reader
16Palm veinRequires palm vein model
191:N automatic matchSet by the device itself; normally not sent by the platform
20Any biometric of the personAny biometric or combination of the person
21Palm vein + faceRequires palm vein model
22Fingerprint + palm veinRequires fingerprint and palm vein model
23Card + palm veinRequires palm vein model
24Palm vein + passwordRequires palm vein model
25Card + face + passwordRequires camera model

Notes:


Document generated: 2026-05-06

Last updated: 2026-09-22 — added fingerprint / palm vein / face feature (with key points) push examples, record encoding rules and duplicate-check failure codes; corrected the verifymode value reference (see Appendix 10)

Based on webserver.cpp source code analysis