Webhooks hooks
React hooks for webhooks — webhook endpoints (inbound HTTP targets) and webhook subscriptions (event → endpoint mappings).
Usage
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.
useCreateWebhookEndpoint(options?: MutationOpts<WebhookEndpoint, CreateWebhookEndpointParams>)Types: WebhookEndpoint · CreateWebhookEndpointParams
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.
useCreateWebhookSubscription(options?: MutationOpts<WebhookSubscription, CreateWebhookSubscriptionParams>)Types: WebhookSubscription · CreateWebhookSubscriptionParams
const create = useCreateWebhookSubscription();
create.mutate({ endpointId: "wbhend_abc", eventType: "agent.updated" });useDeleteWebhookEndpoint mutation
Delete a webhook endpoint. Auto-invalidates webhook endpoint queries on success.
useDeleteWebhookEndpoint(options?: MutationOpts<SuccessResponse, string>)Types: SuccessResponse
const del = useDeleteWebhookEndpoint();
del.mutate("wbhend_abc");useDeleteWebhookSubscription mutation
Delete a webhook subscription. Auto-invalidates webhook subscription queries on success.
useDeleteWebhookSubscription(options?: MutationOpts<SuccessResponse, string>)Types: SuccessResponse
const del = useDeleteWebhookSubscription();
del.mutate("wbhsub_abc");useListWebhookEndpoints query
Fetch paginated list of webhook endpoints.
useListWebhookEndpoints(params?: Omit<ListWebhookEndpointsParams, | > & { filter?: WebhookEndpointFilter; orderBy?: WebhookEndpointOrderBy[]; } & WebhookEndpointShorthands, options?: QueryOpts<Page<WebhookEndpoint>>)Types: ListWebhookEndpointsParams · WebhookEndpointFilter · WebhookEndpointOrderBy · WebhookEndpointShorthands · Page · WebhookEndpoint
const { data } = useListWebhookEndpoints({ workspace_id: "wsp_abc123" });useListWebhookSubscriptions query
Fetch paginated list of webhook subscriptions.
useListWebhookSubscriptions(params?: Omit<ListWebhookSubscriptionsParams, | > & { filter?: WebhookSubscriptionFilter; orderBy?: WebhookSubscriptionOrderBy[]; } & WebhookSubscriptionShorthands, options?: QueryOpts<Page<WebhookSubscription>>)Types: ListWebhookSubscriptionsParams · WebhookSubscriptionFilter · WebhookSubscriptionOrderBy · WebhookSubscriptionShorthands · Page · WebhookSubscription
const { data } = useListWebhookSubscriptions({ workspace_id: "wsp_abc123" });usePurgeWebhookEndpoint composite
Permanently delete a soft-deleted webhook endpoint. Caller must have admin tier.
usePurgeWebhookEndpoint(options?: MutationOpts<SuccessResponse, PurgeWebhookEndpointParams>)Types: SuccessResponse · PurgeWebhookEndpointParams
useRestoreWebhookEndpoint composite
Restore a soft-deleted webhook endpoint.
useRestoreWebhookEndpoint(options?: MutationOpts<WebhookEndpoint, string>)Types: WebhookEndpoint
useRestoreWebhookSubscription composite
Restore a soft-deleted webhook subscription.
useRestoreWebhookSubscription(options?: MutationOpts<WebhookSubscription, string>)Types: WebhookSubscription
useRetrieveWebhookEndpoint query
Fetch a single webhook endpoint by ID.
useRetrieveWebhookEndpoint(id: string, options?: QueryOpts<WebhookEndpoint>)Types: WebhookEndpoint
const { data: endpoint } = useRetrieveWebhookEndpoint("wbhend_abc");useRetrieveWebhookSubscription query
Fetch a single webhook subscription by ID.
useRetrieveWebhookSubscription(id: string, options?: QueryOpts<WebhookSubscription>)Types: WebhookSubscription
const { data: sub } = useRetrieveWebhookSubscription("wbhsub_abc");useUpdateWebhookEndpoint mutation
Update an existing webhook endpoint. Optimistically updates the detail cache and invalidates on settle.
useUpdateWebhookEndpoint(options?: MutationOpts<WebhookEndpoint, UpdateWebhookEndpointParams>)Types: WebhookEndpoint · UpdateWebhookEndpointParams
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.
useUpdateWebhookSubscription(options?: MutationOpts<WebhookSubscription, UpdateWebhookSubscriptionParams>)Types: WebhookSubscription · UpdateWebhookSubscriptionParams
const update = useUpdateWebhookSubscription();
update.mutate({ id: "wbhsub_abc", eventType: "run.completed" });