Send HTTP Webhook

Send metadata, snapshots, clips from the pipeline to a HTTP endpoint / API at a periodic interval or based on a trigger.

Overview

Send HTTP Webhook node sends pipeline metadata to a Web service periodically or when a trigger condition is met.

Inputs & Outputs

  • Inputs : 1, Media Format : Any
  • Outputs : 1, Media Format: Same as Input
  • Output Metadata : webhook_sent_delta

Properties

PropertyDescriptionTypeDefaultRequired
trigger_typeWhen to collect metadata. Options: Custom Trigger (custom_trigger): Collect metadata when a custom trigger is fired; Auto Trigger (auto_trigger): Collect metadata when significant node properties change; Interval (periodic): Collect metadata periodically; Startup (startup): Collect metadata on the first frame of the source; Shutdown (shutdown): Collect metadata when the deployment shuts down.enumauto_triggerYes
triggerSend a webhook when this condition evaluates to true. Conditional on trigger_type being custom_trigger.trigger-conditionnullNo
intervalHow frequently to send webhook. Set to 0 to publish every time metadata is collected. Unit: seconds.number0Yes
delayDelay (in seconds) after the trigger before sending the webhook. Set to 0 to send immediately. Unit: seconds.number0No
webhook_urlPOSTs to this URL directly from the GatewaystringnullYes
formatFormat. Options: JSON POST (application_json): Send metadata as JSON in request body (application/json); Form Multipart POST (form_multipart): Send metadata as JSON file attachment. Can send clips and snapshots; Custom Body POST (custom_body_post): Send custom body as a POST request; HTTP GET (http_get): Make a HTTP Get request without any body.enumapplication_jsonYes
metadata_filter_patternsComma separated list of metadata patterns to keep in the JSON body of the webhook. Format: comma-separated metadata paths or patterns.stringnullNo
custom_body_templateUse Jinja2 template syntax to customize the body of the POST request. Conditional on format being custom_body_post.string{}Yes
json_formatMetadata JSON Format. Options: Dynamic Keys (dynamic_keys): Use certain attributes, e.g. ROI names, as keys. Useful for JSON path operations; Static Keys (static_keys): Convert all attributes to a named static key.enumdynamic_keysYes
include_frame_metadataAttach frame metadata. Conditional on format being form_multipart.booltrueNo
include_snapshotAttach frame snapshot. Conditional on format being form_multipart.boolfalseNo
include_object_snapshotsex. car, person, car.red. Attach snapshots for all matching objects from the time the trigger happened with the webhook. Conditional on format being form_multipart.model-labelsnullNo
clip_nodeAttach the most recent clip from the named Save Clip node with the webhook. The node must be configured to store clips locally. Delays webhook until a clip is available or timeout is reached. Conditional on format being form_multipart. Accepted node type: clip.stringnullNo
include_clip_metadataAttaches metadata from the clip along with the media. Conditional on format being form_multipart.boolfalseNo
max_media_wait_timeMax. wait time until media clip is available. Conditional on format being form_multipart. Unit: seconds.number10No
authAuthentication. Options: None (none); Basic (basic); Digest (digest).enumnoneNo
usernameUsernamestringnullNo
passwordPasswordstringnullNo
extra_headersComma separated list of headers to insert into the request. Format: HeaderName:HeaderValuestringnullNo
max_retriesMaximum number of times to retry in case of failure.number3No
compressionIf enabled, Gzip encoding reduces bandwidth required to send the metadata. Disable if the webhook endpoint does not support it.boolfalseNo
debugLog Debug Messages?boolfalseNo

Webhook Format

JSON POST

When format is set to application_json, the contents of the Frame's metadata (see Frame Metadata section below) are sent as the body of a POST request made to the webhook_url.

Form Multipart POST

When format is set to form_multipart, the POST request to the webhook_url can contain one or more of the following "files" when the corresponding settings are enabled in the node settings.

KeyFileNameFile Contents
metadatameta.json (or meta.json.gz if compression is enabled)Contains the contents of the triggering Frame's Metadata described below.

Maximum 1 per POST request.
snapshotsnapshot.jpgContains the snapshot from the frame when the webhook was triggered.
clip<capture-timestamp>.mp4Media Clip generated by a Save Clip Node
clipmetadata<capture-timestamp>.mp4.jsonMetadata corresponding to the entire Media Clip, in the same format as described below.

