Skip to main content

useWebhookAppSession

The useWebhookAppSession hook loads webhook app portal session data, exchanges optional tickets, and exposes helper actions for endpoint and replay operations.

Parameters

ticket
string | null
Optional session ticket to exchange before loading webhook app session data.

Return Value

hasSession
boolean
Whether the current request has an active session.
sessionLoading
boolean
Whether ticket exchange or session fetch is in progress.
sessionError
Error | null
Session or ticket error.
sessionId
string | null
Webhook app session ID.
webhookApp
WebhookApp | null
Webhook app metadata.
ticketExchanged
boolean
Whether ticket exchange succeeded.
ticketLoading
boolean
Whether ticket exchange is in progress.
refetch
() => Promise<void>
Revalidate session data.
createEndpoint
(options) => Promise<EndpointWithSubscriptions>
Create a webhook endpoint.
updateEndpoint
(endpointId, options) => Promise<EndpointWithSubscriptions>
Update an endpoint.
deleteEndpoint
(endpointId) => Promise<void>
Delete an endpoint.
testEndpoint
(endpointId, options) => Promise<void>
Trigger endpoint test delivery.
rotateSecret
() => Promise<RotateSecretResponse>
Rotate app signing secret.
replayDelivery
(options) => Promise<ReplayResponse>
Replay a delivery.
fetchReplayTaskStatus
(options) => Promise<ReplayTaskStatus>
Fetch replay task status.
fetchReplayTasks
(options?) => Promise<ReplayTaskList>
List replay tasks.
cancelReplayTask
(options) => Promise<void>
Cancel replay task.
fetchDeliveryDetail
(deliveryId: string) => Promise<WebhookDeliveryDetail>
Fetch delivery detail.

Example

import { useWebhookAppSession } from "@wacht/react-router";

function WebhookPortal({ ticket }: { ticket?: string }) {
  const { sessionLoading, webhookApp, createEndpoint } = useWebhookAppSession(ticket);

  if (sessionLoading) return <div>Loading...</div>;

  return (
    <button
      onClick={() =>
        void createEndpoint({
          url: "https://example.com/webhooks",
          subscribed_events: ["user.created"],
        })
      }
    >
      Create endpoint for {webhookApp?.name}
    </button>
  );
}