DocumentationAPI ReferenceReact SDKRelease Notes
ScaleAI

Getting Started

OverviewInstallationQuick Start

Core

Provider & Setup

Hooks

AgentsOutbound CallsCall HistoryPhone NumbersIntegration CredentialsWebhooksKnowledge BasesFunction ToolsFunction Logs

Realtime

Realtime

UI

Components

Reference

TypesUtilities
Go to platform

Agents

Query, create, update, publish, version, and generate prompts for AI voice agents using the React SDK.

Agents are the core resource in ScaleAI. Each agent encapsulates a voice personality, prompt, tool configuration, and deployment status. The SDK exposes a full set of TanStack Query hooks for listing, mutating, versioning, and AI-assisted prompt generation.

Fetching agents

useAgents

useAgents(params?) fetches a paginated list of AgentListItem records. All parameters are optional — call it with no arguments to load the first page of all agents.

import { useAgents } from "@scalereal/sr-voice-engine-react-sdk/hooks";

export function AgentList() {
  const { data, isPending, isError } = useAgents({
    status: "published",
    sort_by: "-updated_at",
    page: 1,
    size: 20,
  });

  if (isPending) return <p>Loading agents…</p>;
  if (isError) return <p>Failed to load agents.</p>;

  return (
    <ul>
      {data.results.map((agent) => (
        <li key={agent.id}>{agent.name}</li>
      ))}
    </ul>
  );
}

Parameters — ListAgentsParams

ParameterTypeDescription
pagenumber1-based page number.
sizenumberNumber of records per page.
searchstringFree-text search across agent names.
agent_type"single_prompt" | "workflow"Filter to a specific agent type.
status"draft" | "published"Filter by publish status.
is_activebooleantrue returns only active agents; false returns archived agents.
languagestringFilter by language code (e.g. "en").
workflow_idstringFilter agents attached to a specific workflow.
knowledgebase_idstringFilter agents that use a specific knowledge base.
sort_bystringSort field: created_at, updated_at, or name. Prefix with - for descending (e.g. -updated_at).

Return type

PaginatedResponse<AgentListItem> — includes results, total, page, and size.


useAgentDetails

useAgentDetails(agentId, enabled?) fetches the full AgentDetail for a single agent. The query is automatically disabled when agentId is an empty string, so it's safe to call before you have an ID.

import { useAgentDetails } from "@scalereal/sr-voice-engine-react-sdk/hooks";

export function AgentDetail({ agentId }: { agentId: string }) {
  const { data, isPending } = useAgentDetails(agentId);

  if (isPending) return <p>Loading…</p>;
  return <h1>{data?.name}</h1>;
}
ParameterTypeDescription
agentIdstringThe agent's ID. Pass an empty string to keep the query idle.
enabledbooleanExplicitly disable the query without changing agentId. Optional.

Creating and updating agents

useCreateAgent

Creates a new agent and returns the full Agent object. After a successful mutation, the agents list cache is automatically invalidated.

import { useCreateAgent } from "@scalereal/sr-voice-engine-react-sdk/hooks";

export function CreateAgentButton() {
  const { mutate, isPending } = useCreateAgent();

  return (
    <button
      type="button"
      disabled={isPending}
      onClick={() =>
        mutate({
          name: "Support Assistant",
          agent_type: "single_prompt",
        })
      }
    >
      {isPending ? "Creating…" : "Create agent"}
    </button>
  );
}
ParameterTypeDescription
namestringDisplay name of the agent.
agent_type"single_prompt" | "workflow"The agent's execution model. Cannot be changed after creation.

useUpdateAgent

Sends a partial (PATCH) update — only the fields you include are changed. Automatically invalidates both the agent detail and list caches on success.

useUpdateAgent is the multi-purpose mutation for configuration changes. It also handles publishing and deactivation via the same call.

import { useUpdateAgent } from "@scalereal/sr-voice-engine-react-sdk/hooks";

