Webhook map
interactionsapplicationCommand(interactions.applicationCommand)messageComponent(interactions.messageComponent)modalSubmit(interactions.modalSubmit)ping(interactions.ping)
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);
// With multiTenancy, give each tenant its own URL (/api/webhook?tenantId=acme):
// the query says whose account, secret and hooks handle the delivery.
const query = Object.fromEntries(new URL(request.url).searchParams);
// The raw text, not request.json(): signatures are checked over the exact bytes sent.
const body = await request.text();
const result = await processWebhook(corsair, headers, body, query);
if (!result.plugin) {
return Response.json({ success: false }, { status: 404 });
}
// A refusal (bad signature) carries no status and answers 400; a handler
// that threw comes back with 500, so the sender retries it.
const status =
result.response?.success === false ? (result.response.statusCode ?? 400) : 200;
return Response.json(result.response ?? { success: true }, {
status,
headers: result.responseHeaders,
});
}
Events
Interactions
Application Command
interactions.applicationCommand
A user invoked a slash command or context-menu action
Payload
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Yes | — |
application_id | string | Yes | — |
token | string | Yes | — |
version | 1 | Yes | — |
guild_id | string | No | — |
channel_id | string | No | — |
member | object | No | — |
user | object | No | — |
locale | string | No | — |
guild_locale | string | No | — |
app_permissions | string | No | — |
type | 2 | Yes | — |
data | object | Yes | — |
member full type
member full type
{
user?: {
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
},
nick: string | null,
roles: string[],
joined_at: string,
permissions: string,
deaf: boolean,
mute: boolean
}
user full type
user full type
{
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
}
data full type
data full type
{
id: string,
name: string,
type: number,
options?: {
name: string,
type: number,
value?: string | number | boolean,
focused?: boolean,
options?: {
name: string,
type: number,
value?: string | number | boolean,
focused?: boolean,
options?: (recursive)
}[]
}[],
guild_id?: string,
target_id?: string
}
Response data full type
Response data full type
{
id: string,
application_id: string,
token: string,
version: 1,
guild_id?: string,
channel_id?: string,
member?: {
user?: {
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
},
nick: string | null,
roles: string[],
joined_at: string,
permissions: string,
deaf: boolean,
mute: boolean
},
user?: {
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
},
locale?: string,
guild_locale?: string,
app_permissions?: string,
type: 2,
data: {
id: string,
name: string,
type: number,
options?: {
name: string,
type: number,
value?: string | number | boolean,
focused?: boolean,
options?: {
name: string,
type: number,
value?: string | number | boolean,
focused?: boolean,
options?: (recursive)
}[]
}[],
guild_id?: string,
target_id?: string
}
}
webhookHooks example
discord({
webhookHooks: {
interactions: {
applicationCommand: {
before(ctx, args) {
return { ctx, args };
},
after(ctx, response) {
},
},
},
},
})
Message Component
interactions.messageComponent
A user clicked a button or selected a menu option
Payload
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Yes | — |
application_id | string | Yes | — |
token | string | Yes | — |
version | 1 | Yes | — |
guild_id | string | No | — |
channel_id | string | No | — |
member | object | No | — |
user | object | No | — |
locale | string | No | — |
guild_locale | string | No | — |
app_permissions | string | No | — |
type | 3 | Yes | — |
data | object | Yes | — |
message | object | Yes | — |
member full type
member full type
{
user?: {
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
},
nick: string | null,
roles: string[],
joined_at: string,
permissions: string,
deaf: boolean,
mute: boolean
}
user full type
user full type
{
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
}
data full type
data full type
{
custom_id: string,
component_type: number,
values?: string[]
}
message full type
message full type
{
id: string,
channel_id: string,
content: string,
author: {
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
},
timestamp: string,
edited_timestamp: string | null,
tts: boolean,
mention_everyone: boolean,
mentions: {
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
}[],
attachments: any[],
embeds: {
title?: string,
description?: string,
url?: string,
color?: number,
fields?: {
name: string,
value: string,
inline?: boolean
}[],
footer?: {
text: string,
icon_url?: string
},
image?: {
url: string
},
thumbnail?: {
url: string
},
author?: {
name: string,
url?: string,
icon_url?: string
},
timestamp?: string
}[],
pinned: boolean,
type: number
}
Response data full type
Response data full type
{
id: string,
application_id: string,
token: string,
version: 1,
guild_id?: string,
channel_id?: string,
member?: {
user?: {
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
},
nick: string | null,
roles: string[],
joined_at: string,
permissions: string,
deaf: boolean,
mute: boolean
},
user?: {
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
},
locale?: string,
guild_locale?: string,
app_permissions?: string,
type: 3,
data: {
custom_id: string,
component_type: number,
values?: string[]
},
message: {
id: string,
channel_id: string,
content: string,
author: {
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
},
timestamp: string,
edited_timestamp: string | null,
tts: boolean,
mention_everyone: boolean,
mentions: {
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
}[],
attachments: any[],
embeds: {
title?: string,
description?: string,
url?: string,
color?: number,
fields?: {
name: string,
value: string,
inline?: boolean
}[],
footer?: {
text: string,
icon_url?: string
},
image?: {
url: string
},
thumbnail?: {
url: string
},
author?: {
name: string,
url?: string,
icon_url?: string
},
timestamp?: string
}[],
pinned: boolean,
type: number
}
}
webhookHooks example
discord({
webhookHooks: {
interactions: {
messageComponent: {
before(ctx, args) {
return { ctx, args };
},
after(ctx, response) {
},
},
},
},
})
Modal Submit
interactions.modalSubmit
A user submitted a modal dialog
Payload
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Yes | — |
application_id | string | Yes | — |
token | string | Yes | — |
version | 1 | Yes | — |
guild_id | string | No | — |
channel_id | string | No | — |
member | object | No | — |
user | object | No | — |
locale | string | No | — |
guild_locale | string | No | — |
app_permissions | string | No | — |
type | 5 | Yes | — |
data | object | Yes | — |
member full type
member full type
{
user?: {
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
},
nick: string | null,
roles: string[],
joined_at: string,
permissions: string,
deaf: boolean,
mute: boolean
}
user full type
user full type
{
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
}
data full type
data full type
{
custom_id: string,
components: {
type: number,
components: {
type: number,
custom_id: string,
value: string
}[]
}[]
}
Response data full type
Response data full type
{
id: string,
application_id: string,
token: string,
version: 1,
guild_id?: string,
channel_id?: string,
member?: {
user?: {
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
},
nick: string | null,
roles: string[],
joined_at: string,
permissions: string,
deaf: boolean,
mute: boolean
},
user?: {
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
},
locale?: string,
guild_locale?: string,
app_permissions?: string,
type: 5,
data: {
custom_id: string,
components: {
type: number,
components: {
type: number,
custom_id: string,
value: string
}[]
}[]
}
}
webhookHooks example
discord({
webhookHooks: {
interactions: {
modalSubmit: {
before(ctx, args) {
return { ctx, args };
},
after(ctx, response) {
},
},
},
},
})
Ping
interactions.ping
Discord sends a PING to verify the endpoint is live
Payload
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Yes | — |
application_id | string | Yes | — |
token | string | Yes | — |
version | 1 | Yes | — |
guild_id | string | No | — |
channel_id | string | No | — |
member | object | No | — |
user | object | No | — |
locale | string | No | — |
guild_locale | string | No | — |
app_permissions | string | No | — |
type | 1 | Yes | — |
member full type
member full type
{
user?: {
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
},
nick: string | null,
roles: string[],
joined_at: string,
permissions: string,
deaf: boolean,
mute: boolean
}
user full type
user full type
{
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
}
Response data full type
Response data full type
{
id: string,
application_id: string,
token: string,
version: 1,
guild_id?: string,
channel_id?: string,
member?: {
user?: {
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
},
nick: string | null,
roles: string[],
joined_at: string,
permissions: string,
deaf: boolean,
mute: boolean
},
user?: {
id: string,
username: string,
discriminator: string,
global_name: string | null,
avatar: string | null,
bot?: boolean,
system?: boolean,
email?: string | null,
verified?: boolean,
locale?: string,
premium_type?: number,
public_flags?: number,
flags?: number
},
locale?: string,
guild_locale?: string,
app_permissions?: string,
type: 1
}
webhookHooks example
discord({
webhookHooks: {
interactions: {
ping: {
before(ctx, args) {
return { ctx, args };
},
after(ctx, response) {
},
},
},
},
})