MyCover AI
Services

Webhooks

Our webhooks provide instantaneous alerts whenever particular events take place within your account. These events encompass various actions, spanning from successful policy purchase to renewal.

To receive these notifications, you will need a POST endpoint on your server that can be called by our system to send you notifications.

Setup Webhook

To enable Webhooks, please follow the steps below:

Step 1

Log in to your Distributor dashboard. Then, click on the settings icon to navigate to the settings page.

Step 2

At the bottom, you will find the form to enter and save your webhook URL. Make sure to enable webhooks by toggling the switch on.

Validation

You can effortlessly verify webhooks received from the MyCover.ai platform by following these steps:

Signature Inclusion: Every sent webhook includes a signature in the headers. This signature is the encrypted webhook data using the merchant's (i.e Distributor) private secret API key.

Your secret API Key is located at Settings > Api Key & Web hooks. It is usually annotated with "MCASECK".

Validation on Merchant's End: Merchants can follow the same encryption steps using their secret API key. Then, they can compare the created signature with the one they received. If the signatures are the same, it's safe to go ahead and use the webhook information. However, if the signatures don't match, they should ignore the webhook and not use the information it carries.

const crypto = require("crypto");

const secretKey = 'MCASECK|49939d32-f649-4de4-ab35-51060ca292f9';

const signature = crypto
  .createHmac("sha512", secretKey)
  .update(JSON.stringify(req.body))
  .digest("hex");

if (req.headers['x-mycoverai-signature'] === signature) {
      const event = req.body;
      // Do something with event - that will not take long
      
      // Return Ok
      res.send(200);
}

Webhook Events

purchase.successful

This webhook event is triggered when a client initiates a policy purchase, and the transaction is successfully completed.

{
    "event": "purchase.successful",
    "data": {
      "id": "e431432e-3daa-11ee-be56-0242ac120002",
      "amount": 5000,
      "status": "successful",
      "reference": "BUY-PSKUEVZSSXVJRPQX",
      "customer": {
        "id": "db0c25ae0-3dab-11ee-be56-0242ac120002",
        "first_name": "Jack",
        "last_name": "Olu",
        "email": "[email protected]",
        "phone": "+2349162753630",
      },
      "product_id": "280798d6-3dac-11ee-be56-0242ac120002",
      "created_at": "2023-08-18T09:47:22.008Z",
      "updated_at": "2023-08-18T09:47:22.008Z",
      "policy_expiry_date": "2023-09-18T09:47:22.008Z",
    },
}

renewal.successful

This webhook event is triggered when a client initiates a policy renewal, and the transaction is successfully completed.

{
    "event": "renewal.successful",
    "data": {
      "id": "e431432e-3daa-11ee-be56-0242ac120002",
      "amount": 5000,
      "status": "successful",
      "reference": "BUY-PSKUEVZSSXVJRPQX",
      "customer": {
        "id": "db0c25ae0-3dab-11ee-be56-0242ac120002",
        "first_name": "Jack",
        "last_name": "Olu",
        "email": "[email protected]",
        "phone": "+2349162753630",
      },
      "product_id": "280798d6-3dac-11ee-be56-0242ac120002",
      "created_at": "2023-08-18T09:47:22.008Z",
      "updated_at": "2023-08-18T09:47:22.008Z",
      "policy_expiry_date": "2023-09-18T09:47:22.008Z",
    },
}