API Documentation
API Architecture
Trata’s API architecture is divided into two main categories:
Control Plane APIs
- Configuration-focused APIs
- Not invoked during active conversations
- Used for system setup and management
Data Plane APIs
- Runtime APIs used during conversation flows
- Handles real-time communication
- Manages connections and WebSocket interactions
Conversation Protocol
Trata uses WebSockets for real-time communication with user-facing endpoints (Telephony providers and Frontend UI widgets).
Message Stream Schema
After opening the websocket connection, the server expects and sends messages in the following schema:
Command Types
Command | Description |
---|---|
CLIENT_TO_SERVER_SYNC | Clients uses this command to send audio bytes received from microphone or text to server |
SERVER_TO_CLIENT_SYNC | Server uses this command to send audio bytes to be played to the user or text to be displayed to the users terminal |
END_OF_TURN | Server sends this command to indicate that the response for a dialog request is completed |
STOP | If client wants to stop the conversation and close the websocket connection, it can send this command |
ABORT_AUDIO | When server detects that the user has interrupted the conversation, it will send this command to client so that client can stop playing any buffered audio and listen to the user input |
UPDATE_MESSAGE_STATUS | Client can send this message to update the server that audio bytes for a particular dialog has been played |
Payload Types
Type | Description | Format |
---|---|---|
AUDIO | Audio data payload | For BROWSER connections: PCM audio with FLOAT32 encoding, 44.1kHz sample rate, 32-bit depth, and 128-sample chunks. For TWILIO/PLIVO connections: Format is automatically handled by Trata |
TEXT | Text data payload | Text string |