Skip to content

TwilioWebhookRequest

Defined in: lib/webhook/twilio-webhook.guard.ts:41

Minimal, platform-agnostic shape of the properties TwilioWebhookGuard reads off the incoming request. Both the Express and the Fastify Nest HTTP adapters satisfy it.

rawBody is only required for JSON webhooks (those Twilio signs with a bodySHA256 query parameter): enable it via NestFactory.create(AppModule, { rawBody: true }), which makes Nest populate it with the exact bytes received.

Note this models the HTTP request the guard inspects, not the Twilio payload itself. Typed payload interfaces are tracked in #85.

// Enable rawBody so JSON webhooks can be validated.
const app = await NestFactory.create(AppModule, { rawBody: true });
// The guard reads the request through this shape on either adapter.
@Post('/webhooks/sms')
@TwilioWebhook()
handleSms(@Req() request: TwilioWebhookRequest) {
return request.body;
}
Property Type Defined in
body? unknown lib/webhook/twilio-webhook.guard.ts:46
headers Record<string, string | string[] | undefined> lib/webhook/twilio-webhook.guard.ts:45
originalUrl? string lib/webhook/twilio-webhook.guard.ts:43
protocol? string lib/webhook/twilio-webhook.guard.ts:42
rawBody? string | Buffer<ArrayBufferLike> lib/webhook/twilio-webhook.guard.ts:47
url? string lib/webhook/twilio-webhook.guard.ts:44