AppFolio Webhooks & Events
Overview
AppFolio Stack delivers real-time webhook notifications for property management lifecycle events including tenant onboarding, lease execution, rent payments, and maintenance workflows. Use these webhooks to sync AppFolio data with your CRM, accounting system, or custom property management dashboards without polling the API.
Prerequisites
- Written confirmation in the current AppFolio partner contract that the target
portfolio supports the event types, registration process, delivery semantics,
and signature scheme. Do not infer webhook support from another integration.
- A bounded raw-body ingress route, managed webhook secret, durable event store,
queue, idempotency table, and owner for downstream accounting/CRM effects.
- A sandbox endpoint and synthetic events for valid, malformed, duplicate, and
delayed-delivery tests before production registration.
Instructions
- Register events only through the provider-issued process and contract-bound
client after verifying the target URL, allowlist, and secret delivery path.
- Verify bounded raw bytes and the signature before parsing; reject malformed
or replayed events without logging tenant, payment, or lease content.
- Persist the event ID, type, received time, and encrypted/minimized payload
transactionally before acknowledging delivery, then process it asynchronously.
- Enforce durable idempotency and reconcile unknown downstream outcomes before
writing CRM, accounting, tenant, lease, or work-order state.
Webhook Registration
// Use this only if the signed provider contract explicitly supports this API.
const response = await createVerifiedAppFolioClient().post("/webhooks", {
url: "https://yourapp.com/webhooks/appfolio",
events: ["tenant.created", "work_order.updated", "payment.received", "lease.signed"],
secret: process.env.APPFOLIO_WEBHOOK_SECRET,
});
Signature Verification
import crypto from "crypto";
import { Request, Response, NextFunction } from "express";
function verifyAppFolioSignature(req: Request, res: Response, next: NextFunction) {
const signature = req.headers["x-appfolio-signature"] as string;
const expected = Buffer.from(crypto
.createHmac("sha256", process.env.APPFOLIO_WEBHOOK_SECRET!)
.update(req.body)
.digest("hex"));
const received = signature ? Buffer.from(signature) : Buffer.alloc(0);
if (received.length !== expected.length || !crypto.timingSafeEqual(received, expected)) {
return res.status(401).json({ error: "Invalid signature" });
}
next();
}
Event Handler
import express from "express";
const app = express();
app.post("/webhooks/appfolio", express.raw({ type: "application/json" }), verifyAppFolioSignature, (req, res) => {
const event = JSON.parse(req.body.toString());
// persistIncomingEvent performs a durable idempotency insert and queue write
// in one transaction. A failed persist must receive a retryable response.
persistIncomingEvent(event).then(() => {
res.status(202).json({ received: true });
}).catch(() => {
res.status(503).json({ error: "Event persistence unavailable" });
});
});
Event Types
| Event |
Payload Fields |
Use Case |
tenant.created |
tenant_id, property_id, email |
Sync new tenant to CRM |
work_order.updated |
work_order_id, status, assigned_vendor |
Dispatch or escalate maintenance |
payment.received |
lease_id, amount_cents, payment_method |
Update accounting ledger |
lease.signed |
lease_id, move_in_date, term_months |
Activate unit and send welcome |
lease.expired |
lease_id, unit_id, vacate_date |
Trigger renewal or re-listing |
Retry & Idempotency
async function handleIdempotent(event: { id: string; type: string; data: any }) {
if (await durableEventStore.hasSucceeded(event.id)) return;
await routeEvent(event);
await durableEventStore.markSucceeded(event.id);
}
Error Handling
| Issue |
Cause |
Fix |
| Signature mismatch |
Wrong secret or parsed body |
Use express.raw() for verification |
| Duplicate events |
AppFolio retry on timeout |
Track event IDs for idempotency |
Missing property_id |
Event from archived property |
Check property status before processing |
| Durable store/queue unavailable |
Cannot guarantee acknowledged event survives |
Return retryable 503; do not acknowledge before persistence |
Output
- A contract-gated webhook registration decision and a fail-closed raw-body
signature verification result
- A durable receipt for each accepted event before acknowledgement, with
minimized/encrypted content and durable idempotency state
- A controlled asynchronous processing outcome that can be retried or
reconciled without duplicate tenant, lease, payment, or work-order effects
Examples
For a synthetic work-order update, deliver a valid signed event, a malformed
signature, a duplicate ID, and a downstream timeout. Prove the valid event is
persisted before 202, the malformed request is rejected without parsing, the
duplicate does not produce a second side effect, and the timeout remains queued
for reconciliation. If provider support, raw-body capture, signature secret,
durable store, or queue is unavailable, keep the endpoint disabled and use the
provider-approved polling/reconciliation path instead.
Resources
Next Steps
See appfolio-security-basics.
1---2name: appfolio-webhooks-events3description: Handle AppFolio webhook events for property management notifications. Trigger: "appfolio webhook".4license: MIT5---6# AppFolio Webhooks & Events
7
8## Overview
9
10AppFolio Stack delivers real-time webhook notifications for property management lifecycle events including tenant onboarding, lease execution, rent payments, and maintenance workflows. Use these webhooks to sync AppFolio data with your CRM, accounting system, or custom property management dashboards without polling the API.
11
12## Prerequisites
13
14- Written confirmation in the current AppFolio partner contract that the target
15 portfolio supports the event types, registration process, delivery semantics,
16 and signature scheme. Do not infer webhook support from another integration.
17- A bounded raw-body ingress route, managed webhook secret, durable event store,
18 queue, idempotency table, and owner for downstream accounting/CRM effects.
19- A sandbox endpoint and synthetic events for valid, malformed, duplicate, and
20 delayed-delivery tests before production registration.
21
22## Instructions
23
241. Register events only through the provider-issued process and contract-bound
25 client after verifying the target URL, allowlist, and secret delivery path.
262. Verify bounded raw bytes and the signature before parsing; reject malformed
27 or replayed events without logging tenant, payment, or lease content.
283. Persist the event ID, type, received time, and encrypted/minimized payload
29 transactionally before acknowledging delivery, then process it asynchronously.
304. Enforce durable idempotency and reconcile unknown downstream outcomes before
31 writing CRM, accounting, tenant, lease, or work-order state.
32
33## Webhook Registration
34
35```typescript
36// Use this only if the signed provider contract explicitly supports this API.
37const response = await createVerifiedAppFolioClient().post("/webhooks", {
38 url: "https://yourapp.com/webhooks/appfolio",
39 events: ["tenant.created", "work_order.updated", "payment.received", "lease.signed"],
40 secret: process.env.APPFOLIO_WEBHOOK_SECRET,
41});
42```
43
44## Signature Verification
45
46```typescript
47import crypto from "crypto";
48import { Request, Response, NextFunction } from "express";
49
50function verifyAppFolioSignature(req: Request, res: Response, next: NextFunction) {
51 const signature = req.headers["x-appfolio-signature"] as string;
52 const expected = Buffer.from(crypto
53 .createHmac("sha256", process.env.APPFOLIO_WEBHOOK_SECRET!)
54 .update(req.body)
55 .digest("hex"));
56 const received = signature ? Buffer.from(signature) : Buffer.alloc(0);
57 if (received.length !== expected.length || !crypto.timingSafeEqual(received, expected)) {
58 return res.status(401).json({ error: "Invalid signature" });
59 }
60 next();
61}
62```
63
64## Event Handler
65
66```typescript
67import express from "express";
68const app = express();
69
70app.post("/webhooks/appfolio", express.raw({ type: "application/json" }), verifyAppFolioSignature, (req, res) => {
71 const event = JSON.parse(req.body.toString());
72 // persistIncomingEvent performs a durable idempotency insert and queue write
73 // in one transaction. A failed persist must receive a retryable response.
74 persistIncomingEvent(event).then(() => {
75 res.status(202).json({ received: true });
76 }).catch(() => {
77 res.status(503).json({ error: "Event persistence unavailable" });
78 });
79});
80```
81
82## Event Types
83
84| Event | Payload Fields | Use Case |
85|-------|---------------|----------|
86| `tenant.created` | `tenant_id`, `property_id`, `email` | Sync new tenant to CRM |
87| `work_order.updated` | `work_order_id`, `status`, `assigned_vendor` | Dispatch or escalate maintenance |
88| `payment.received` | `lease_id`, `amount_cents`, `payment_method` | Update accounting ledger |
89| `lease.signed` | `lease_id`, `move_in_date`, `term_months` | Activate unit and send welcome |
90| `lease.expired` | `lease_id`, `unit_id`, `vacate_date` | Trigger renewal or re-listing |
91
92## Retry & Idempotency
93
94```typescript
95async function handleIdempotent(event: { id: string; type: string; data: any }) {
96 if (await durableEventStore.hasSucceeded(event.id)) return;
97 await routeEvent(event);
98 await durableEventStore.markSucceeded(event.id);
99}
100```
101
102## Error Handling
103
104| Issue | Cause | Fix |
105|-------|-------|-----|
106| Signature mismatch | Wrong secret or parsed body | Use `express.raw()` for verification |
107| Duplicate events | AppFolio retry on timeout | Track event IDs for idempotency |
108| Missing `property_id` | Event from archived property | Check property status before processing |
109| Durable store/queue unavailable | Cannot guarantee acknowledged event survives | Return retryable 503; do not acknowledge before persistence |
110
111## Output
112
113- A contract-gated webhook registration decision and a fail-closed raw-body
114 signature verification result
115- A durable receipt for each accepted event before acknowledgement, with
116 minimized/encrypted content and durable idempotency state
117- A controlled asynchronous processing outcome that can be retried or
118 reconciled without duplicate tenant, lease, payment, or work-order effects
119
120## Examples
121
122For a synthetic work-order update, deliver a valid signed event, a malformed
123signature, a duplicate ID, and a downstream timeout. Prove the valid event is
124persisted before `202`, the malformed request is rejected without parsing, the
125duplicate does not produce a second side effect, and the timeout remains queued
126for reconciliation. If provider support, raw-body capture, signature secret,
127durable store, or queue is unavailable, keep the endpoint disabled and use the
128provider-approved polling/reconciliation path instead.
129
130## Resources
131
132- [AppFolio Stack APIs](https://www.appfolio.com/stack/partners/api)
133
134## Next Steps
135
136See `appfolio-security-basics`.