Registry / messaging / tnzapi

tnzapi

JSON →
library2.4.2jsnpmunverified

tnzapi is a Node.js library for interacting with the TNZ Group REST API, supporting SMS, email, fax, text-to-speech (TTS), and voice messaging. Current stable version is 2.4.2. The library provides a unified client with namespaced messaging services (SMS, Email, Fax, TTS, Voice) and supports both Promise and callback patterns. It has moderate release cadence and is focused on New Zealand telecom services. Key differentiator is its all-in-one API for multiple communication channels in one package.

npm install tnzapi
INSTALL
IMPORT
SIG · TNZAPI
T
tnzapi
messagingjavascriptv2.4.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TNZAPI
const TNZAPI = require('tnzapi');
import TNZAPI from 'tnzapi';
This package is CommonJS only; ESM import will fail.
Client instance
const client = new TNZAPI({ AuthToken: '...' });
const client = new TNZAPI.AuthToken('...');
TNZAPI is a constructor function; pass options object, not direct token.
client.Messaging.SMS.SendMessage
client.Messaging.SMS.SendMessage({...}).then(callback);
client.Messaging.SMS.sendMessage({...});
Method name is PascalCase SendMessage, not camelCase.

Sends an SMS using the TNZ API client with authentication from environment variable.

const TNZAPI = require('tnzapi'); const client = new TNZAPI({ AuthToken: process.env.TNZ_AUTH_TOKEN ?? '' }); client.Messaging.SMS.SendMessage({ Reference: 'Test', Message: 'Hello from tnzapi!', Destinations: [ { Recipient: '+64211234567' } ] }).then(response => { console.log('Response:', JSON.stringify(response, null, 2)); }).catch(err => { console.error('Error:', err); });
Debug
Known issues
gotchaAll method names use PascalCase (e.g., SendMessage, GetStatus). Using camelCase (sendMessage) will fail silently.
fix
Use exact method names as documented: SendMessage, GetStatus, etc.
affects: >=2.0.0
gotchaThe library is CommonJS only. Using ES module imports (import TNZAPI from 'tnzapi') will result in an error: 'The requested module 'tnzapi' does not provide an export named 'default'.
fix
Always use require('tnzapi') in Node.js; for ESM projects, use dynamic import or create a CJS wrapper.
affects: >=2.0.0
deprecatedThe callback pattern (e.g., client.Messaging.SMS.SendMessage({...}, callback)) is deprecated. Promises are preferred.
fix
Use .then()/.catch() or async/await instead of passing a callback.
affects: >=2.4.0
Errors
Common errors & fixes
ReferenceError: TNZAPI is not defined
Missing require or incorrect import style (ESM import).
fix
Replace 'import TNZAPI from "tnzapi"' with 'const TNZAPI = require("tnzapi")'.
TypeError: client.Messaging is undefined
Authentication failed or invalid AuthToken passed to constructor.
fix
Ensure you pass an object with 'AuthToken' property to the TNZAPI constructor: new TNZAPI({ AuthToken: 'your-token' })
TypeError: client.Messaging.SMS.sendMessage is not a function
Wrong method casing; should be PascalCase SendMessage.
fix
Use client.Messaging.SMS.SendMessage instead of sendMessage.
Upgrade
Version history
2.4.2latest on npm
Audit
Dependencies
axiosrequiredHTTP client for REST API calls
Agent activity
26 hits · last 30 days
node
22
OpenAI (training)
1
Resources
packagetnzapi
tnzapi — npm install tnzapi · libregistry