Webhooks
Billing Webhooks
POST
/api/webhooks/billingHandles subscription lifecycle events. Signature verified with webhook secret.
payment.succeededExtend subscription period
subscription.updatedHandle plan changes
subscription.cancelledDowngrade to free tier
payment.failedNotify user, start grace period
Huggingface Webhooks
POST
/api/webhooks/huggingfaceMonitors model deployment status and inference endpoint health.
model.deployedEnable model for inference
endpoint.health_checkUpdate availability status
Webhook Security
// Signature verification example
import crypto from 'crypto';
export async function POST(req: Request) {
const body = await req.text();
const signature = req.headers.get('x-webhook-signature');
// Verify HMAC signature
const expectedSig = crypto
.createHmac('sha256', process.env.WEBHOOK_SECRET)
.update(body)
.digest('hex');
if (signature !== expectedSig) {
return new Response('Invalid signature', { status: 401 });
}
const event = JSON.parse(body);
// Handle event...
}