6.1 Data Sanitization Request

Request

Value

Method

POST

URL

https://api.metadefender.com/v4/file

Throttled

Yes

Summary

Retrieve scan status and data sanitization results after uploading a file.

Data sanitization is supported for the following file types: PDF, DOC(X/M), DOT(X/M), XLS(B/X/M), PPT(X/M), PPSX, RTF, BMP, PNG, JPG/JPEG, EPS, GIF, SVG, TIF(F), HTM/HTML, XML, HWP, JTD, OTD, DWG.

Initiate Data Sanitization Request

On MetaDefender Cloud, scans and data sanitization requests are performed asynchronously, and each scan request is tracked by a data_id. For initiating data sanitization, use the same endpoint that is used for File scan: POST /v4/file and add additional header rule and value sanitize: Scanning a file by file upload.

Private scanning does not work with sanitization. When sanitizing a file, even if the file is uploaded with "samplesharing: 0" header, we will keep a copy of the sanitized version of the file for the user to download.

Response

Body

Example of successful scan request with data sanitization

{
"scan_result_history_length": 1,
"file_id": "bzE5MDIyN1NKbGJ5RzFNRVU0",
"data_id": "bzE5MDIyN1NKbGJ5RzFNRVU0cmtaYnlNSk00TEU",
"sanitized": {
"file_path": "https://s3.us-west-2.amazonaws.com/d.files.metadefender.com/dt%3D190227/SJlbyG1MEU4.sanitized?AWSAccessKeyId=AKIAIQ4OFCFFFT4QMUYA&Expires=1553865780&Signature=MugvIclVIXmivtDCstBnMzdq1WI%3D&response-content-disposition=attachment%3B%20filename%3DUnknown%20Filename",
"data_id": "ZDE5MDIyN1NKbGJ5RzFNRVU0LnNhbml0aXplZEJ5bXprekVVRQ",
"result": "Blocked",
"reason": "Infected"
},
"process_info": {
"result": "Blocked",
"profile": "multiscan_sanitize",
"post_processing": {
"copy_move_destination": "",
"converted_to": "doc",
"converted_destination": "VW5rbm93biBGaWxlbmFtZQ_sanitized_by_OPSWAT_MetaDefender_0bf0c3c282494d6b860537879f96b9ad.doc",
"actions_ran": "Sanitized",
"actions_failed": ""
},
"file_type_skipped_scan": false,
"blocked_reason": "Infected"
},
"scan_results": {
"scan_details": {
"Xvirus Personal Guard": {
"threat_found": "",
"scan_time": 91,
"scan_result_i": 0,
"def_time": "2019-02-26T09:57:00.000Z"
},
"TrendMicro House Call": {
"threat_found": "",
"scan_time": 593,
"scan_result_i": 0,
"def_time": "2019-02-25T21:06:00.000Z"
},
"TrendMicro": {
"threat_found": "",
"scan_time": 495,
"scan_result_i": 0,
"def_time": "2019-02-25T20:54:00.000Z"
},
"SUPERAntiSpyware": {
"threat_found": "",
"scan_time": 1109,
"scan_result_i": 0,
"def_time": "2013-05-22T22:16:00.000Z"
},
"Jiangmin": {
"threat_found": "",
"scan_time": 1093,
"scan_result_i": 0,
"def_time": "2019-02-25T23:22:00.000Z"
},
"Filseclab": {
"threat_found": "",
"scan_time": 233,
"scan_result_i": 0,
"def_time": "2019-02-25T22:48:00.000Z"
},
"F-secure": {
"threat_found": "",
"scan_time": 565,
"scan_result_i": 0,
"def_time": "2019-02-05T01:33:00.000Z"
},
"ClamAV": {
"threat_found": "",
"scan_time": 97,
"scan_result_i": 0,
"def_time": "2019-02-26T10:34:00.000Z"
},
"ByteHero": {
"threat_found": "",
"scan_time": 265,
"scan_result_i": 0,
"def_time": "2019-02-26T00:00:00.000Z"
},
"Baidu": {
"threat_found": "",
"scan_time": 535,
"scan_result_i": 0,
"def_time": "2019-01-08T11:35:00.000Z"
},
"Zillya!": {
"threat_found": "",
"scan_time": 3,
"scan_result_i": 0,
"def_time": "2019-02-26T17:27:00.000Z"
},
"VirusBlokAda": {
"threat_found": "",
"scan_time": 3,
"scan_result_i": 0,
"def_time": "2019-02-26T15:24:00.000Z"
},
"Total Defense": {
"threat_found": "",
"scan_time": 5,
"scan_result_i": 0,
"def_time": "2019-02-26T00:00:00.000Z"
},
"ThreatTrack": {
"threat_found": "",
"scan_time": 9,
"scan_result_i": 0,
"def_time": "2019-02-25T08:30:00.000Z"
},
"TACHYON": {
"threat_found": "",
"scan_time": 12,
"scan_result_i": 0,
"def_time": "2019-02-27T05:00:00.000Z"
},
"Sophos": {
"threat_found": "",
"scan_time": 5,
"scan_result_i": 0,
"def_time": "2019-02-26T00:56:00.000Z"
},
"Quick Heal": {
"threat_found": "",
"scan_time": 2,
"scan_result_i": 0,
"def_time": "2019-02-26T08:14:00.000Z"
},
"Preventon": {
"threat_found": "",
"scan_time": 46,
"scan_result_i": 0,
"def_time": "2019-02-27T05:02:00.000Z"
},
"NANOAV": {
"threat_found": "",
"scan_time": 7,
"scan_result_i": 0,
"def_time": "2019-02-27T02:05:00.000Z"
},
"McAfee": {
"threat_found": "",
"scan_time": 7,
"scan_result_i": 0,
"def_time": "2019-02-26T00:00:00.000Z"
},
"K7": {
"threat_found": "",
"scan_time": 1,
"scan_result_i": 0,
"def_time": "2019-02-27T00:10:00.000Z"
},
"Ikarus": {
"threat_found": "",
"scan_time": 2,
"scan_result_i": 0,
"def_time": "2019-02-26T19:13:05.000Z"
},
"Huorong": {
"threat_found": "",
"scan_time": 2,
"scan_result_i": 0,
"def_time": "2019-02-25T09:11:00.000Z"
},
"Hauri": {
"threat_found": "",
"scan_time": 2,
"scan_result_i": 0,
"def_time": "2019-02-27T00:00:00.000Z"
},
"Fortinet": {
"threat_found": "",
"scan_time": 48,
"scan_result_i": 0,
"def_time": "2019-02-26T00:00:00.000Z"
},
"F-prot": {
"threat_found": "",
"scan_time": 3,
"scan_result_i": 0,
"def_time": "2019-02-27T06:10:00.000Z"
},
"Emsisoft": {
"threat_found": "",
"scan_time": 12,
"scan_result_i": 0,
"def_time": "2019-02-26T13:51:00.000Z"
},
"ESET": {
"threat_found": "",
"scan_time": 3,
"scan_result_i": 0,
"def_time": "2019-02-27T00:00:00.000Z"
},
"Cyren": {
"threat_found": "",
"scan_time": 10,
"scan_result_i": 0,
"def_time": "2019-02-27T07:43:00.000Z"
},
"BitDefender": {
"threat_found": "",
"scan_time": 6,
"scan_result_i": 0,
"def_time": "2019-02-27T04:54:00.000Z"
},
"Avira": {
"threat_found": "",
"scan_time": 3,
"scan_result_i": 0,
"def_time": "2019-02-25T00:00:00.000Z"
},
"Antiy": {
"threat_found": "",
"scan_time": 1,
"scan_result_i": 0,
"def_time": "2019-02-27T07:47:00.000Z"
},
"Ahnlab": {
"threat_found": "",
"scan_time": 16,
"scan_result_i": 0,
"def_time": "2019-02-27T00:00:00.000Z"
},
"Agnitum": {
"threat_found": "",
"scan_time": 3,
"scan_result_i": 0,
"def_time": "2019-02-25T10:54:00.000Z"
},
"AegisLab": {
"threat_found": "Test.File.EICAR.00x7",
"scan_time": 0,
"scan_result_i": 1,
"def_time": "2019-02-26T01:00:00.000Z"
},
"Vir.IT eXplorer": {
"threat_found": "",
"scan_time": 3,
"scan_result_i": 0,
"def_time": "2019-02-26T14:46:00.000Z"
},
"Vir.IT ML": {
"threat_found": "",
"scan_time": 2,
"scan_result_i": 0,
"def_time": "2019-02-25T14:46:00.000Z"
}
},
"rescan_available": true,
"scan_all_result_i": 1,
"start_time": "2019-02-27T13:22:15.669Z",
"total_time": 1125,
"total_avs": 37,
"total_detected_avs": 1,
"progress_percentage": 100,
"scan_all_result_a": "Infected"
},
"file_info": {
"file_size": 24064,
"upload_timestamp": "2019-02-27T13:22:15.653Z",
"md5": "718AD665F282996F8AD75397E4CE9301",
"sha1": "F4420B7F7BC3C1E875373FC5DBE5099DE082F143",
"sha256": "9A43A628A61B29489BDB738F03EA13C54C10E41CE23B3FED05A9DE789CCBBBF2",
"file_type_category": "D",
"file_type_description": "Microsoft Word 97-2003 Document",
"file_type_extension": "doc",
"display_name": "Unknown Filename"
},
"share_file": 1,
"rest_version": "4",
"additional_info": [],
"votes": {
"up": 0,
"down": 0
}
}

Errors

Please refer to Errors for more information.

Sample code (Node.js)

var http = require("https");
 
var options = {
"method": "POST",
"hostname": [
"api",
"metadefender",
"com"
],
"path": [
"v4",
"file"
],
"headers": {
"content-type": "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
"apikey": process.env.APIKEY,
"Content-Type": "multipart/form-data",
"rule": "sanitize"
}
};
 
var req = http.request(options, function (res) {
var chunks = [];
 
res.on("data", function (chunk) {
chunks.push(chunk);
});
 
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
 
req.write("------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"\"; filename=\"C:\\Users\\user_name\\Documents\\test_doc.doc\"\r\nContent-Type: application/msword\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--");
req.end();

Sample code (cURL)

curl -X POST \
https://api.metadefender.com/v4/file \
-H 'Content-Type: multipart/form-data' \
-H "apikey: ${APIKEY}" \
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
-H 'rule: sanitize' \
-F '=@C:\Users\user_name\Documents\test_doc.doc'