Webhooks
Real-time event notifications for your applications.
Overview
Webhooks allow you to receive real-time notifications when events occur in your PropTechUSA account.
Supported Events
| Event | Description |
|---|
lead.created | New lead submitted |
|---|---|
lead.updated | Lead information updated |
lead.status_changed | Lead status changed |
property.valuated | Property valuation completed |
offer.created | New offer generated |
Webhook Payload
{
"id": "evt_abc123",
"type": "lead.created",
"created_at": "2024-01-15T10:30:00Z",
"data": {
"id": "lead_xyz789",
"name": "John Doe",
"email": "john@example.com"
}
}
Setting Up Webhooks
1. Create Endpoint
Create an endpoint in your application to receive webhooks:
// app/api/webhooks/proptech/route.ts
import { headers } from 'next/headers';
import { PropTech } from '@proptechusa/sdk';
export async function POST(request: Request) {
const body = await request.text();
const signature = headers().get('x-proptech-signature');
// Verify signature
const isValid = PropTech.webhooks.verify(
body,
signature,
process.env.PROPTECH_WEBHOOK_SECRET
);
if (!isValid) {
return new Response('Invalid signature', { status: 401 });
}
const event = JSON.parse(body);
// Handle the event
switch (event.type) {
case 'lead.created':
// Handle new lead
break;
case 'lead.status_changed':
// Handle status change
break;
}
return new Response('OK', { status: 200 });
}
2. Register Webhook URL
Register your endpoint in the PropTechUSA dashboard or via API:
await proptech.webhooks.create({
url: 'https://yourdomain.com/api/webhooks/proptech',
events: ['lead.created', 'lead.status_changed'],
});
Retry Policy
Failed webhook deliveries are retried:
- 1st retry: 1 minute
- 2nd retry: 5 minutes
- 3rd retry: 30 minutes
- 4th retry: 2 hours
- 5th retry: 24 hours