Loading...
Loading...
Use when setting up Commet webhook endpoints, verifying signatures, handling billing events (subscription.created, subscription.activated, subscription.canceled, subscription.updated, payment.received, payment.failed, invoice.created), or building event-driven billing workflows.
npx skill4agent add commet-labs/commet-skills commet-webhooks// app/api/webhooks/commet/route.ts
import { Webhooks } from "@commet/next";
export const POST = Webhooks({
webhookSecret: process.env.COMMET_WEBHOOK_SECRET!,
onSubscriptionActivated: async (payload) => {
await sendWelcomeEmail(payload.data.externalId);
},
onSubscriptionCanceled: async (payload) => {
await sendCancellationEmail(payload.data.externalId);
},
});npm install @commet/nextimport { Commet } from "@commet/node";
const commet = new Commet({ apiKey: process.env.COMMET_API_KEY! });
// Check subscription status -- do this, not webhook state sync
const { data: sub } = await commet.subscriptions.get("user_123");
if (sub?.status === "active" || sub?.status === "trialing") {
// grant access
}
// Check feature access
const { data } = await commet.features.check({
code: "advanced_analytics",
customerId: "user_123",
});| Event | When Fired | Common Use |
|---|---|---|
| New subscription created, before payment | Logging, analytics |
| Payment successful, subscription active | Welcome email, provision resources |
| Subscription canceled | Cancellation email, schedule cleanup |
| Subscription details changed | Sync external systems |
| Plan upgrade/downgrade | Notify of plan change, adjust resources |
| Recurring payment processed | Receipt email, update accounting |
| Recurring charge failed | Alert customer, dunning flow |
| New invoice generated | Custom invoice handling |
{
"event": "subscription.activated",
"timestamp": "2026-03-25T14:30:00.000Z",
"organizationId": "org_abc123",
"data": { }
}| Header | Description |
|---|---|
| HMAC-SHA256 hex signature of the raw body |
| The event type |
| ISO 8601 datetime when the event was emitted |