Webhooks hooks

React hooks for webhooks — webhook endpoints (inbound HTTP targets) and webhook subscriptions (event → endpoint mappings).

Usage

TSX
import Aeontel from "@aeontel/sdk";
import { AeontelProvider, useListWebhookEndpoints } from "@aeontel/react";

const client = new Aeontel(import.meta.env.VITE_AEONTEL_API_KEY);

function App() {
  return (
    <AeontelProvider client={client}>
      <WebhooksList workspaceId="wsp_abc123" />
    </AeontelProvider>
  );
}

function WebhooksList({ workspaceId }: { workspaceId: string }) {
  const { data, isLoading } = useListWebhookEndpoints({
    workspace_id: workspaceId,
  });
  if (isLoading) return <p>Loading…</p>;
  return (
    <ul>
      {data?.data.map((w) => (
        <li key={w.id}>{w.url}</li>
      ))}
    </ul>
  );
}

Hooks

useCreateWebhookEndpoint mutation

Create a new webhook endpoint. Auto-invalidates webhook endpoint queries on success.

TypeScript
useCreateWebhookEndpoint(options?: MutationOpts<WebhookEndpoint, CreateWebhookEndpointParams>)

Types: WebhookEndpoint · CreateWebhookEndpointParams

TypeScript
const create = useCreateWebhookEndpoint();
create.mutate({ workspaceId: "wsp_abc123", url: "https://example.com/hook" });

useCreateWebhookSubscription mutation

Create a new webhook subscription. Auto-invalidates webhook subscription queries on success.

TypeScript
useCreateWebhookSubscription(options?: MutationOpts<WebhookSubscription, CreateWebhookSubscriptionParams>)

Types: WebhookSubscription · CreateWebhookSubscriptionParams

TypeScript
const create = useCreateWebhookSubscription();
create.mutate({ endpointId: "wbhend_abc", eventType: "agent.updated" });

useDeleteWebhookEndpoint mutation

Delete a webhook endpoint. Auto-invalidates webhook endpoint queries on success.

TypeScript
useDeleteWebhookEndpoint(options?: MutationOpts<SuccessResponse, string>)

Types: SuccessResponse

TypeScript
const del = useDeleteWebhookEndpoint();
del.mutate("wbhend_abc");

useDeleteWebhookSubscription mutation

Delete a webhook subscription. Auto-invalidates webhook subscription queries on success.

TypeScript
useDeleteWebhookSubscription(options?: MutationOpts<SuccessResponse, string>)

Types: SuccessResponse

TypeScript
const del = useDeleteWebhookSubscription();
del.mutate("wbhsub_abc");

useListWebhookEndpoints query

Fetch paginated list of webhook endpoints.

TypeScript
useListWebhookEndpoints(params?: Omit<ListWebhookEndpointsParams, | > & { filter?: WebhookEndpointFilter; orderBy?: WebhookEndpointOrderBy[]; } & WebhookEndpointShorthands, options?: QueryOpts<Page<WebhookEndpoint>>)

Types: ListWebhookEndpointsParams · WebhookEndpointFilter · WebhookEndpointOrderBy · WebhookEndpointShorthands · Page · WebhookEndpoint

TypeScript
const { data } = useListWebhookEndpoints({ workspace_id: "wsp_abc123" });

useListWebhookSubscriptions query

Fetch paginated list of webhook subscriptions.

TypeScript
useListWebhookSubscriptions(params?: Omit<ListWebhookSubscriptionsParams, | > & { filter?: WebhookSubscriptionFilter; orderBy?: WebhookSubscriptionOrderBy[]; } & WebhookSubscriptionShorthands, options?: QueryOpts<Page<WebhookSubscription>>)

Types: ListWebhookSubscriptionsParams · WebhookSubscriptionFilter · WebhookSubscriptionOrderBy · WebhookSubscriptionShorthands · Page · WebhookSubscription

TypeScript
const { data } = useListWebhookSubscriptions({ workspace_id: "wsp_abc123" });

usePurgeWebhookEndpoint composite

Permanently delete a soft-deleted webhook endpoint. Caller must have admin tier.

TypeScript
usePurgeWebhookEndpoint(options?: MutationOpts<SuccessResponse, PurgeWebhookEndpointParams>)

Types: SuccessResponse · PurgeWebhookEndpointParams

useRestoreWebhookEndpoint composite

Restore a soft-deleted webhook endpoint.

TypeScript
useRestoreWebhookEndpoint(options?: MutationOpts<WebhookEndpoint, string>)

Types: WebhookEndpoint

useRestoreWebhookSubscription composite

Restore a soft-deleted webhook subscription.

TypeScript
useRestoreWebhookSubscription(options?: MutationOpts<WebhookSubscription, string>)

Types: WebhookSubscription

useRetrieveWebhookEndpoint query

Fetch a single webhook endpoint by ID.

TypeScript
useRetrieveWebhookEndpoint(id: string, options?: QueryOpts<WebhookEndpoint>)

Types: WebhookEndpoint

TypeScript
const { data: endpoint } = useRetrieveWebhookEndpoint("wbhend_abc");

useRetrieveWebhookSubscription query

Fetch a single webhook subscription by ID.

TypeScript
useRetrieveWebhookSubscription(id: string, options?: QueryOpts<WebhookSubscription>)

Types: WebhookSubscription

TypeScript
const { data: sub } = useRetrieveWebhookSubscription("wbhsub_abc");

useUpdateWebhookEndpoint mutation

Update an existing webhook endpoint. Optimistically updates the detail cache and invalidates on settle.

TypeScript
useUpdateWebhookEndpoint(options?: MutationOpts<WebhookEndpoint, UpdateWebhookEndpointParams>)

Types: WebhookEndpoint · UpdateWebhookEndpointParams

TypeScript
const update = useUpdateWebhookEndpoint();
update.mutate({ id: "wbhend_abc", url: "https://new.example.com/hook" });

useUpdateWebhookSubscription mutation

Update an existing webhook subscription. Optimistically updates the detail cache and invalidates on settle.

TypeScript
useUpdateWebhookSubscription(options?: MutationOpts<WebhookSubscription, UpdateWebhookSubscriptionParams>)

Types: WebhookSubscription · UpdateWebhookSubscriptionParams

TypeScript
const update = useUpdateWebhookSubscription();
update.mutate({ id: "wbhsub_abc", eventType: "run.completed" });