export function UpdateAgentForm({ agentId }: { agentId: string }) {
  const { mutate, isPending } = useUpdateAgent();

  const handleSave = () => {
    mutate({
      agentId,
      welcome_message: "Thanks for calling. How can I help?",
      language: "en",
    });
  };

  return (
    <button type="button" onClick={handleSave} disabled={isPending}>
      Save changes
    </button>
  );
}
ParameterTypeDescription
agentIdstringRequired. The agent to update.
...UpdateAgentRequestPartial<UpdateAgentRequest>Any subset of the agent's configuration fields.
status"draft" | "published"Set to "published" to publish the agent atomically with other changes.
is_activebooleanSet to false to deactivate (soft-delete) the agent.

Publishing with or without changes. useUpdateAgent with status: "published" saves your changes and publishes in one request. usePublishAgent publishes the last-saved state with no changes. Use useUpdateAgent when you want the user's current edits to go live; use usePublishAgent for a "publish" button that commits what's already saved.


Cloning, archiving, and publishing

useCloneAgent

Duplicates an existing agent with a new name. Returns { agent_id } for the new clone. The cloned agent starts as a draft.

import { useCloneAgent } from "@scalereal/sr-voice-engine-react-sdk/hooks";

export function CloneButton({ agentId }: { agentId: string }) {
  const { mutate, isPending } = useCloneAgent();

  return (
    <button
      type="button"
      disabled={isPending}
      onClick={() => mutate({ agentId, name: "My Agent (copy)" })}
    >
      Clone
    </button>
  );
}
ParameterTypeDescription
agentIdstringThe agent to clone.
namestringDisplay name for the cloned agent.

useDeleteAgent

useDeleteAgent is a soft delete. It sets is_active: false on the agent — it does not erase the agent, its configuration, or any call history. You can restore the agent by calling useUpdateAgent with is_active: true.

import { useDeleteAgent } from "@scalereal/sr-voice-engine-react-sdk/hooks";

export function ArchiveButton({ agentId }: { agentId: string }) {
  const { mutate, isPending } = useDeleteAgent();

  return (
    <button type="button" disabled={isPending} onClick={() => mutate({ agentId })}>
      Archive
    </button>
  );
}

usePublishAgent

Publishes the agent's last-saved configuration without making any other changes.

import { usePublishAgent } from "@scalereal/sr-voice-engine-react-sdk/hooks";

export function PublishButton({ agentId }: { agentId: string }) {
  const { mutate, isPending } = usePublishAgent();

  return (
    <button type="button" disabled={isPending} onClick={() => mutate({ agentId })}>
      {isPending ? "Publishing…" : "Publish"}
    </button>
  );
}

Managing versions

Every time you save an agent, a new version snapshot is created. You can list, inspect, annotate, and restore versions to roll back to a previous configuration.

useAgentVersions

import { useAgentVersions } from "@scalereal/sr-voice-engine-react-sdk/hooks";

export function VersionList({ agentId }: { agentId: string }) {
  const { data } = useAgentVersions(agentId, { page: 1, size: 10 });

  return (
    <ul>
      {data?.results.map((v) => (
        <li key={v.version}>
          v{v.version} — {v.version_title ?? "Untitled"}
        </li>
      ))}
    </ul>
  );
}

useAgentVersion

Fetches a single stored version. Pass enabled: false to defer loading.

const { data } = useAgentVersion(agentId, "42");

useUpdateAgentVersionMetadata

Annotates a version with a human-readable title and description without modifying the configuration.

import { useUpdateAgentVersionMetadata } from "@scalereal/sr-voice-engine-react-sdk/hooks";

const { mutate } = useUpdateAgentVersionMetadata();

mutate({
  agentId: "agent-id",
  version: "42",
  version_title: "Stability release",
  version_description: "Fixed greeting loop and reduced latency.",
});
ParameterTypeDescription
agentIdstringThe agent whose version to annotate.
versionstringVersion identifier.
version_titlestringShort label for this version. Optional.
version_descriptionstringLonger notes about this version. Optional.

useRestoreAgentVersion

Restoring a version replaces the current draft configuration with the restored snapshot. Any unsaved changes to the current draft are lost. The restore does not auto-publish — the agent remains a draft until you explicitly publish it.

import { useRestoreAgentVersion } from "@scalereal/sr-voice-engine-react-sdk/hooks";

const { mutate } = useRestoreAgentVersion();

