API Reference

REST endpoints and WebSocket protocols for the FastAPI backend.

Base URL: /api/v1/ — Interactive OpenAPI docs available at /docs when running locally.

Health & Monitoring

EndpointMethodDescription
/healthGETLiveness check. Returns 200 when server is running. Use for K8s liveness probes.
/readyGETReadiness check. Returns 200 when warmup tasks (MCP, pools) are complete.
/readinessGETDeep health check. Validates all Azure service dependencies.
/poolsGETResource pool metrics — TTS/STT client availability and utilization.
/appconfigGETAzure App Configuration provider status.
/appconfig/refreshPOSTForce refresh App Configuration cache.

Example

# Check if backend is ready to serve calls
curl https://your-backend.azurecontainerapps.io/api/v1/ready

# Response
{
  "status": "ready",
  "mcp": "connected",
  "pools": { "tts": 5, "stt": 5 }
}

Call Management

EndpointMethodDescription
/calls/initiatePOSTStart an outbound call. Body: { "phone_number": "+1..." }
/calls/GETList active/recent calls with pagination.
/calls/terminatePOSTEnd an active call. Body: { "connection_id": "..." }
/calls/answerPOSTHandle inbound call from ACS Event Grid webhook.
/calls/callbacksPOSTProcess ACS callback events (call state changes, DTMF, etc.)

Initiate a call

curl -X POST https://your-backend/api/v1/calls/initiate \
  -H "Content-Type: application/json" \
  -d '{"phone_number": "+18165019907", "scenario": "banking"}'

Media Streaming

EndpointTypeDescription
/media/statusGETMedia streaming configuration and active stream count.
/media/streamWebSocketACS bidirectional audio stream. See WebSocket protocol.

Genesys AudioConnector

AudioHook v2 bridge for Genesys Cloud telephony. See the Genesys Cloud Integration guide for setup, the simulator, and troubleshooting.

EndpointTypeDescription
/genesys/healthGETLiveness check — returns {"status":"ok","service":"genesys-audiohook"}.
/genesys/streamWebSocketAudioHook v2 audio + control stream (subprotocol audiohook-v2, µ-law 8 kHz). Bridges Genesys Cloud AudioConnector to Azure VoiceLive.

Browser Conversations

EndpointTypeDescription
/browser/statusGETActive browser connections and service status.
/browser/conversationWebSocketBrowser-based voice conversation. See WebSocket protocol.
/browser/dashboard/relayWebSocketReal-time dashboard events (audio levels, transcripts, agent state).

Agent Management

EndpointMethodDescription
/agentsGETList all loaded agents with their configuration.
/agents/{name}GETGet specific agent details (prompt, tools, handoff trigger).
/agents/{name}PUTUpdate agent runtime configuration (model, temperature, etc.).
/agentsPOSTCreate a new agent at runtime (session-scoped).

Sessions

EndpointMethodDescription
/sessions/{id}GETGet session state (scenario, active agent, conversation history).
/sessions/{id}/resetPOSTReset session — new ID, clear state, fresh conversation.

Scenarios

EndpointMethodDescription
/scenariosGETList available scenarios (built-in + session-created).
/scenariosPOSTCreate a session-scoped scenario from the Scenario Builder.
/scenarios/{name}GETGet scenario details (agents, handoffs, start agent).

Demo Profiles

EndpointMethodDescription
/profiles/generatePOSTGenerate a random demo customer profile (name, accounts, MFA).
/profiles/{id}GETRetrieve a generated profile by ID.

WebSocket: Media Stream

wss://your-backend/api/v1/media/stream

Bidirectional audio streaming for ACS. The backend receives raw audio from ACS and sends synthesized audio back.

Message types (server → client)

TypePayload
audioBase64-encoded PCM audio chunk
transcriptSTT recognition result (interim or final)
agent_responseLLM text response before TTS
handoffAgent handoff notification (from, to, type)
tool_callTool invocation event (name, args, result)

WebSocket: Browser Conversation

wss://your-backend/api/v1/browser/conversation?session_id=...

Browser-based voice conversation using the Web Audio API. Same orchestration pipeline as phone calls.

Message types (client → server)

TypePayload
audio_dataBase64 PCM audio from browser microphone
controlStart/stop/pause/reset commands
configSession configuration (scenario, agent overrides)

Message types (server → client)

TypePayload
audioBase64 PCM audio for playback
transcriptUser speech recognition
responseAgent text response
eventSession events (handoff, tool call, state change)
audio_levelsInput/output amplitude for visualization

Configuration Reference

All configuration via environment variables. azd up generates a .env.local with all values.

Core

VariableDescriptionDefault
ACS_STREAMING_MODEOrchestration mode: MEDIA, TRANSCRIPTION, or VOICE_LIVEMEDIA
BASE_URLPublic callback URL ACS uses to reach the backend (dev tunnel URL for local dev)
ENVIRONMENTdevelopment or productiondevelopment

Azure Services

PrefixServiceKey variables
ACS_*Communication ServicesACS_ENDPOINT, ACS_PHONE_NUMBER
AZURE_OPENAI_*Azure OpenAIAZURE_OPENAI_ENDPOINT, AZURE_OPENAI_DEPLOYMENT
AZURE_SPEECH_*Speech ServicesAZURE_SPEECH_REGION, AZURE_SPEECH_KEY
REDIS_*Azure RedisREDIS_HOST, REDIS_PORT
AZURE_COSMOS_*Cosmos DBAZURE_COSMOS_ENDPOINT, AZURE_COSMOS_DATABASE

Voice settings

VariableDescriptionDefault
TTS_VOICEAzure neural voice nameen-US-AvaMultilingualNeural
TTS_STYLEVoice style (chat, friendly, etc.)chat
TTS_RATESpeech rate adjustment+3%
STT_LANGUAGERecognition languageen-US
VAD_SILENCE_TIMEOUTSilence before turn end (ms)500