SDK & API Docs
Everything you need to integrate VoiceAI into your backend.
Installation
Install the VoiceAI SDK from npm. Requires Node.js 20+.
bash
npm install @voice-agent/sdk
# or
yarn add @voice-agent/sdk
# or
bun add @voice-agent/sdkQuickstart
Create a client with your API key and trigger your first outbound call in seconds.
typescript
import VoiceAI from "@voice-agent/sdk";
const client = new VoiceAI({ apiKey: process.env.VOICEAI_API_KEY });
// Trigger an outbound call
const call = await client.calls.create({
assistantId: "asst_01",
to: "+14155552671",
from: "+18445550100",
metadata: { orderId: "ORD-12345", customerId: "cust_abc" },
});
console.log("Call started:", call.id);Note: Your VOICEAI_API_KEY can be found on the API Keys page. Never expose it in client-side code.
REST API
The REST API is available at https://api.go-do.ai/v1. Use it directly or via the SDK.
bash
curl -X POST https://api.go-do.ai/v1/calls \
-H "Authorization: Bearer vai_prod_k8x2••••••••" \
-H "Content-Type: application/json" \
-d '{
"assistantId": "asst_01",
"to": "+14155552671",
"from": "+18445550100"
}'Webhooks
Configure a webhook URL in Settings → Integrations. VoiceAI will POST events to your endpoint.
typescript
// POST https://your-server.com/webhooks/voiceai
app.post("/webhooks/voiceai", (req, res) => {
const event = req.body;
switch (event.type) {
case "call.completed":
console.log("Call ended:", event.data.call.id);
console.log("Duration:", event.data.call.durationSeconds, "s");
console.log("Sentiment:", event.data.call.sentiment);
break;
case "call.tool_called":
// event.data.toolName, event.data.args, event.data.callId
break;
case "campaign.completed":
console.log("Campaign done:", event.data.campaign.name);
break;
}
res.json({ received: true });
});Event Reference
| Event | Description |
|---|---|
call.started | Call connected and agent session initialized |
call.completed | Call ended; includes duration, sentiment, outcome |
call.failed | Call failed to connect or agent session crashed |
call.tool_called | Agent invoked a tool mid-call; includes args and result |
call.transcript_ready | Full transcript available at the given URL |
campaign.started | Campaign dialing has begun |
campaign.paused | Campaign was paused |
campaign.completed | All targets have been processed |
assistant.updated | An assistant's configuration was changed |