Webhooks
Verify signed DunSocial events in your app.
The SDK only verifies deliveries. Creating endpoints still needs a session — see the API webhooks guide.
import { DunSocial } from '@thisux/dunsocial-sdk';
export async function POST(request: Request) {
const rawBody = await request.text();
const event = await DunSocial.webhooks.constructEvent(
rawBody,
{
signature: request.headers.get('X-DunSocial-Signature') ?? '',
timestamp: request.headers.get('X-DunSocial-Timestamp') ?? ''
},
process.env.DUN_WEBHOOK_SECRET!
);
if (event.type === 'post.published') {
// event.data
}
}The signature is HMAC-SHA256 of {timestamp}.{rawBody}, sent as X-DunSocial-Signature: v1=…. Pass the raw body. The default replay window is 300 seconds.
Events: post.scheduled, post.rescheduled, post.cancelled, post.published, post.publish_failed, social_account.reconnect_required.