Last updated: Mar 3rd, 2025

CLI Introduction

TNZ SMSCLI is a lightweight command-line tool that allows users to send SMS messages.

Whether you need to send one-time passwords (OTP), alerts, or general notifications, TNZ SMSCLI makes it fast and easy from your terminal.

Register your account

If you don't have an account, head to https://www.tnz.co.nz/Customer/SignUp/ and register.


Create & Export Your API Auth Token

To use the API, an Auth Token is required in the Authorization HTTP header.

To export your Auth Token:

  1. Login to the TNZ Dashboard
  2. Navigate to 'Users'
  3. Create a new user or select an existing one
  4. Enable API access (if it's not already enabled)
  5. Click on the 'API' tab
  6. Enable 'Auth Token' and create a new Auth Token
  7. Click the ' Copy' button to copy it to your clipboard
  8. Paste the Auth Token into the Authorization Header in your application or code

At any time, you can refresh your Auth Token by clicking the button and exporting your new Auth Token. This action will invalidate any apps using your old Auth Token.

Auth Tokens can be used for multiple use-cases, with SubAccount and Department values helping in tracking reporting and billing.


Download

Microsoft Windows 10 and later:

CLI - Send SMS

Call the TNZSMSCLI app from your command line (cmd).


CLI:

TNZSMSCLI.exe "[Mobile]" "[Message]"
TNZSMSCLI.exe "+642100001" "Your verification code is 789456"

Omitting [Mobile] will prompt the user to enter the mobile number into the console.

Omitting [Message] will send the default message: "From [CompanyName], your OTP Code is: [OTPCode]"


Response:

  • Successfully sent [Mobile] the message: [Message]
  • Failed to send [Error] - Invalid Variables
  • Failed to send [401 Unauthorized] - Invalid Auth Token
  • Failed to send [500 Internal Server Error] - API Server Fault

Note:

A "Success" response indicates that the API has accepted your parameters, not that the message has been delivered. For a list of error messages, see TNZ API Errors.


Examples:


Send a custom Message:

TNZSMSCLI.exe "+642100001" "Hi Aaron, your appointment is scheduled for 3pm on Thursday. Reply Y to confirm."

Send the Default OTP Message:

TNZSMSCLI.exe "+642100001"

Send the Default OTP Message and prompt the user for the mobile number:

TNZSMSCLI.exe

Send a single SMS from a PowerShell script:

Start-Process -FilePath ".\TNZSMSCLI.exe" -ArgumentList '"+642100001", "Your appointment is scheduled for 3pm on Thursday"'

Send a batch of SMS messages from a PowerShell script:

$numbers = Get-Content ".\List of mobile numbers.txt"
foreach ($number in $numbers) {
    Start-Process -FilePath ".\TNZSMSCLI.exe" -ArgumentList "$number", '"System outage: The server at domain.com is down."'
}

Send a SMS messages using Windows Task Scheduler:

  1. Open Task Scheduler from the Start menu.
  2. In the Action panel click Create Task.
  3. Under the General tab, give your task a name (e.g. "Send Reminder SMS").
  4. Under the Triggers tab, set a trigger (e.g. Daily at 9:00 AM).
  5. Under the Actions tab, select New, and in the Program/Script box, enter the path to TNZSMSCLI.exe
  6. In the Add arguments (optional) box, enter the following arguments, then save the task:
"+642100001" "Reminder: Run daily tasks."

CLI - Configuration

The TNZSMSCLI.ini contains configuration options:

Parameter Description
CompanyName Sets the 'CompanyName' to display in the default SMS message.
Auth Your TNZ API Auth Token.
PromptClose Prompt the user before closing the app (True/False).
ApiURL The TNZ API version and path.

Frequently Asked Questions

Yes, full international delivery is supported. See Mobile Number Formatting for details.
The TNZ SMSCLI app is built in Rust for Windows. Contact the TNZ team for alternative Operating Systems.
SMS messages are sent and charged in blocks of characters. One text message is 160 characters. By default, we will limit your message to three-message-parts in length (459 characters using the GSM character set, or 210 characters using Unicode/UCS-2). This can be increased on request. See the SMS Message Parts and Concatenated SMS guide for further information.
");