# Push Messages (webhooks)
The NiXT Platform send events to your webhook to notify you when a variety of interactions or events happen. The NiXT Platform sends a HTTP POST request with a webhook event object to your webhook URL
Make sure that your webhook processes the webhook event objects correctly.
Security warning
Your webhook may receive malicious HTTP POST requests that was not sent from the NiXT Platform.
Do not process any webhook event objects until you have verified their signatures.
Tip
We recommend processing events asynchronously, so that processing an HTTP POST request does not cause delays in processing subsequent requests.
# Verifying signatures
Have your webhook verify the signature in the x-nixt-signature request, header to confirm that the request was sent from the NiXT Platform.
Using the HMAC-SHA256 algorithm with the channel secret as the secret key, compute the digest for the request body.
Confirm that the Base64-encoded digest matches the signature in the x-nixt-signature request header.
The following is an example of how to implement signature validation in Node.js.
const crypto = require('crypto');
const secretKey = '...'; // app secret key string
const body = '...'; // Request body string
const signature = crypto
.createHmac('SHA256', secretKey)
.update(body).digest('base64’);
// Compare x-nixt-signature request header and the signature
# Webhook types
You can control and respond to the user based on the data in the webhook event object. For more information, see Webhook event object in the table below.
| Event Type | Description |
|---|---|
| Push Event | Notify immediately when happen from NiXT Platform |
# Push event
Webhook event object which contains sending messages. The message property contains a message object which corresponds with the message type.
| Parameter | Type | Description |
|---|---|---|
| event | enum | PushEvent is special data type that enables for a variable as a set of predefined constants and determine PushDataBody.
|
| type | enum | PushType is special data type that enables for a variable as a set of predefined constants.
|
| meta | Object | PushMetaData is object contain contents of the message. Message types include: |
| data | Object | PushDataBody Information depends on PushEvent |
| eventAt | Date | Datetime of the event |
# alarm
A message object which contains the text sent from the database source.
| Parameter | Type | Description |
|---|---|---|
| _id | ObjectId | Object ID from collection alarm |
| title | String | Message's title |
| description | String | Message's content |
| elementName | String | Element's name |
| troubleShoot | String | Message's trouble shooting |
| value | Any | Message's content |
| properties | Any | Device's properties |
| serverity | enum | There are 4 severity that consist of 'info', 'minor', 'major', 'critical' |
| status | enum | There are 3 status that consist of 'open', 'clear', 'ack'(acknowledge)* |
| StartAt | Date | The start Datetime of the event with status is 'oepn' |
| endAt | Date | The end Datetime of the event with status is 'close' |
| remindCount | number | Count of remind following to action |
| ack | Object | Acknowledge's information is consist of userId, email, and date |
| nextAlertAt | Date | Next alert date time to remind |
| lastHappenAt | Date | The lasted happen date time |
# device
Message object which contains the text sent from the database source.
| Parameter | Type | Description |
|---|---|---|
| _id | ObjectId | Object ID from collection devices |
| deviceName | String | Device's name |
| deviceType | String | Device's type |
# site
Message object which contains the text sent from the database source.
| Parameter | Type | Description |
|---|---|---|
| _id | ObjectId | Object ID from collection sites |
| siteName | String | Site's name |
| code | String | Project's code |
# template
Message object which contains the text sent from the database source.
| Parameter | Type | Description |
|---|---|---|
| _id | ObjectId | Object ID from collection alarm_template |
| templateCode | String | Alarm template code |
# data
Message object which contains the text sent from the database source and depend on PushEvent
- Server status
| Parameter | Type | Description |
|---|---|---|
| status | number | Server status code number |
| type | enum | Status type 'NEW','CLEAR' |
- Inverter alarm
| Parameter | Type | Description |
|---|---|---|
| type | enum | Status type 'NEW','CLEAR' |
| tag | String | Tag code from Inverter alarm monitor |
| code | number | Alarm code from manufacturers' inverter |
- Inverter status
| Parameter | Type | Description |
|---|---|---|
| type | enum | Status type 'NEW','CLEAR' |
| code | number | Status code from manufacturers' inverter |
- Threshold alarm
| Parameter | Type | Description |
|---|---|---|
| type | enum | Status type 'NEW','CLEAR' |
| tag | String | Tag code from device that be required to monitor |
| value | number | actual value from device |
| threshold | number | Set point that be required to monitor |
| thresholdType | enum | Threshold level 'highhigh', 'high', 'low', 'lowlow' |
- UPS status
| Parameter | Type | Description |
|---|---|---|
| type | enum | Status type 'NEW','CLEAR' |
| code | number | Status code from IoT Standard |