API for hikvision face detection DS-K1T341AMF

ayoubef

n3wb
Dec 25, 2025
1
0
Maroc
I am trying to use the Hikvision device DS-K1T341AMF.
Could you please guide me on how to upload a face image and link it to the correct person on this device?
I have already created a person using the following API:
POST /ISAPI/AccessControl/UserInfo/Record?format=json
I am currently trying to upload a JPG image, but it is not working.
Could you please let me know what I am missing?

async uploadFaceDataBinaryType(memberData, service) {
try {
/ 1️⃣ Download face image as binary buffer
/ memberData?.UserInfo?.faceList?.img => HTTPS image URL from my server
const imageRes = await axios.get(memberData?.UserInfo?.faceList?.img, {
responseType: "arraybuffer"
});
const imageBuffer = Buffer.from(imageRes.data);
/ 2️⃣ Create temporary folder for face images (if not exists)
const tmpFolder = path.join(process.cwd(), 'member');
if (!fs.existsSync(tmpFolder)) {
fs.mkdirSync(tmpFolder, { recursive: true });
}
/ memberData.UserInfo.employeeNo => unique identifier used as filename
const imageFilePath = path.join(
tmpFolder,
face_${memberData.UserInfo.employeeNo}.jpg
);
/ 3️⃣ Resize image to Hikvision-compatible dimensions (300x400)
/ - Crop from center
/ - Convert to JPEG
/ - Reduce quality for better device compatibility
await sharp(imageBuffer)
.resize(300, 400, {
fit: "cover", / Center crop (similar to Laravel fit)
position: "center"
})
.jpeg({ quality: 85 })
.toFile(imageFilePath);
/ 4️⃣ Create multipart/form-data payload for Hikvision API
const form = new FormData();
/ REQUIRED JSON FIELD (must be named exactly "FaceDataRecord")
/ memberData?.UserInfo?.faceList?.FaceDataRecord example:
/ { "faceLibType": "blackFD", "FDID": "1", "FPID": "15277" }
form.append(
"FaceDataRecord",
JSON.stringify(memberData?.UserInfo?.faceList?.FaceDataRecord),
{ contentType: "application/json" }
);
/ Add face image file (field name MUST be "img")
form.append(
"img",
fs.createReadStream(imageFilePath),
{
filename: path.basename(imageFilePath),
contentType: "image/jpeg"
}
);
/ 5️⃣ Required request headers for multipart upload
const headers = {
...form.getHeaders(),
'Accept': 'application/json',
'Connection': 'keep-alive'
};
/ 6️⃣ Send face data to Hikvision face library
const result = await service.put(
'/ISAPI/Intelligent/FDLib/FDSetUp?format=json',
form,
{ headers }
);
/ 7️⃣ Optional: remove temporary image file after upload
/ fs.unlinkSync(imageFilePath);
return { success: true };
} catch (error) {
console.error('❌ Hikvision face upload failed:', error.response?.data || error.message);
return {
success: false,
error: error.response?.data || error.message
};
}
}
 
There are 3 ways to send image.

By sending faceData which is hikvision binary compressed form, you get it by starting enrollment mode.

Or by sending faceURL or by sending image data as byte aray.

If you gonna go with sending image data as bytearray you will fail without few tricks in documentation

I suggest using faceURL


So body is

{ "faceLibType": "blackFD", "FDID": "1", "FPID": "15277","faceURL":"localurl or internet url " }