Example Handler
Set up an HTTP or HTTPS endpoint function that can accept webhook requests with a POST method.
Example endpoint
This code snippet is a webhook function configured to check that the event type was received, to handle the event, and return a 200 response.
// This example uses Express 4.x to receive events. Use body-parsing middleware express.json()
const request_signature = request.get('ca_signature');
const event_mes = request.body;
const hmac = createHmac('sha256', webhook_secret); //webhook_secret: get it from Webhooks page
hmac.update(JSON.stringify(event_mes));
const signature = hmac.digest('hex');
if(request_signature === signature) {
//message authenticity checked. proceed with actions.
}