Verification Events#

CasaPay sends webhook events to notify your application about changes to verification sessions and reports.

Event Types#

EventDescription
verification_session.createdA new verification session was created
verification_session.pendingThe applicant has started the verification flow
verification_session.processingVerification data is being processed
verification_session.completedAll verification checks are complete
verification_session.expiredThe session expired before completion
verification_session.failedThe verification session failed
verification_report.readyThe full verification report is available
document_upload.processedA document upload has been processed
document_upload.rejectedA document was rejected (e.g., fraud detected)
identity_check.passedAn identity check passed
identity_check.failedAn identity check failed

Event Object#

{
  "id": "evt_1a2b3c4d",
  "object": "event",
  "type": "verification_session.completed",
  "data": {
    "object": {
      "id": "vs_1a2b3c4d5e6f",
      "object": "verification_session",
      "status": "completed",
      "applicant": {
        "first_name": "Jane",
        "last_name": "Doe",
        "email": "jane.doe@example.com"
      },
      "report": "vr_9z8y7x6w5v",
      "products": ["identity", "income", "credit", "cash_flow"]
    }
  },
  "created": 1706140800,
  "livemode": false
}

Handling Verification Events#

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

  switch (event.type) {
    case 'verification_session.completed':
      const session = event.data.object;
      const report = await casapay.verificationReports.retrieve(session.report);
      await processVerificationResult(session, report);
      break;

    case 'verification_session.expired':
      await sendReminderEmail(event.data.object.applicant.email);
      break;

    case 'document_upload.rejected':
      await requestNewDocument(event.data.object);
      break;
  }

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