Skip to main content

Custom Hook Flow Implementation

If webhook management must live inside your core product settings, use the hooks directly.

Core hook stack from your SDK

  1. useWebhookAppSession(ticket)
  2. useWebhookEndpoints()
  3. useWebhookEvents()
  4. useWebhookDeliveries(...)
  5. useWebhookAnalytics(...) + useWebhookTimeseries(...)
useWebhookAppSession already exposes full mutation surface:
  • createEndpoint
  • updateEndpoint
  • deleteEndpoint
  • testEndpoint
  • rotateSecret
  • replayDelivery
  • fetchReplayTasks
  • fetchReplayTaskStatus
  • cancelReplayTask

Session bootstrap example

import { useWebhookAppSession } from "@wacht/nextjs";

export function WebhookGate({ ticket }: { ticket?: string }) {
  const { hasSession, sessionLoading, sessionError } = useWebhookAppSession(ticket);

  if (sessionLoading) return <div>Loading webhook access...</div>;
  if (!hasSession) return <div>Access required</div>;
  if (sessionError) return <div>Could not establish webhook session</div>;

  return <div>Webhook session active</div>;
}

Endpoint creation example

const { createEndpoint } = useWebhookAppSession(ticket);

await createEndpoint({
  url: "https://customer.example.com/hooks/wacht",
  description: "Primary endpoint",
  subscribed_events: ["invoice.paid", "invoice.failed"],
  headers: {
    "x-customer-env": "production",
  },
});

Delivery replay example

const { replayDelivery } = useWebhookAppSession(ticket);

await replayDelivery({
  start_date: "2026-03-01T00:00:00Z",
  end_date: "2026-03-01T23:59:59Z",
  status: "failed",
  event_name: "invoice.paid",
});

UX requirements for production

  1. Explicit endpoint URL validation.
  2. Confirmation steps for delete and secret rotation.
  3. Filter controls for deliveries and replay windows.
  4. Clear state for running replay tasks.
  5. Immutable audit trail in support tools.
  1. React Router useWebhookAppSession
  2. React Router useWebhookEndpoints
  3. React Router useWebhookEvents
  4. React Router useWebhookDeliveries
  5. React Router useWebhookAnalytics
  6. Webhooks Backend API Reference

Go-live checklist

  1. Event catalog and naming policy are frozen for current release.
  2. Endpoint test flow is working for pilot customers.
  3. Replay workflow is documented for support.
  4. Signature verification docs are published for customers.
  5. Alerts for endpoint failures and deactivations are active.