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

EventDescription
user.createdA new user was created
user.updatedA user's profile was updated
user.deletedA user was deleted
org.createdA new organization was created
org.updatedAn organization was updated
membership.createdA user was added to an organization
membership.removedA user was removed from an organization