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 Resend 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

  • domains
    • created (domains.created)
    • updated (domains.updated)
  • emails
    • bounced (emails.bounced)
    • clicked (emails.clicked)
    • complained (emails.complained)
    • delivered (emails.delivered)
    • failed (emails.failed)
    • opened (emails.opened)
    • received (emails.received)
    • sent (emails.sent)

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

Domains

Created

domains.created A new sending domain was created Payload
NameTypeRequiredDescription
typedomain.createdYes
created_atstringYes
dataobjectYes
{
  domain_id: string,
  name: string,
  status: not_started | validation | scheduled | ready | error,
  created_at: string
}
{
  type: domain.created,
  created_at: string,
  data: {
    domain_id: string,
    name: string,
    status: not_started | validation | scheduled | ready | error,
    created_at: string
  }
}
webhookHooks example
resend({
    webhookHooks: {
        domains: {
            created: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Updated

domains.updated A sending domain was updated Payload
NameTypeRequiredDescription
typedomain.updatedYes
created_atstringYes
dataobjectYes
{
  domain_id: string,
  name: string,
  status: not_started | validation | scheduled | ready | error,
  created_at: string
}
{
  type: domain.updated,
  created_at: string,
  data: {
    domain_id: string,
    name: string,
    status: not_started | validation | scheduled | ready | error,
    created_at: string
  }
}
webhookHooks example
resend({
    webhookHooks: {
        domains: {
            updated: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Emails

Bounced

emails.bounced An email bounced and was not delivered Payload
NameTypeRequiredDescription
typeemail.bouncedYes
created_atstringYes
dataobjectYes
{
  email_id: string,
  from: string,
  to: string[],
  subject?: string,
  created_at: string,
  bounce_type?: string
}
{
  type: email.bounced,
  created_at: string,
  data: {
    email_id: string,
    from: string,
    to: string[],
    subject?: string,
    created_at: string,
    bounce_type?: string
  }
}
webhookHooks example
resend({
    webhookHooks: {
        emails: {
            bounced: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Clicked

emails.clicked A recipient clicked a link in an email Payload
NameTypeRequiredDescription
typeemail.clickedYes
created_atstringYes
dataobjectYes
{
  email_id: string,
  from: string,
  to: string[],
  subject?: string,
  created_at: string,
  link?: string
}
{
  type: email.clicked,
  created_at: string,
  data: {
    email_id: string,
    from: string,
    to: string[],
    subject?: string,
    created_at: string,
    link?: string
  }
}
webhookHooks example
resend({
    webhookHooks: {
        emails: {
            clicked: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Complained

emails.complained A recipient marked an email as spam Payload
NameTypeRequiredDescription
typeemail.complainedYes
created_atstringYes
dataobjectYes
{
  email_id: string,
  from: string,
  to: string[],
  subject?: string,
  created_at: string
}
{
  type: email.complained,
  created_at: string,
  data: {
    email_id: string,
    from: string,
    to: string[],
    subject?: string,
    created_at: string
  }
}
webhookHooks example
resend({
    webhookHooks: {
        emails: {
            complained: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Delivered

emails.delivered An email was delivered to the recipient Payload
NameTypeRequiredDescription
typeemail.deliveredYes
created_atstringYes
dataobjectYes
{
  email_id: string,
  from: string,
  to: string[],
  subject?: string,
  created_at: string
}
{
  type: email.delivered,
  created_at: string,
  data: {
    email_id: string,
    from: string,
    to: string[],
    subject?: string,
    created_at: string
  }
}
webhookHooks example
resend({
    webhookHooks: {
        emails: {
            delivered: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Failed

emails.failed An email failed to send Payload
NameTypeRequiredDescription
typeemail.failedYes
created_atstringYes
dataobjectYes
{
  email_id: string,
  from: string,
  to: string[],
  subject?: string,
  created_at: string,
  error?: string
}
{
  type: email.failed,
  created_at: string,
  data: {
    email_id: string,
    from: string,
    to: string[],
    subject?: string,
    created_at: string,
    error?: string
  }
}
webhookHooks example
resend({
    webhookHooks: {
        emails: {
            failed: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Opened

emails.opened A recipient opened an email Payload
NameTypeRequiredDescription
typeemail.openedYes
created_atstringYes
dataobjectYes
{
  email_id: string,
  from: string,
  to: string[],
  subject?: string,
  created_at: string
}
{
  type: email.opened,
  created_at: string,
  data: {
    email_id: string,
    from: string,
    to: string[],
    subject?: string,
    created_at: string
  }
}
webhookHooks example
resend({
    webhookHooks: {
        emails: {
            opened: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Received

emails.received An inbound email was received Payload
NameTypeRequiredDescription
typeemail.receivedYes
created_atstringYes
dataobjectYes
{
  email_id: string,
  from: string,
  to: string[],
  subject?: string,
  created_at: string
}
{
  type: email.received,
  created_at: string,
  data: {
    email_id: string,
    from: string,
    to: string[],
    subject?: string,
    created_at: string
  }
}
webhookHooks example
resend({
    webhookHooks: {
        emails: {
            received: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Sent

emails.sent An email was accepted and sent Payload
NameTypeRequiredDescription
typeemail.sentYes
created_atstringYes
dataobjectYes
{
  email_id: string,
  from: string,
  to: string[],
  subject?: string,
  created_at: string
}
{
  type: email.sent,
  created_at: string,
  data: {
    email_id: string,
    from: string,
    to: string[],
    subject?: string,
    created_at: string
  }
}
webhookHooks example
resend({
    webhookHooks: {
        emails: {
            sent: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})