Pull vs push
Pull = le site interroge périodiquement le CRM. Push = le CRM notifie le site dès qu'un changement a lieu. Le webhook est la forme classique du push.
Webhooks entrants — depuis le CRM vers Ts-Immo
Ts-Immo expose deux endpoints qui reçoivent les webhooks des CRM event-driven : Sweepbright et Whise.
| CRM | Endpoint | Signature | Algo |
|---|---|---|---|
| Sweepbright | POST /v1/gateway/webhooks/sweepbright/{gatewayId} | X-Hook-Signature | HMAC-SHA1 |
| Whise | POST /v1/gateway/webhooks/whise/{gatewayId} | X-Whise-Signature | HMAC-SHA256 |
CRM qui supportent les webhooks
- Sweepbright — natif, événements granulaires (HMAC-SHA1)
- Whise — natif (HMAC-SHA256)
- Apimo et autres CRM — synchronisation périodique multi-quotidienne
Webhook sortant — Ts-Immo vers votre site
Le connecteur de sortie `WEBHOOK` de Ts-Immo permet de pousser le portefeuille normalisé vers un endpoint cible (votre Next.js par exemple) à chaque synchronisation. Configuration côté passerelle : `{ "url": "https://monsite.com/api/sync-webhook" }`. Le body est le bien normalisé Ts-Immo.
Cas d'usage Next.js — revalidation ISR à la demande
Sur un site Next.js, vous pouvez exposer une route /api/sync-webhook qui reçoit le webhook sortant Ts-Immo et appelle `revalidateTag()` ou `revalidatePath()` pour rafraîchir uniquement les pages concernées.
import { revalidateTag } from 'next/cache'
import { NextRequest, NextResponse } from 'next/server'
export async function POST(req: NextRequest) {
const secret = req.headers.get('x-ts-immo-secret')
if (secret !== process.env.TS_IMMO_WEBHOOK_SECRET) {
return NextResponse.json({ error: 'unauthorized' }, { status: 401 })
}
const property = await req.json() // bien normalisé Ts-Immo (snake_case)
revalidateTag('listings')
revalidateTag(`listing:${property.id}`)
return NextResponse.json({ revalidated: true })
}