Webhooks
To provide more visibility and information about the events happening after the user is redirected to WMS, we offer an optional Webhook facility.
In order to opt-in to receive the events via a webhook, you need to provide a URL for the webhook which will be added to the Config ID along with an assigned MAC secret for validation.
If a Config ID has a webhook associated with it, events will be sent to the webhook as they happen. The events will be sent in the body of a POST call to the webhook.
Events
Event | Severity | Payload | Description |
---|---|---|---|
WMS_LOADED | INFO | - | WMS has been loaded |
CONFIGURATION_LOADED | INFO | - | Config fetched using the provided Config ID |
CAMERA_PERMISSION_GRANTED | INFO | - | User has granted the camera permission |
CAMERA_PERMISSION_DENIED | ERROR | - | User has denied the camera permission |
CAMERA_STARTED | INFO | - | Camera started. This can be either by user or automatically. |
MEASUREMENT_STARTED | INFO | - | Measurement Started. This can be either by user or automatically. |
MEASUREMENT_CREATED | INFO | Measurement ID | Measurement created and got the measurement ID |
INTERMEDIATE_RESULTS | INFO | SNR, Sequence, Measurement ID | Intermediate result received |
SCAN_COMPLETED | INFO | Measurement ID | Scan has completed and waiting for the final results |
RESULTS_RECEIVED | INFO | Measurement ID | Final results have been received |
REDIRECTING_TO_CALLBACK | INFO | Measurement ID (if created) | Starting the redirect to the callback URL |
MEASUREMENT_CANCELED | WARN | Measurement ID | Measurement has been cnceled |
CONSTRAINT_VIOLATION | ERROR | Constraint Violated, Measurement ID (If created) | A constraint has been violated (resulting in measurement cancel) |
PAGE_UNLOADED | INFO | Measurement ID (If created) | Either the user has closed the browser (tab) or typed a new URL and navigating away from WMS |
WEBSOCKET_DISCONNECTED | WARN | Measurement ID | Websocket has been disconnected |
WEBSOCKET_RECONNECTED | INFO | Measurement ID | Websocket has been reconnected |
WEBSOCKET_RECONNECTION_FAILED | ERROR | Measurement ID | Websocket failed to reconnect |
API_ERROR | ERROR | API Error Code, Measurement ID (If created) | API threw an error |
PAGE_VISIBILITY_CHANGE | INFO | Visible / Hidden, Measurement ID (If created) | User minimized / maximized the browser or switched to anothe tab / application |
Event body
{
"timestamp": 1689684577,
"sessionId": "ryueiwoqfh910fu3rpqruvfiu",
"sequence": 0,
"event": "MEASUREMENT_CREATED",
"severity": "INFO"
"payload": {
"measurementId": "f0c8ca8d-111d-4dcf-a69d-46ed39a2db06"
},
}
Field | Description |
---|---|
timestamp | The time of the event |
sessionId | The session ID provided when constructing the call-in URL |
sequence | The sequence of the event, starts at 0 and incremented with each event |
event | Event code as shown on the list of events |
payload | If the event has a payload, it will be provided in the payload section. Example: Measurement ID, SNR etc. |
Webhook Validation
A hash of the body contents using the hook's MAC secret (macSecret) is given in the X-WMS-Content-MAC header. The recipient can verify this value to make sure that the webhook call was initiated by WMS by doing the following computation (in JavaScript, for example):
// Note: Use the provided MAC secret here
const hmac = require('crypto').createHmac('sha256', macSecret);
hmac.update(requestBody.toString(), 'ascii');
const expectedContentHmac = 'hmac-sha256=' + hmac.digest('hex');