mutate({ agentId: "agent-id", version: "42" });

AI prompt generation

useGenerateAgentPrompt

Sends a plain-language description to the platform AI and returns an enhanced_prompt — a fully structured system prompt optimized for voice.

useGenerateAgentPrompt does not save the result. It only returns the enhanced text. You must pass the result to useUpdateAgent to apply it to the agent.

import {
  useGenerateAgentPrompt,
  useUpdateAgent,
} from "@scalereal/sr-voice-engine-react-sdk/hooks";

export function PromptGenerator({ agentId }: { agentId: string }) {
  const generate = useGenerateAgentPrompt();
  const update = useUpdateAgent();

  const handleGenerate = async () => {
    const result = await generate.mutateAsync({
      agentId,
      userPrompt: "A friendly support agent for a SaaS product that helps with billing issues.",
    });

    // Apply the enhanced prompt to the agent
    update.mutate({ agentId, system_prompt: result.enhanced_prompt });
  };

  return (
    <button type="button" onClick={handleGenerate} disabled={generate.isPending || update.isPending}>
      {generate.isPending ? "Generating…" : "Generate prompt"}
    </button>
  );
}
ParameterTypeDescription
agentIdstringThe agent context used to seed generation.
userPromptstringPlain-language description of the agent's role, tone, and responsibilities.

Returns: { enhanced_prompt: string }


Creating from a template

useCreateAgentFromTemplate provisions a fully configured agent from a pre-built template. Returns { agent_id } for the new agent.

import { useCreateAgentFromTemplate } from "@scalereal/sr-voice-engine-react-sdk/hooks";

const { mutate } = useCreateAgentFromTemplate();

mutate({ template_id: "tpl_inbound_support_v1" });

Calendar integration

useGetCalendarIntegration(provider, apiKeyId, timezoneSearch?, enabled?) loads scheduling metadata for Calendly or Cal.com integrations attached to an agent. The query stays idle if either provider or apiKeyId is empty.

import { useGetCalendarIntegration } from "@scalereal/sr-voice-engine-react-sdk/hooks";

const calendar = useGetCalendarIntegration("calendly", credentialId, "America/New_York");
ParameterTypeDescription
providerstring"calendly" or "calcom".
apiKeyIdstringThe integration credential ID. See Integration Credentials.
timezoneSearchstringFilter available event types by timezone. Optional.
enabledbooleanExplicitly disable the query. Optional.

Prompt variables

useAgentPromptVariables(agentId, enabled?) loads the prompt variable templates defined for an agent (e.g. {{customer_name}}). Use this to populate a UI that lets callers fill in dynamic values before initiating a call.

const { data } = useAgentPromptVariables(agentId);

Cache keys

agentKeys is a factory object that produces stable TanStack Query cache keys for all agent-related queries. Use it to manually invalidate or prefetch from outside a hook.

import { agentKeys } from "@scalereal/sr-voice-engine-react-sdk/hooks";
import { useQueryClient } from "@tanstack/react-query";

const qc = useQueryClient();
qc.invalidateQueries({ queryKey: agentKeys.lists() });
qc.invalidateQueries({ queryKey: agentKeys.detail(agentId) });

Related pages

  • Calls — Initiate telephony and SIP calls with an agent.
  • Function Tools — Configure tools attached to agents.
  • Integration Credentials — Manage provider keys used by agent features.
  • Knowledge Bases — Manage knowledge sources attached to agents.
  • Types — Full type reference for agent request and response models.

Provider & Setup

Configure CallingAgentProvider, use its built-in query client, and handle SDK errors.

Outbound Calls

Initiate telephony and SIP calls, handle dynamic variables, and recall existing sessions.

On this page

Fetching agentsuseAgentsParameters — ListAgentsParamsReturn typeuseAgentDetailsCreating and updating agentsuseCreateAgentuseUpdateAgentCloning, archiving, and publishinguseCloneAgentuseDeleteAgentusePublishAgentManaging versionsuseAgentVersionsuseAgentVersionuseUpdateAgentVersionMetadatauseRestoreAgentVersionAI prompt generationuseGenerateAgentPromptCreating from a templateCalendar integrationPrompt variablesCache keysRelated pages