Frame Metadata

This section describes the format of each Frame's metadata that is sent in the webhook.

KeyDescription
versionIndicates the metadata format version.
1: Dynamic Keys;
2: Static Keys.
deployment_idThe unique ID of the deployment that generated this metadata.
metaObject containing one or more entries keyed by frame-relative timestamps. Each entry holds metadata for a single frame.
meta.<relative_timestamp>Metadata for a particular frame, keyed by its timestamp (relative to stream start). This includes key-value pairs reflecting metadata provided by all nodes in the pipeline up to the Webhook node.
If the node's batch property is enabled, there may be multiple such timestamped frame metadata entries.
{
  "version": 1,
  "deployment_id": "6372b7e6-e5d6-45b8-b31b-c400a3754ff4",
  "meta": {
    "0:06:40": {
      "timestamp": "2022-11-04T23:41:34.036574Z",
      "nodes": {
        "video1": {
          "type": "video_source",
          "source_id": "6372b7e6-e5d6-45b8-b31b-c400a3754ff4",
          "source_name": "Milestone-AXIS P1455-LE (172.16.0.38) - Camera 1",
          "source_type": "stream",
          "uri": "rtsp://172.16.0.45:554/live/658040e2-fe47-4d4b-9a27-2217af4c4193"
        },
        "annotate_presence1": {
          "type": "annotate_presence",
          "rois": {
            "roi1": {
              "coords": [
                [1, 1],
                [100, 100],
                [200, 200]
              ],
              "total_objects": 2,
              "objects_entered_delta": 1,
              "objects_exited_delta": 0,
              "objects_above_max_time_threshold_count": 1,
              "current_objects_count": 2,
              "current_objects": {
                "15069984211300461000": {
                  "first_seen": 20,
                  "time_present": 3600
                },
                "1506998428100461000": {
                  "first_seen": 22,
                  "time_present": 20
                }
              }
            }
          }
        }
      },
      "objects": [
        {
          "attributes": [],
          "probability": -0.10000000149011612,
          "class_id": 0,
          "rect": {
            "top": 236.29208374023438,
            "height": 15.62222957611084,
            "left": 339.904052734375,
            "width": 31.91175079345703
          },
          "id": 1506998428100461000,
          "label": "car"
        },
        {
          "attributes": [],
          "probability": -0.10000000149011612,
          "class_id": 0,
          "rect": {
            "top": 250.60275268554688,
            "height": 19.088224411010742,
            "left": 235.5812530517578,
            "width": 35.78194046020508
          },
          "id": 1506998428100461000,
          "label": "car"
        },
        {
          "attributes": [],
          "probability": -0.10000000149011612,
          "class_id": 0,
          "rect": {
            "top": 447.784912109375,
            "height": 244.92181396484375,
            "left": 0,
            "width": 158.60867309570312
          },
          "id": 1506998428100460500,
          "label": "car"
        },
        {
          "attributes": [],
          "probability": -0.10000000149011612,
          "class_id": 0,
          "rect": {
            "top": 495.3921813964844,
            "height": 205.00851440429688,
            "left": 427.19415283203125,
            "width": 135.38002014160156
          },
          "id": 1506998428100460500,
          "label": "car"
        },
        {
          "attributes": [],
          "probability": -0.10000000149011612,
          "class_id": 0,
          "rect": {
            "top": 518.0147705078125,
            "height": 194.1524200439453,
            "left": 239.1914825439453,
            "width": 158.16836547851562
          },
          "id": 1506998428100460500,
          "label": "car"
        },
        {
          "attributes": [],
          "probability": -0.10000000149011612,
          "class_id": 0,
          "rect": {
            "top": 538.0975952148438,
            "height": 173.88412475585938,
            "left": 96.46807098388672,
            "width": 154.6107940673828
          },
          "id": 1506998428100461000,
          "label": "car"
        }
      ]
    }
  }
}
{
  "version": 2,
  "deployment_id": "6372b7e6-e5d6-45b8-b31b-c400a3754ff4",
  "meta": [
    {
      "relative_timestamp": "0:06:40",
      "timestamp": "2022-11-04T23:41:34.036574Z",
      "nodes": [
        {
          "id": "video1",
          "type": "video_source",
          "source_id": "6372b7e6-e5d6-45b8-b31b-c400a3754ff4",
          "source_name": "Milestone-AXIS P1455-LE (172.16.0.38) - Camera 1",
          "source_type": "stream",
          "uri": "rtsp://172.16.0.45:554/live/658040e2-fe47-4d4b-9a27-2217af4c4193"
        },
        {
          "id": "annotate_presence1",
          "type": "annotate_presence",
          "rois": [
            {
              "label": "roi1",
              "coords": [
                [1, 1],
                [100, 100],
                [200, 200]
              ],
              "total_objects": 2,
              "objects_entered_delta": 1,
              "objects_exited_delta": 0,
              "objects_above_max_time_threshold_count": 1,
              "current_objects_count": 2,
              "current_objects": [
                {
                  "id": "15069984211300461000",
                  "first_seen": 20,
                  "time_present": 3600
                },
                {
                  "id": "1506998428100461000",
                  "first_seen": 22,
                  "time_present": 20
                }
              ]
            }
          ]
        }
      ],
      "objects": [
        {
          "attributes": [],
          "probability": -0.10000000149011612,
          "class_id": 0,
          "rect": {
            "top": 236,
            "height": 15,
            "left": 339,
            "width": 31
          },
          "id": 1506998428100461000,
          "label": "car"
        },
        {
          "attributes": [],
          "probability": -0.10000000149011612,
          "class_id": 0,
          "rect": {
            "top": 250,
            "height": 19,
            "left": 235,
            "width": 35
          },
          "id": 1506998428100461000,
          "label": "car"
        },
        {
          "attributes": [],
          "probability": -0.10000000149011612,
          "class_id": 0,
          "rect": {
            "top": 447,
            "height": 244,
            "left": 0,
            "width": 158
          },
          "id": 1506998428100460500,
          "label": "car"
        },
        {
          "attributes": [],
          "probability": -0.10000000149011612,
          "class_id": 0,
          "rect": {
            "top": 495,
            "height": 205,
            "left": 427,
            "width": 135
          },
          "id": 1506998428100460500,
          "label": "car"
        },
        {
          "attributes": [],
          "probability": -0.10000000149011612,
          "class_id": 0,
          "rect": {
            "top": 518,
            "height": 194,
            "left": 239,
            "width": 158
          },
          "id": 1506998428100460500,
          "label": "car"
        },
        {
          "attributes": [],
          "probability": -0.10000000149011612,
          "class_id": 0,
          "rect": {
            "top": 538,
            "height": 173,
            "left": 96,
            "width": 154
          },
          "id": 1506998428100461000,
          "label": "car"
        }
      ]
    }
  ]
}

