> For the complete documentation index, see [llms.txt](https://apidocs.lwolf.com/doc/spacio-api/llms.txt)

# Webhooks & Notifications

## Webhooks (Beta)

Enable real-time notifications instead of polling.

### Supported Events

- `lead.registered` - New lead captured
- `lead.status_changed` - Lead status updated
- `property.status_changed` - Property listing status changed
- `property.price_changed` - Price updated
- `open_house.scheduled` - Open house created
- `open_house.cancelled` - Open house cancelled

### Webhook Setup

1. Configure endpoint in Spacio dashboard
2. Spacio will POST events to your URL
3. Respond with 200 status within 10 seconds

### Webhook Payload

```json
{
  "event": "lead.registered",
  "timestamp": "2024-01-15T14:30:00Z",
  "data": {
    "registrant_id": "reg_123",
    "property_id": "prop_456",
    "email": "buyer@example.com"
  },
  "signature": "sha256_hash"
}
```

### Verification

Verify webhook authenticity:
```python
import hmac
import hashlib

def verify_webhook(payload, signature, secret):
    expected = hmac.new(
        secret.encode(),
        payload.encode(),
        hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(signature, expected)
```

### Retry Policy

Spacio retries failed deliveries:
- First attempt: Immediate
- 2nd-4th attempts: Exponential backoff
- Max 24 hour window

### Notification Preferences

Configure which events to receive in dashboard:
- Email notifications
- SMS alerts
- Webhook deliveries
- Frequency preferences

### Best Practices

1. **Respond quickly** - 10 second timeout
2. **Idempotency** - Handle duplicate events
3. **Queue processing** - Don't process synchronously
4. **Verify signature** - Ensure authenticity
5. **Log all webhooks** - For debugging

