Webhooks are a useful tool for apps that want to interact with Pepperi in real-time by executing their code immediately when a specific workflow event happens on a Pepperi account , for example, after a sales rep creates a Sales Order on the Mobile App or a customer checks out a cart on the storefront.
 
So - instead of telling your app to make an API call every X number of minutes to check if a data update has occured on Pepperi, you can register webhooks as part of a Workflow, which sends an HTTP request from Pepperi telling your app that the data update has occurred.
 
This uses many less API requests overall, allowing you to build more robust apps, and update your app instantly after a webhook is received.
 
Authenticating a Webhook Request
 
X-Pepperi-Signature custom request header is used to authenticate webhooks.
The value of the header is : "sha256=the actual sha256 signature"
The sha256 signature is generated using the webhook's secret key(entered in the webhook UI), along with the data sent in the request body.
 
 
Webhook Request and Optional Response Types
 
Below is a sample of a webhook POST request generated by Pepperi :
 
Request Body:
 
{
 "ID": "ef6ed5b0-b7dc-44c5-9d8a-e8630318404b",
 "Delivery": {
  "ID": 2345522,
  "CreatedAt": "2016-09-06T09:24:22Z",
  "UpdatedAt": "2016-09-06T09:24:22Z"
 },
 "CompnayID": 232455,
 "TriggeredBy": {
  "ID": 123,
  "URI": "/users/123"
 },
 "Data": {
  "ID": 173331,
  "ExternalID": "ASFG9322",
  "URI": "/accounts/173331"
 }

}
 
The app listening to the webhook can either return an immediate response to Pepperi and the end user , or return a "callback URL" for Pepperi to check this URL for a later response - the later is used for Async process.
 
Below is a sample of response genrated by the listening App:
 
Sync Response :
 
{
 "Success": true,
 "HTMLResponse": "<b>great!</b>",
 "Timestamp": "2016-09-06T09:24:22Z"
}
 
Async Response:
 
{
 "Success": true,
 "AsyncCallback": {
  "URI": "https://integration.myapp.com/taskId=32323",
  "StartAfterSeconds": 180,
  "IntervalSeconds": 10
 },
 "Timestamp": "2016-09-06T09:24:22Z"
}