Custom Body POST

When format is set to custom_body_post, the contents of custom_body_template are sent as the body of a POST request made to the webhook_url.
custom_body_template uses Jinja2 Template Syntax for customizing the body of the POST request.

Variables available to the template:

VariableDescription
metaOriginal webhook metadata in JSON format. This contains the contents of the metadata as per the Frame Metadata section above.
application_idThe application ID of the deployment that produced this metadata.
application_nameThe application name of the deployment that produced this metadata.
deployment_idThe deployment ID of the deployment that produced this metadata.
deployment_nameThe deployment name of the deployment that produced this metadata.
gateway_idThe gateway ID of the deployment that produced this metadata.
gateway_nameThe gateway name of the deployment that produced this metadata.

Example templates

Static text content:

Text content

Reference specific metadata (when used with json_format set to static_keys):

{ "deployment_id": "{{ deployment_id }}", "source_id": "{{ meta['meta'][0]['nodes'][0]['source_id'] }}" }

Metadata reinserted as is:

{{ meta | tojson }}

Output Metadata

The fields below are declared by this node's metadata schema; the JSON values are representative examples.

PathTypeDescription
nodes.<node_id>.webhook_sent_deltainteger1 When a webhook is sent, 0 otherwise
nodes.<node_id>.typestringIdentifies the node type that produced this metadata.

JSON example

{
  "nodes": {
    "webhook_local1": {
      "type": "webhook_local",
      "webhook_sent_delta": 0
    }
  }
}

Did this page help you?