Webhooks
Manage event subscriptions and inspect delivery attempts.
Webhook hooks manage subscriptions scoped to agents, phone numbers, or batches, and query delivery logs.
List subscriptions and event types
useGetWebhooks(params?) returns a paginated subscription list. Its optional filters are page, size, and scope (agent, phone_number, or batch).
useGetWebhookEventTypes(scope?) lists available event types. Pass a scope to narrow the result; omit it to request all available types.
import {
useGetWebhookEventTypes,
useGetWebhooks,
} from "@scalereal/sr-voice-engine-react-sdk/hooks";
export function AgentWebhookOptions() {
const eventTypes = useGetWebhookEventTypes("agent");
const webhooks = useGetWebhooks({ scope: "agent" });
if (eventTypes.isPending || webhooks.isPending)
return <p>Loading webhook settings…</p>;
if (eventTypes.isError || webhooks.isError)
return <p>Could not load webhook settings.</p>;
return (
<p>
{eventTypes.data.length} event types · {webhooks.data.total} subscriptions
</p>
);
}Read subscription details and delivery logs
useWebhookDetails(webhookId, enabled?)fetches one subscription and stays idle for an empty ID or when disabled.useGetWebhookLogs(params?)returns paginated delivery attempts. Filters arepage,size,webhook_id, andcall_session_id.
Each WebhookDeliveryLog records the event, endpoint, attempt number, success flag, HTTP status, response body, transport error, and creation time.
Create a subscription
useCreateWebhook accepts a CreateWebhookRequest: scope, url, and events are required. Provide the matching agent_id, phone_number_id, or batch_id for the selected scope. Optional fields include an integration credential, signing secret, custom headers, and query parameters. The API generates a signing secret if omitted.
import { useCreateWebhook } from "@scalereal/sr-voice-engine-react-sdk/hooks";
export function SubscribeAgentEvents({ agentId }: { agentId: string }) {
const createWebhook = useCreateWebhook();
return (
<button
type="button"
disabled={createWebhook.isPending}
onClick={() =>
createWebhook.mutate({
scope: "agent",
agent_id: agentId,
url: "https://example.com/webhooks/scaleai",
events: ["call.completed"],
})
}
>
Subscribe
</button>
);
}Update or delete a subscription
useUpdateWebhook accepts { id, data }, where data is a partial UpdateWebhookRequest. It refreshes the subscription, list, and delivery-log queries. useDeleteWebhook accepts the webhook ID string and invalidates webhook caches.
Use webhookKeys to target subscription query caches. Hook inputs and result data are typed and available through TypeScript inference.
Related pages
- Agents Subscribe to agent events.
- Integration Credentials Store the credentials used to authenticate deliveries.
- Types Review webhook models and event types.