Core Concepts
Webhooks
Receive real-time notifications when events occur in your Interna account.
Overview
Webhooks allow your application to receive real-time HTTP callbacks when events happen in Interna. Instead of polling the API, your server is notified immediately.
Setting Up Webhooks
create-webhook.ts
const webhook = await interna.webhooks.create({
url: "https://yourapp.com/api/webhooks",
events: ["user.created", "user.deleted", "org.updated"],
});Verifying Signatures
Always verify webhook signatures to ensure events are genuinely from Interna.
api/webhooks/route.ts
import { Interna } from "@interna/sdk";
export async function POST(req: Request) {
const body = await req.text();
const signature = req.headers.get("x-interna-signature")!;
const event = Interna.webhooks.verify(body, signature, process.env.INTERNA_WEBHOOK_SECRET!);
switch (event.type) {
case "user.created":
// Handle new user
break;
case "user.deleted":
// Handle user deletion
break;
}
return new Response("OK", { status: 200 });
}Event Types
| Event | Description |
|---|---|
user.created | A new user was created |
user.updated | A user's profile was updated |
user.deleted | A user was deleted |
org.created | A new organization was created |
org.updated | An organization was updated |
membership.created | A user was added to an organization |
membership.removed | A user was removed from an organization |