Node.js SDK
TypeScript SDK for Node.js. Install via npm, place calls with client.calls.create(). Preview; pin your version.
TypeScript SDK for Node.js. Install via npm, place calls with client.calls.create(). Preview; pin your version.
@sautikit/node is the server-side TypeScript client for the Sautikit API. It places calls, fetches call records and recordings, supervises live calls, mints tokens for browser calling, and builds voice-action JSON. It ships both ES modules and CommonJS and runs on Node.js 18 or later.
It authenticates with your secret API key, so it must run on a server. For calling from a web page, use @sautikit/webrtc with a short-lived token (see Mint a token for the browser).
npm install @sautikit/nodeOr with Yarn:
yarn add @sautikit/nodeOr with pnpm:
pnpm add @sautikit/nodeto is an array of E.164 numbers. The call's flow comes from the voice_callback_url set on the from number:
import { SautikitClient } from "@sautikit/node";
const client = new SautikitClient({
apiKey: process.env.SAUTIKIT_API_KEY,
});
const call = await client.calls.create({
from: "+254720000000",
to: ["+254720000001"],
});
console.log(`Call placed. ID: ${call.call_id}, Status: ${call.status}`);The response includes:
{
"call_id": "9d2b1f53-8c0e-4f1d-9a6b-5d3a8c47e9f0",
"session_id": "HD_1a2b3c",
"status": "ringing"
}The API key is a bearer JWT. The SDK reads it from the SAUTIKIT_API_KEY environment variable by default:
export SAUTIKIT_API_KEY="eyJ..."Or pass it directly to the constructor:
const client = new SautikitClient({
apiKey: "eyJ...",
});Never send your API key to a web page. Mint a short-lived token on your server (POST /v1/webrtc/token, scope webrtc.token) and pass the result to @sautikit/webrtc:
const session = await client.webrtc.mintToken({
phoneNumber: "+254720000000", // one of your Sautikit numbers
});
// Return `session` to the page: { token, endpoint, protocol, turnServer, expiresIn }Put a supervisor on a live call, switch between listen, whisper and barge, and take them off again. Your API key needs the calls.supervise scope (calls.read for getSupervision):
const sup = await client.calls.supervise("HD_24d73b4518bc", {
mode: "listen",
supervisor: { type: "phone", number: "+254720000002" },
label: "Mary Wanjiku",
});
// Later, once the supervisor has answered (call.supervision.started):
await client.calls.setSupervisionMode(sup.call_id, "whisper");
// When they are done:
await client.calls.stopSupervision(sup.call_id);A mode change before the supervisor answers gets 409 calls.supervisor_not_connected.
calls.getSupervision(callId) returns the active supervision or null. The full walkthrough, including a browser supervisor, is in Supervise live calls.
@sautikit/webrtc with a token from client.webrtc.mintToken().Preview. The SDK's public API may change before v1.0. Pin an exact version in package.json:
{
"dependencies": {
"@sautikit/node": "0.x.y"
}
}Watch releases on GitHub for breaking changes.