Developers

SDK Quickstart

Configure one official SDK and create a test call with inline Voice XML. Use a non-production deployment and source and destination identities your environment is permitted to call.

Never commit API credentials. Use HTTPS for remote deployments and callbacks, redact authorization headers from logs, and avoid real customer data during initial testing.

1. Prepare a test environment

Use a non-production NextGenSwitch deployment with test source and destination identities. Confirm permitted destinations, SIP routing, and expected caller ID behavior before sending a request.

2. Configure credentials

All three SDKs can use the same environment variable names:

export NEXTGENSWITCH_BASE_URL="https://your-switch.example.com"
export NEXTGENSWITCH_AUTHORIZATION="your-authorization-code"
export NEXTGENSWITCH_AUTHORIZATION_SECRET="your-authorization-secret"

3. Choose and install a language SDK

Option 1

PHP

PHP 8.1+

Install

composer require nextgenswitch/nextgenswitch-php

Create a call

<?php
require __DIR__ . '/vendor/autoload.php';

use NextGenSwitch\Client;
use NextGenSwitch\VoiceResponse;

$client = new Client(
    baseUrl: getenv('NEXTGENSWITCH_BASE_URL'),
    authorizationCode: getenv('NEXTGENSWITCH_AUTHORIZATION'),
    authorizationSecret: getenv('NEXTGENSWITCH_AUTHORIZATION_SECRET'),
);

$flow = (new VoiceResponse())
    ->say('Hello from NextGenSwitch.');

$result = $client->createCall(
    to: '2001',
    from: '1001',
    responseXml: $flow,
);

print_r($result->data());
Open the PHP SDK repository

Option 2

Python

Python 3.9+

Install

pip install "nextgenswitch @ git+https://github.com/nextgenswitch/nextgenswitch-python.git"

Create a call

import os
from nextgenswitch import Client, VoiceResponse

client = Client(
    os.environ["NEXTGENSWITCH_BASE_URL"],
    os.environ["NEXTGENSWITCH_AUTHORIZATION"],
    os.environ["NEXTGENSWITCH_AUTHORIZATION_SECRET"],
)

flow = VoiceResponse().say("Hello from NextGenSwitch.")
result = client.create_call(
    "2001",
    "1001",
    response_xml=flow,
)
print(result.data)
Open the Python SDK repository

Option 3

Node.js / TypeScript

Node.js 18+

Install

npm install github:nextgenswitch/nextgenswitch-nodejs

Create a call

import {
  NextGenSwitchClient,
  VoiceResponse,
} from "@nextgenswitch/sdk";

const client = new NextGenSwitchClient({
  baseUrl: process.env.NEXTGENSWITCH_BASE_URL!,
  authorization: process.env.NEXTGENSWITCH_AUTHORIZATION!,
  authorizationSecret:
    process.env.NEXTGENSWITCH_AUTHORIZATION_SECRET!,
});

const flow = new VoiceResponse()
  .say("Hello from NextGenSwitch.");

const result = await client.createCall({
  to: "2001",
  from: "1001",
  responseXml: flow,
});

console.log(result.data);
Open the Node.js / TypeScript SDK repository

5. Verify the result

  1. Confirm the API returned a successful response and capture the call ID.
  2. Observe switch logs and call status callbacks without logging authorization headers.
  3. Confirm the test destination rings, answers, and plays the expected message.
  4. Test rejected, unanswered, invalid-credential, and unreachable-callback paths.

A successful API response does not guarantee that a destination answered. Treat call state callbacks and platform logs as separate evidence.

Continue building