From.123456789101112131415import { RuutVoice, VoiceResponse } from "@ruut/voice-sdk"; const client = new RuutVoice({ accountSid: process.env.RUUT_ACCOUNT_SID, authToken: process.env.RUUT_AUTH_TOKEN, baseUrl: "https://voice.ruut.chat", }); const call = await client.calls.create({ to: "+2348000000001", from: "+2348000000002", twiml: new VoiceResponse() .say("Hello! This call was placed with the Ruut Voice API.") .toXml(), });
Method (GET or POST) when the call connects — ideal when your call flow depends on data you compute at answer time.123456const call = await client.calls.create({ to: "+2348000000001", from: "+2348000000002", url: "https://app.example.com/twiml/welcome", method: "POST", });
1234567curl -X POST "https://voice.ruut.chat/2010-04-01/Accounts/$RUUT_ACCOUNT_SID/Calls" \ -u "$RUUT_ACCOUNT_SID:$RUUT_AUTH_TOKEN" \ --data-urlencode "To=+2348000000001" \ --data-urlencode "From=+2348000000002" \ --data-urlencode "Url=https://app.example.com/twiml/welcome" \ --data-urlencode "Method=POST" \ --data-urlencode "StatusCallback=https://app.example.com/calls/status"
1234567891011121314// Direct SIP await client.calls.createSipCall({ sipUri: "sip:trunk@pbx.example.com", from: "+2348000000002", twiml: new VoiceResponse().say("Connecting you.").toXml(), }); // Agent extension (username) await client.calls.createAgentCall({ agentUsername: "agent-1001", sipDomain: "sip.ruut.chat", from: "+2348000000002", twiml: new VoiceResponse().say("You are being connected to an agent.").toXml(), });
statusCallback URL to receive asynchronous updates as the call progresses: queued → ringing → in-progress → completed (or a terminal failure). The current call-status callback is unsigned; verify important state through the authenticated API. See the call status webhook reference.12345678{ "sid": "CA2e9f6b3c4d5e6f7a8b9c0d1e2f3a4b5c", "status": "queued", "to": "+2348000000001", "from": "+2348000000002", "direction": "outbound-api", "uri": "/2010-04-01/Accounts/AC…/Calls/CA2e9f6b…" }