Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.corsair.dev/llms.txt

Use this file to discover all available pages before exploring further.

The Vapi 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

  • client
    • workflowNodeStarted (client.workflowNodeStarted)
  • server
    • assistantRequest (server.assistantRequest)
    • endOfCallReport (server.endOfCallReport)
    • statusUpdate (server.statusUpdate)
    • toolCalls (server.toolCalls)
    • transferDestinationRequest (server.transferDestinationRequest)

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

Client

Workflow Node Started

client.workflowNodeStarted Sent when the active workflow node changes Payload
NameTypeRequiredDescription
messageobjectYes
{
  type: workflow.node.started,
  call: {
    id: string,
    orgId?: string,
    type?: string,
    status?: string,
    endedReason?: string | null,
    assistantId?: string | null,
    phoneNumberId?: string | null,
    startedAt?: string | null,
    endedAt?: string | null,
    cost?: number,
    messages?: {
    }[],
    artifact?: {
    },
    analysis?: {
    }
  },
  node?: {
  },
  timestamp?: string
}
{
  message: {
    type: workflow.node.started,
    call: {
      id: string,
      orgId?: string,
      type?: string,
      status?: string,
      endedReason?: string | null,
      assistantId?: string | null,
      phoneNumberId?: string | null,
      startedAt?: string | null,
      endedAt?: string | null,
      cost?: number,
      messages?: {
      }[],
      artifact?: {
      },
      analysis?: {
      }
    },
    node?: {
    },
    timestamp?: string
  }
}
webhookHooks example
vapi({
    webhookHooks: {
        client: {
            workflowNodeStarted: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Server

Assistant Request

server.assistantRequest Sent to fetch assistant configuration for an incoming call Payload
NameTypeRequiredDescription
messageobjectYes
{
  type: assistant-request,
  call: {
    id: string,
    orgId?: string,
    type?: string,
    status?: string,
    endedReason?: string | null,
    assistantId?: string | null,
    phoneNumberId?: string | null,
    startedAt?: string | null,
    endedAt?: string | null,
    cost?: number,
    messages?: {
    }[],
    artifact?: {
    },
    analysis?: {
    }
  },
  phoneNumber?: {
  },
  customer?: {
  },
  timestamp?: string
}
{
  message: {
    type: assistant-request,
    call: {
      id: string,
      orgId?: string,
      type?: string,
      status?: string,
      endedReason?: string | null,
      assistantId?: string | null,
      phoneNumberId?: string | null,
      startedAt?: string | null,
      endedAt?: string | null,
      cost?: number,
      messages?: {
      }[],
      artifact?: {
      },
      analysis?: {
      }
    },
    phoneNumber?: {
    },
    customer?: {
    },
    timestamp?: string
  }
}
webhookHooks example
vapi({
    webhookHooks: {
        server: {
            assistantRequest: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

End Of Call Report

server.endOfCallReport Sent at the end of a call with transcript, summary, and analysis Payload
NameTypeRequiredDescription
messageobjectYes
{
  type: end-of-call-report,
  call: {
    id: string,
    orgId?: string,
    type?: string,
    status?: string,
    endedReason?: string | null,
    assistantId?: string | null,
    phoneNumberId?: string | null,
    startedAt?: string | null,
    endedAt?: string | null,
    cost?: number,
    messages?: {
    }[],
    artifact?: {
    },
    analysis?: {
    }
  },
  endedReason?: string,
  transcript?: string,
  summary?: string,
  messages?: {
  }[],
  analysis?: {
  },
  artifact?: {
  },
  timestamp?: string
}
{
  message: {
    type: end-of-call-report,
    call: {
      id: string,
      orgId?: string,
      type?: string,
      status?: string,
      endedReason?: string | null,
      assistantId?: string | null,
      phoneNumberId?: string | null,
      startedAt?: string | null,
      endedAt?: string | null,
      cost?: number,
      messages?: {
      }[],
      artifact?: {
      },
      analysis?: {
      }
    },
    endedReason?: string,
    transcript?: string,
    summary?: string,
    messages?: {
    }[],
    analysis?: {
    },
    artifact?: {
    },
    timestamp?: string
  }
}
webhookHooks example
vapi({
    webhookHooks: {
        server: {
            endOfCallReport: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Status Update

server.statusUpdate Sent when the call status changes Payload
NameTypeRequiredDescription
messageobjectYes
{
  type: status-update,
  call: {
    id: string,
    orgId?: string,
    type?: string,
    status?: string,
    endedReason?: string | null,
    assistantId?: string | null,
    phoneNumberId?: string | null,
    startedAt?: string | null,
    endedAt?: string | null,
    cost?: number,
    messages?: {
    }[],
    artifact?: {
    },
    analysis?: {
    }
  },
  status: string,
  timestamp?: string
}
{
  message: {
    type: status-update,
    call: {
      id: string,
      orgId?: string,
      type?: string,
      status?: string,
      endedReason?: string | null,
      assistantId?: string | null,
      phoneNumberId?: string | null,
      startedAt?: string | null,
      endedAt?: string | null,
      cost?: number,
      messages?: {
      }[],
      artifact?: {
      },
      analysis?: {
      }
    },
    status: string,
    timestamp?: string
  }
}
webhookHooks example
vapi({
    webhookHooks: {
        server: {
            statusUpdate: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Tool Calls

server.toolCalls Triggered when the assistant makes tool calls during a call Payload
NameTypeRequiredDescription
messageobjectYes
{
  type: tool-calls,
  call: {
    id: string,
    orgId?: string,
    type?: string,
    status?: string,
    endedReason?: string | null,
    assistantId?: string | null,
    phoneNumberId?: string | null,
    startedAt?: string | null,
    endedAt?: string | null,
    cost?: number,
    messages?: {
    }[],
    artifact?: {
    },
    analysis?: {
    }
  },
  toolCallList: {
    id: string,
    type: function,
    function: {
      name: string,
      arguments: string
    }
  }[],
  toolWithToolCallList?: {
  }[],
  timestamp?: string
}
{
  message: {
    type: tool-calls,
    call: {
      id: string,
      orgId?: string,
      type?: string,
      status?: string,
      endedReason?: string | null,
      assistantId?: string | null,
      phoneNumberId?: string | null,
      startedAt?: string | null,
      endedAt?: string | null,
      cost?: number,
      messages?: {
      }[],
      artifact?: {
      },
      analysis?: {
      }
    },
    toolCallList: {
      id: string,
      type: function,
      function: {
        name: string,
        arguments: string
      }
    }[],
    toolWithToolCallList?: {
    }[],
    timestamp?: string
  }
}
webhookHooks example
vapi({
    webhookHooks: {
        server: {
            toolCalls: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Transfer Destination Request

server.transferDestinationRequest Triggered when processing a transfer destination request Payload
NameTypeRequiredDescription
messageobjectYes
{
  type: transfer-destination-request,
  call: {
    id: string,
    orgId?: string,
    type?: string,
    status?: string,
    endedReason?: string | null,
    assistantId?: string | null,
    phoneNumberId?: string | null,
    startedAt?: string | null,
    endedAt?: string | null,
    cost?: number,
    messages?: {
    }[],
    artifact?: {
    },
    analysis?: {
    }
  },
  timestamp?: string
}
{
  message: {
    type: transfer-destination-request,
    call: {
      id: string,
      orgId?: string,
      type?: string,
      status?: string,
      endedReason?: string | null,
      assistantId?: string | null,
      phoneNumberId?: string | null,
      startedAt?: string | null,
      endedAt?: string | null,
      cost?: number,
      messages?: {
      }[],
      artifact?: {
      },
      analysis?: {
      }
    },
    timestamp?: string
  }
}
webhookHooks example
vapi({
    webhookHooks: {
        server: {
            transferDestinationRequest: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})