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.
Getting started
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:
- Login to the TNZ Dashboard
- Navigate to 'Users'
- Create a new user or select an existing one
- Enable API access (if it's not already enabled)
- Click on the 'API' tab
- Enable 'Auth Token' and create a new Auth Token
- Click the ' Copy' button to copy it to your clipboard
- 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.
CLI - Send SMS
Call the TNZSMSCLI app from your command line (cmd).
Command syntax
TNZSMSCLI.exe "[Mobile]" "[Message]"
Example
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]"
Responses
Success
Successfully sent [Mobile] the message: [Message]Failure
Failed to send [Error]- Invalid VariablesFailed to send [401 Unauthorized]- Invalid Auth TokenFailed 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.exeSend 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:
- Open Task Scheduler from the Start menu.
- In the Action panel click Create Task.
- Under the General tab, give your task a name (e.g. "Send Reminder SMS").
- Under the Triggers tab, set a trigger (e.g. Daily at 9:00 AM).
- Under the Actions tab, select New, and in the Program/Script box, enter the path to TNZSMSCLI.exe
- 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
Can messages be sent internationally?
Yes, full international delivery is supported. See Mobile Number Formatting for details.
Does this app work with my PC?
The TNZ SMSCLI app is built in Rust for Windows. Contact the TNZ team for alternative Operating Systems.
When I send SMS messages, the text is cut off at 160 characters. Why?
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.