Flexi API Introduction
The Flexi API accepts a range of inputs and dynamically determines how to process your SMS message.
It is designed to be an ultra simple API integration specifically for SMS so that you can seamlessly redirect your existing endpoints into the TNZ network by simply changing the URL and Authorization header.
The Flexi API has been tested with Twilio, eTXT, mTXT, GroupText, MessageMedia, 3CX and a range of other tools.
Authentication
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.
API v3.00 utilizes JWT token Authentication. For OAuth2 authentication options, contact your TNZ representative.
API basics
This flexible API allows you to send multiple message types. For a brief overview of the API, see the TNZ API Structure guide.
The API URL:
https://flexiapi.tnz.co.nz/api/v3.00/flexi/sms
[Version]is the API Version ('v3.00')[MessageType]is the type of message (currently only 'sms' is supported)
The API HTTP Headers:
The HTTP Headers define the API call's formatting -
Content-Type: application/json
Accept: application/json
Authorization: Bearer [Auth Token]
** The 'Accept' header is optional but encouraged
You can find your Auth Token in the TNZ Dashboard.
The API Body:
The Body contains your message details.
The Flexi API is designed to be flexible! Input any parameters and the API will do its best to match and send your SMS.
{
"to": "+6421000001",
"body": "Hello, this is a test."
}
API - Send SMS
Request:
API URL: https://flexiapi.tnz.co.nz/api/v3.00/flexi/sms
HTTP Method: POST
HTTP Headers:
Content-Type: application/json
Accept: application/json
Authorization: Bearer [Your Auth Token]
{
"to": "+6421000001",
"body": "Hello, this is a test."
}
Response:
200 OK- Message Accepted400 BAD REQUEST- Invalid Variables401 Unauthorized- Invalid Auth Token500 Internal Server Error- API Server Fault
API - Examples
Flexible Parameters
Any of the examples listed below will be ingested by the API.
If variable names are mixed-and-matched, the API will attempt to identify possible variable names merge them into a known schema.
If you require different parameter names, Contact Us and we can review your requirements.
{
"to": "+6421000001",
"from": "+0000",
"body": "Hello, this is a test."
}
{
"to_number": "+6421000001",
"from_number": "+0000",
"message": "Hello, this is a test."
}
{
"mobile": "+6421000001",
"message": "Hello, this is a test."
}
{
"destination": "+6421000001",
"message": "Hello, this is a test."
}
{
"messages": [
{
"destination_number": "+6421000001",
"content": "Hello, this is a test."
}
]
}
{
"destination_number": "+6421000001",
"format": "SMS",
"content": "Hello, this is a test.",
"message_id": "877c19ef-fa2e-4cec-827a-e1df9b5509f7",
"callback_url": "https://www.example.com/webhook"
}
Parameter aliases
Aliases for To:
to |
tonumber |
to_number |
tosms |
to_sms |
tomobile |
to_mobile |
mobile |
mobilenumber |
mobile_number |
handset |
number |
destination |
destinationnumber |
destination_number |
destinationmobile |
recipient |
msisdn |
target |
contact |
receiver |
dst |
Aliases for From:
from |
fromnumber |
from_number |
fromsms |
from_sms |
frommobile |
from_mobile |
source |
sourcenumber |
source_number |
sourcemobile |
Aliases for Message:
message |
message_text |
messagetext |
text |
body |
sms |
content |
Aliases for MessageID:
messageid |
message_id |
message-id |
message_uuid |
message-uuid |
Sid |
MessageSid |
batch_id |
id |
Aliases for WebhookCallbackURL:
WebhookCallbackURL |
callback |
callback-url |
callback_url |
StatusCallback |
status_callback |
Status-Callback |
CallbackData |
notifyUrl |
webhookurl |
webhook_url |
webhook-url |
Frequently Asked Questions
Can messages be sent internationally?
Yes, full international delivery is supported.
Is there a maximum request size?
The maximum request size supported is 20MB. This is our server side limitation. Your client side limitation may be smaller.
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.
Is HTTPS, SSL, or TLS supported?
Yes, encrypted submissions are accepted across the API via HTTPS. SSL/TLS is also supported for outbound email messages provided the receiving email server supports this.