Events Webhook
Describes the Viare events webhook, and provides an example you can use to easily integrate.
The Viare event webhook performs a POST of a JSON payload to a nominated HTTPS endpoint.
The POST request also carries an x-estar-signature header, which can be (optionally) used to validate the authenticity of the message.
If you’re using .NET, the following example can be used within your code to read the payload, and validate the header:
using System.Security.Cryptography;
using System.Text.Encoding;
string data;
using (StreamReader reader = new StreamReader(http.Request.InputStream)) {
data = reader.ReadToEnd();
if (!String.IsNullOrEmpty(data)) {
bool MessageValid = false;
using (HMACSHA256 hmac = new HMACSHA256(UTF8.GetBytes("[Key]"))) {
byte[] messageBytes = UTF8.GetBytes(data);
var hash = hmac.ComputeHash(messageBytes);
string computedHash = System.Convert.ToBase64String(hash);
string receivedHash = http.Request.Headers.Get("x-estar-signature");
MessageValid = (receivedHash == computedHash);
}
}
}
if (MessageValid){
// Process data.
}
Payloads
The payload itself is of the form below. A complete list of events, details and payloads is listed here .
{
subscriber: 1,
sequence: 1,
type: "dispatch.shipped",
message: {
orderID: "111111",
externalReferences: [],
dispatchPoint: "Location",
freightProvider: "PBT",
shipping: [
{
reference: "123456"
}
]
}
}ℹ️Note
The subscriber and sequence numbers can be used to recover any missing messages.
The sequence number is sequential for a subscriber, meaning missing messages can be identified and recovered if desired from the Event API
Updated 4 months ago
Check out all the events and payloads available on the next page.
