Webhook Event Notification API
Viewtron IP cameras and NVRs can push real-time AI detection events to your HTTP server as webhooks. When a camera detects a person, vehicle, face, or license plate, it sends an HTTP POST to your server with XML data containing the event details, bounding box coordinates, and optionally base64-encoded JPEG images of the scene and detected target.
No polling required — your server receives events the moment they happen. No cloud service, no monthly fees, no third-party dependencies. The camera posts directly to your server on your local network or over the internet.
What You Can Build
- Real-time alert systems — push notifications when AI detections occur
- Event logging and analytics — record all detections with timestamps, images, and metadata
- Custom automation — trigger actions (lights, relays, gates, alarms) based on detection events
- Integration with VMS, SIEM, or building management systems
- Multi-camera event aggregation and dashboards
Two Sources of Webhook Data
| Source | Format | Supports traject | Setup |
|---|---|---|---|
| IP Camera (direct) | IPC v1.x XML | Yes | Configure on camera via API or web interface |
| NVR (forwarded) | NVR v2.0 XML | No | Configure on NVR web interface |
Recommended setup: Configure the NVR to forward alarm events (images included), and configure individual cameras to send traject real-time tracking data directly. Your server receives both streams simultaneously.
How It Works
- Configure the webhook destination on the camera or NVR — your server's IP, port, and URL path
- Enable detection types you want to receive (perimeter, face, LPR, etc.)
- Start your HTTP server listening for POST requests
- Parse the XML when events arrive — use the Viewtron Python SDK (
pip install viewtron) or Node.js SDK to handle parsing automatically - Respond with success XML to keep the connection alive
Supported Detection Types
| IPC smartType | NVR smartType | Detection |
|---|---|---|
PEA (intrusion) | regionIntrusion | Human Detection / Intrusion |
PEA (line cross) | lineCrossing | Perimeter / Line Crossing |
VEHICE | vehicle | License Plate Recognition |
VFD | videoFaceDetect | Face Detection |
PASSLINECOUNT | targetCountingByLine | People Counting |
TRAFFIC | targetCountingByArea | People Counting |
VSD | videoMetadata | Video Metadata (full-frame detection) |
VFD_MATCH | Not supported | Face Recognition Match (IPC only) |
Webhook Message Types
Every webhook POST is one of three message types:
| Type | Purpose | Size | Frequency |
|---|---|---|---|
| keepalive | Heartbeat — confirms connection is active | ~300 bytes | Every 30-120 seconds |
| alarmStatus | Alarm state change (on/off) | ~660 bytes | One per state change |
| alarmData | Full detection event with coordinates and images | 2 KB - 530 KB | One per detection |
Configuring Webhooks via API
Use SetHttpPostConfig to configure the webhook destination on IP cameras. The httpPostV2 system supports up to 3 URLs with independent event filtering:
<?xml version="1.0" encoding="UTF-8"?>
<config version="1.0" xmlns="http://www.ipc.com/ver10">
<httpPostV2><postUrlConf>
<urlList type="list" count="1"><item>
<urlId>1</urlId>
<switch>true</switch>
<url>
<protocol>http</protocol>
<domain><![CDATA[192.168.0.53]]></domain>
<port>5002</port>
<path><![CDATA[/API]]></path>
<authentication>none</authentication>
</url>
<heatBeatSwitch>true</heatBeatSwitch>
<keepaliveTimeval>90</keepaliveTimeval>
<subscribeDateType type="list" count="5">
<item>alarmStatus</item>
<item>traject</item>
<item>smartData</item>
<item>sourceImage</item>
<item>targetImage</item>
</subscribeDateType>
<subscriptionEvents type="list" count="1">
<item>PERIMETER</item>
</subscriptionEvents>
</item></urlList>
</postUrlConf></httpPostV2>
</config>
Data Type Subscriptions (httpPostV2)
Control what data each webhook URL receives:
| Data Type | Description | Post Size |
|---|---|---|
alarmStatus | Alarm on/off state changes | ~660 bytes |
traject | Continuous real-time target tracking | ~1.7 KB at ~7/sec |
smartData | Detection event with coordinates | ~2-3 KB |
sourceImage | Full-frame JPEG (base64 in XML) | ~500 KB |
targetImage | Cropped target JPEG (base64 in XML) | Included with smartData |
Subscribe to smartData + sourceImage + targetImage to receive complete detection events with both overview and cropped target images in a single POST.
Server Response
Your server must respond with this XML to keep the connection alive:
<?xml version="1.0" encoding="UTF-8"?>
<config version="1.0" xmlns="http://www.ipc.com/ver10">
<status>success</status>
</config>
Receiving All Event Types
- Python SDK
- Node.js SDK
- NVR XML (v2.0)
- IPC XML (v1.x)
The simplest way to receive all webhook event types. The SDK's ViewtronServer handles HTTP connections, keepalives, XML parsing, version detection, and routing — you just write the callback:
pip install viewtron
from viewtron import ViewtronServer
import os
IMG_DIR = "images"
os.makedirs(IMG_DIR, exist_ok=True)
def on_event(event, client_ip):
print(f"[{event.category}] {event.get_alarm_description()} from {client_ip}")
print(f" Camera: {event.get_ip_cam()}")
print(f" Type: {event.get_alarm_type()}")
# LPR-specific fields
if event.category == "lpr":
print(f" Plate: {event.get_plate_number()}")
print(f" Group: {event.get_plate_group()}")
# Face-specific fields (NVR v2.0)
if event.category == "face":
age = event.get_face_age()
if age:
print(f" Age: {age}, Sex: {event.get_face_sex()}")
# Save images
overview = event.get_source_image_bytes()
if overview:
with open(f"{IMG_DIR}/{event.get_time_stamp()}-overview.jpg", "wb") as f:
f.write(overview)
target = event.get_target_image_bytes()
if target:
with open(f"{IMG_DIR}/{event.get_time_stamp()}-target.jpg", "wb") as f:
f.write(target)
server = ViewtronServer(port=5002, on_event=on_event)
server.serve_forever()
See the Python SDK reference for the full list of methods and event classes.
npm install viewtron-sdk
const { ViewtronServer } = require('viewtron-sdk');
const fs = require('fs');
fs.mkdirSync('images', { recursive: true });
const server = new ViewtronServer({ port: 5002 });
server.on('event', (event, clientIP) => {
console.log(`[${event.category}] ${event.eventType} from ${clientIP}`);
// LPR-specific fields
if (event.category === 'lpr') {
console.log(` Plate: ${event.plateNumber}`);
console.log(` Group: ${event.plateGroup}`);
}
// Face-specific fields (NVR v2.0)
if (event.category === 'face' && event.face) {
console.log(` Age: ${event.face.age}, Sex: ${event.face.sex}`);
}
// Save images
if (event.sourceImageBytes) {
fs.writeFileSync(
`images/${Date.now()}-overview.jpg`,
event.sourceImageBytes
);
}
if (event.targetImageBytes) {
fs.writeFileSync(
`images/${Date.now()}-target.jpg`,
event.targetImageBytes
);
}
});
server.start();
NVR v2.0 events use <messageType>alarmData</messageType> with <smartType> to identify the detection type. Each event type has its own XML structure — see the individual application pages for type-specific examples:
- Human Detection (regionIntrusion)
- Line Crossing (lineCrossing)
- Face Detection (videoFaceDetect)
- License Plate Recognition (vehicle)
- People Counting (targetCountingByLine / targetCountingByArea)
See the NVR Event Format reference for the complete v2.0 XML structure.
IPC v1.x events use <smartType type="openAlramObj"> to identify the detection type. Each type uses the same outer structure but different inner elements:
PEA— intrusion or line crossing (check for<perimeter>vs<tripwire>)VFD— face detectionVEHICE— license plate recognitionPASSLINECOUNT— line countingTRAFFIC— area countingVSD— video metadataAOIENTRY/AOILEAVE— region entry/exit
See the IPC Event Format reference for the complete v1.x XML structure.
Relevant API Endpoints
| Endpoint | Purpose | Reference |
|---|---|---|
| SetHttpPostConfig | Configure webhook destination and subscriptions | Webhook Config |
| GetHttpPostConfig | Read current webhook configuration | Webhook Config |
| GetAlarmStatus | Poll current alarm state | Alarm Status |
Integrations
Viewtron webhook events also integrate with automation platforms via published packages:
| Platform | Package | What It Does |
|---|---|---|
| Home Assistant | viewtron-home-assistant | All detection events as native HA sensors — automate anything in Home Assistant |
| Node-RED | node-red-contrib-viewtron | All detection events direct to Node-RED flows — visual automation builder |
Related Resources
- Python API Server — github.com/mikehaldas/IP-Camera-API — full-featured server handling all detection types
- Webhook format details — IPC Event Format and NVR Event Format
- Detection types reference — All Detection Types
Related Products
- Viewtron AI Security Cameras — IP cameras with built-in AI detection
- Viewtron IP Camera NVRs — NVRs with HTTP POST event forwarding
Questions & Development Inquiries
- Email: mike@viewtron.com
- Phone: 561-433-8488
- Forum: NVR Webhook Setup Guide
Mike Haldas is available for questions, consultation, and custom software development for Viewtron API related projects. Email details about your project to mike@viewtron.com.