PHPackages                             simtabi/netsapiens-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. simtabi/netsapiens-api

ActiveLibrary

simtabi/netsapiens-api
======================

A PHP Library for calling the NetSapiens REST API

019PHP

Since Mar 13Pushed 3y ago1 watchersCompare

[ Source](https://github.com/simtabi/netsapiens-api)[ Packagist](https://packagist.org/packages/simtabi/netsapiens-api)[ RSS](/packages/simtabi-netsapiens-api/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![banner](.github/assets/banner.png?raw=true)](.github/assets/banner.png?raw=true)

NetSapiens REST API Client
==========================

[](#netsapiens-rest-api-client)

[![Latest Version on Packagist](https://camo.githubusercontent.com/df763f476d38d2c66c652fb60bf2c7fca98b0a885800686581843b832463cdf4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73696d746162692f6e657473617069656e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/simtabi/netsapiens)[![Total Downloads](https://camo.githubusercontent.com/171cc8242a3fd4b47cf89a4708487bedbffd40efb2900b8d66597b29850b5045/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73696d746162692f6e657473617069656e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/simtabi/netsapiens)[![GitHub Actions](https://github.com/simtabi/netsapiens/actions/workflows/main.yml/badge.svg)](https://github.com/simtabi/netsapiens/actions/workflows/main.yml/badge.svg)

A PHP REST API client for calling the NetSapiens API ().

API specific documentation can be found online at the [ns-api API Reference ](https://api.netsapiens.com/ns-api/webroot/apidoc/) website.

Features
--------

[](#features)

1. REST API client
2. Command line client — coming soon

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require simtabi/netsapiens
```

### Usage

[](#usage)

```
use Simtabi\NetSapiens\NetSapiens;
use Simtabi\NetSapiens\Helpers\Helpers;

// API auth credentials
$clientId         = ''; // your client id
$clientSecret     = ''; // your client secret
$username         = ''; // your username
$password         = ''; // your password
$baseUrl          = ''; // i.e https://api.netsapiens.com/

$guzzleConfig     = []; // Guzzle HTTP client configuration

// Path to store cache files
$cachePath        = ''; // path to where the cache would be stored

// Initialize the API client
try {
    return NetSapiens::getInstance(
        clientId     : $clientId,
        clientSecret : $clientSecret,
        username     : $username,
        password     : $password,
        baseUrl      : $baseUrl,
        cacher       : function (array $args) use ($cachePath) {
                        $cacheData = $args[0];
                        $cacheId   = $args[1];

                        return Helpers::cacher(
                            items :            $cacheData,
                            cacheId:           $cacheId,
                            cachePath :        $cachePath,
                            lifeTimeInSeconds: Helpers::CACHE_LIFETIME_IN_SECONDS,
                            resetCache:        true,
                        );
    },
        guzzleConfig : $guzzleConfig
    );
} catch (NetSapiensException $exception) {
    // do something if we encountered errors
    echo $exception->getMessage();
}

// you can access resource specific error by calling the following method
```

Accessing the `Authentication` object instance

```
$oAuth2 = $netSapiensClient->getOAuth2();
```

Accessing all errors encountered during an `OAuth2` call

```
$errors = $netSapiensClient->getOAuth2()->getErrors();
```

Using the helper method

```
$netSapiensClient = netSapiensClient($clientId, $clientSecret, $username, $password, $baseUrl, $cacher, $guzzleConfig);

// returns a NetSapiens instance or a string if there were errors found
```

### N.B

[](#nb)

If you do not want to use the default caching mechanism. `cacher` accepts a `callback function` where you can pass in a custom caching implementation.

Available Resources
===================

[](#available-resources)

Resources marked in green are ready for use.

\#ResourceReady?1Address❌2Agent❌3AgentLog❌4AnswerRule❌5Audio❌6Call❌7CallCenterStats❌8CallerIDEmergency❌9CallQueue✅10CallQueueEmailReport❌11CallQueueStats❌12CallRequest❌13CDR2❌14CDRExport❌15CDRSchedule❌16Chart❌17Conference❌18ConferenceParticipant❌19ConferenceRecord❌20Connection❌21Contact❌22Dashboard❌23Default❌24Department❌25Device❌26DeviceModel❌27DeviceProfile❌28DialPlan❌29DialPolicy❌30DialRule❌31Domain❌32Image❌33MAC❌34Meeting❌35Message❌36MessageSession❌37NDPServer❌38Permission❌39PhoneConfiguration❌40PhoneNumber❌41Presence❌42Queued❌43Quota❌44Recording❌45Reseller❌46Route❌47ServerInfo❌48SFU❌49Site❌50Sites❌51SMSNumber❌52Subscriber❌53Subscription❌54TimeFrame❌55TimeRange❌56Trace❌57Turn❌58UCInbox❌59UIConfig❌60Upload❌61VoicemailReminders❌1. Create a Call Queue
----------------------

[](#1-create-a-call-queue)

```
// Call queue details
$phoneNumber = '';
$queue       = '';
$uid         = '';

// Create a call queue
$newCallQueue = $netSapiensClient
                ->getCallQueue()
                ->setQueue($queue)
                ->setUid($uid)
                ->create($phoneNumber);
```

Only use `$netSapiensClient instanceof NetSapiens` when using the helper function. i.e

```
if($netSapiensClient instanceof NetSapiens) {
    $newCallQueue = $netSapiensClient
                    ->getCallQueue()
                    ->setQueId($queue)
                    ->setUid($uid)
                    ->create($phoneNumber);

    if ($newCallQueue) {
        // do something if successful
    }
} else {
    // do something if we have errors
}
```

### Accessing the `Request` object instance

[](#accessing-the-request-object-instance)

This can only be achieved after making a resource request. For example, you can access the `Request` instance after creating a call queue.

```
$callQueue  = $netSapiensClient->getCallQueue()->setQueue($queue)->setUid($uid);
$callNumber = $callQueue->create($phoneNumber);
$errors     = $callQueue->getRequest()->getErrors();
```

If you do not want to use the default caching mechanism. `cacher` accepts a `callback function` where you can pass in a custom caching implementation.

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Imani Manyara](https://github.com/imanimanyara)
- [Easter Mukora](https://github.com/eastermukora)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/e606811f3653a5a5a2a0bc39e2cfd2d52436e7f73da3e416dd13284c7ac87f0a?d=identicon)[simtabi](/maintainers/simtabi)

### Embed Badge

![Health badge](/badges/simtabi-netsapiens-api/health.svg)

```
[![Health](https://phpackages.com/badges/simtabi-netsapiens-api/health.svg)](https://phpackages.com/packages/simtabi-netsapiens-api)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
