Guarantee Events#

CasaPay sends webhook events for guarantee lifecycle changes.

Event Types#

EventDescription
guarantee.createdA new guarantee was created
guarantee.activatedGuarantee is now active
guarantee.claimedA claim was filed
guarantee.expiredGuarantee expired
guarantee.cancelledGuarantee was cancelled
claim.submittedA new claim was submitted
claim.approvedA claim was approved
claim.deniedA claim was denied
claim.paidA claim payout was sent

Event Object#

{
  "id": "evt_grt_abc123",
  "object": "event",
  "type": "claim.approved",
  "data": {
    "object": {
      "id": "clm_ghi789",
      "object": "claim",
      "guarantee": "grt_def456",
      "amount": 120000,
      "currency": "eur",
      "status": "approved",
      "reason": "missed_payment"
    }
  },
  "created": 1709078400
}

Handling Guarantee Events#

app.post('/webhooks/casapay', async (req, res) => {
  const event = req.body;

  switch (event.type) {
    case 'claim.approved':
      await notifyLandlord(event.data.object, 'Claim approved — payout incoming');
      break;
    case 'claim.denied':
      await notifyLandlord(event.data.object, 'Claim denied');
      break;
    case 'guarantee.expired':
      await promptGuaranteeRenewal(event.data.object);
      break;
  }

  res.status(200).send();
});