Skip to main content
The Twilio plugin handles incoming webhooks. Point your provider’s subscription URL at your Corsair HTTP handler (see Overview for setup context and the exact URL shape).
New to Corsair? See webhooks and hooks.

Webhook map

  • call
    • statusUpdate (call.statusUpdate)
  • message
    • received (message.received)
    • statusUpdate (message.statusUpdate)

HTTP handler setup

app/api/webhook/route.ts
import { processWebhook } from "corsair";
import { corsair } from "@/server/corsair";

export async function POST(request: Request) {
    const headers = Object.fromEntries(request.headers);
    const body = await request.json();
    const result = await processWebhook(corsair, headers, body);
    return result.response;
}

Events

Call

Status Update

call.statusUpdate A call status changed (ringing, in-progress, completed, etc.) Payload
NameTypeRequiredDescription
CallSidstringYes
AccountSidstringYes
FromstringYes
TostringYes
CallStatusqueued | ringing | in-progress | completed | busy | no-answer | canceled | failedYes
DirectionstringNo
DurationstringNo
CallDurationstringNo
ApiVersionstringNo
TimestampstringNo
SequenceNumberstringNo
{
  CallSid: string,
  AccountSid: string,
  From: string,
  To: string,
  CallStatus: queued | ringing | in-progress | completed | busy | no-answer | canceled | failed,
  Direction?: string,
  Duration?: string,
  CallDuration?: string,
  ApiVersion?: string,
  Timestamp?: string,
  SequenceNumber?: string
}
webhookHooks example
twilio({
    webhookHooks: {
        call: {
            statusUpdate: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Message

Received

message.received An incoming SMS/MMS message was received Payload
NameTypeRequiredDescription
MessageSidstringYes
SmsSidstringNo
AccountSidstringYes
MessagingServiceSidstringNo
FromstringYes
TostringYes
BodystringYes
NumMediastringYes
NumSegmentsstringNo
SmsStatusstringNo
ApiVersionstringNo
FromCitystringNo
FromStatestringNo
FromCountrystringNo
FromZipstringNo
ToCitystringNo
ToStatestringNo
ToCountrystringNo
ToZipstringNo
{
  MessageSid: string,
  SmsSid?: string,
  AccountSid: string,
  MessagingServiceSid?: string,
  From: string,
  To: string,
  Body: string,
  NumMedia: string,
  NumSegments?: string,
  SmsStatus?: string,
  ApiVersion?: string,
  FromCity?: string,
  FromState?: string,
  FromCountry?: string,
  FromZip?: string,
  ToCity?: string,
  ToState?: string,
  ToCountry?: string,
  ToZip?: string
}
webhookHooks example
twilio({
    webhookHooks: {
        message: {
            received: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Status Update

message.statusUpdate A message delivery status changed (sent, delivered, failed, etc.) Payload
NameTypeRequiredDescription
MessageSidstringYes
AccountSidstringYes
FromstringYes
TostringYes
MessageStatusaccepted | queued | sending | sent | delivered | undelivered | failed | receiving | received | readYes
ErrorCodestringNo
ErrorMessagestringNo
ApiVersionstringNo
{
  MessageSid: string,
  AccountSid: string,
  From: string,
  To: string,
  MessageStatus: accepted | queued | sending | sent | delivered | undelivered | failed | receiving | received | read,
  ErrorCode?: string,
  ErrorMessage?: string,
  ApiVersion?: string
}
webhookHooks example
twilio({
    webhookHooks: {
        message: {
            statusUpdate: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})