Error Handling

Catch and inspect SDK failures in Node.js and Python.

Both SDKs raise on non-2xx responses. A 204 No Content resolves to undefined (Node) / None (Python) instead of raising.

import { BranofyVoiceSdk, VoiceApiError } from "@branofy/voice-sdk-node";

const voice = new BranofyVoiceSdk({
  baseUrl: "https://api.branofy.cloud",
  apiKey: process.env.BRANOFY_VOICE_API_KEY,
});

try {
  await voice.calls.start("agt_missing", {
    phone: "+919876543210",
    name: "Priya Sharma",
  });
} catch (err) {
  if (err instanceof VoiceApiError) {
    console.error(`Request failed (${err.status}): ${err.message}`);
    console.error(err.details);
  } else {
    throw err;
  }
}
import requests

try:
    client.start_call(agent_id="agt_missing", phone="+91...", name="Priya")
except requests.HTTPError as err:
    print("Status:", err.response.status_code)
    print("Body:", err.response.text)

VoiceApiError (Node.js)

PropertyTypeDescription
statusnumberHTTP status code of the failed response.
messagestringError message from the body, or the HTTP status text.
detailsunknownThe parsed JSON error body, when available.

Status codes

StatusMeaning
400Malformed request or missing required fields.
401Missing or invalid API key.
404The referenced resource does not exist.

On this page