Cloud
Voice quickstart
Turn on Pro voice for a project and talk in a room from the browser or Unity WebGL in a few lines.
1. Turn it on
Dashboard, your project, Settings, Voice Pro. If you set Allowed origins, the page that asks for voice must be one of them.
2. Web
npm install @syncverse/client @syncverse/voiceimport { SyncVerseSession } from "@syncverse/client";
import { SyncVerseVoice } from "@syncverse/voice";
const session = new SyncVerseSession({ appId: "sv_app_...", roomName: "lobby" });
let voice: SyncVerseVoice | null = null;
session.on("joined", async (room, me) => {
voice?.leave();
// Mints a voice token with the room ticket, then connects to the voice server. The mic stays off.
voice = await SyncVerseVoice.join(room, { tier: "pro", appId: "sv_app_..." });
voice.on("speaking", (playerId, speaking) => showSpeaker(playerId, speaking));
});
// Browsers only allow audio after a click or key press.
talkButton.onclick = () => voice?.setMicEnabled(!voice.micEnabled);SyncVerseVoice.join uses room.info.ticket, so call it right after joining (tickets expire after 30 seconds). It keeps a voice session for reconnects, retrying with backoff; the session lasts 6 hours from the first token and only while the player stays in the room. The mic starts off; setMicEnabled(true) asks for permission. Each remote player plays through an audio element, or through a Web Audio panner when you pass spatial: true and call setPlayerPosition.
3. Unity
// Same component as Simple voice: GameObject > SyncVerse > Voice Chat.
var voice = SyncVerseVoice.Instance;
voice.Tier = VoiceTier.Pro; // Simple (default) or Pro
voice.FallbackToSimple = true; // if Pro is refused or cannot connect, use the room relay
voice.Mode = TransmitMode.PushToTalk;
voice.OnTierChanged += tier => Debug.Log ("Voice tier: " + tier);In WebGL builds Pro uses the browser's WebRTC. The voice library loads only when Pro is on, so Simple-only games do not download it.
The token endpoint
The SDKs call it for you. For other engines:
POST https://syncverse.aqaddoura.com/api/voice/token
Content-Type: application/json
// Preferred: a voice grant the room server signs for a player who has joined (VoiceGrantRequest, valid 30 s, single use)
{ "appId": "sv_app_...", "grant": "vg1...." }
// Or the room ticket you joined with (CreateRoom / JoinRandomRoom), right after joining
{ "appId": "sv_app_...", "ticket": "<room.ticket>" }
200 { "url": "wss://voice...", "token": "<LiveKit JWT, 60 s to connect>", "room": "svp.<project>.<room>", "identity": "p:3",
"playerId": 3, "expiresAt": 1796540000000, "session": "v1....", "sessionExpiresAt": 1796561600000, "maxRoomSize": 10 }
// Reconnects: no ticket needed while the player is still in the room. The session keeps its original expiry.
{ "appId": "sv_app_...", "session": "v1...." }| Error code | HTTP | Meaning |
|---|---|---|
voice_disabled | 403 | Pro voice is off for this project, or the plan does not include it |
invalid_ticket | 401 | The ticket expired (30 s), is for another project, or is not genuine |
invalid_grant | 401 | The voice grant expired (30 s), was already used, or is not genuine |
invalid_session | 401 | The session expired (6 h) or is for another project |
not_in_room | 403 | The player has not joined the room with this ticket, or has left it |
voice_kicked | 403 | The player was removed from voice in this room (for example for publishing video) and must wait |
room_gone | 404 | The SyncVerse room has ended |
origin_not_allowed | 403 | The page's origin is not in the project's allowed origins |
voice_ccu_full | 429 | The project has as many people in voice as its limit |
voice_minutes_exhausted | 429 | The project used this month's voice minutes |
voice_platform_full | 503 | The voice server is at capacity |
voice_unavailable | 503 | No voice server on this deployment, or it is unreachable |
rate_limited | 429 | Too many token requests from one address or for one project; wait for Retry-After |
Who you are in voice: p:<playerId>, your SyncVerse player id in that room, taken from signed data (never from the request). The same id is attached as the participant attribute sv.player, so clients can put each voice on the right avatar. Errors marked 429 or 503 carry a Retry-After header.