Flexi API v3.00 Oct 2026

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, Detrack 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:

  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.

API v3.00 utilizes JWT token Authentication. For OAuth2 authentication options, contact your TNZ representative.

JSON Body

For applications that send common JSON fields like "to" or "mobile" and "body" or "message".

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."
}

Send SMS

  1. Change your application's current SMS URL to the Flexi API URL.
  2. Add or edit the Authorization header to match TNZ's Auth Token.
  3. Send a test. If the test fails, advise TNZ Support (we'll check the API parameters received).

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 Accepted
  • 400 BAD REQUEST - Invalid Variables
  • 401 Unauthorized - Invalid Auth Token
  • 500 Internal Server Error - API Server Fault

Examples

{
  "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

Fixed Webhook

For applications that send a fixed webhook.

API basics

When the event occurs in your application, it will send a webhook to the TNZ API. TNZ will receive the webhook, populate the [[values]] with data from the webhook, and send your SMS message.

API URL:

https://api.tnz.co.nz/api/v3.00/flexi/header

Use POST with Content-Type: application/json.

API HTTP Headers:

HeaderExampleRequiredExplanation
AuthorizationBearer [Auth Token]YesSee Your Auth Token for export instructions.
X-TNZ-MessageTypeSMSYesSupports "SMS", "Email" and "TTS".
X-TNZ-MessageHi [[name]], your order [[order_number]] is [[status]].YesThe SMS message. TNZ replaces the [[values]] with data from the webhook.
X-TNZ-Destination[[phone_number]]YesThe message recipient (mobile number or email address).
X-TNZ-FromNumber[[from]]NoThe sending SMS number. Omit this header to use the account default. Using an invalid value will cause TNZ to reject the request.

API Body:

Not editable and managed by the application submitting the webhook event. The webhook will contain values which are mapped to the headers using [[values]].

See the placeholder rules for rules around nested fields, arrays and missing values.

Send SMS

  1. Configure a new webhook in your application.
  2. Set the webhook method to POST
  3. Enter the API URL above.
  4. Enter the HTTP headers as specified in the table above.
  5. Send a test.

Example request:

This illustrative delivery event uses a small JSON payload. Replace TEST_MOBILE with a mobile you control before testing. A valid request submits an SMS and normal charges apply.

API URL: https://api.tnz.co.nz/api/v3.00/flexi/header

HTTP Method: POST

HTTP Headers:
Content-Type: application/json
Authorization: Bearer [Your Auth Token]
X-TNZ-MessageType: SMS
X-TNZ-Message: Hi [[name]], your order [[order_number]] is [[status]]
X-TNZ-Destination: [[phone_number]]

{
  "name": "John Doe",
  "order_number": "ORD123",
  "status": "completed",
  "phone_number": "021001234",
  "address": "123 Main Street",
  "items": [
    {
      "description": "Apple", 
      "quantity": 10
    },
    {
      "description": "Banana", 
      "quantity": 2
    }
  ]
}

Rendered SMS:

To: 021001234
Hi John Doe, your order ORD123 is completed.

Response:

  • 200 OK - Message Accepted
  • 400 BAD REQUEST - Invalid Variables. Check headers and placeholders.
  • 401 Unauthorized - Invalid Auth Token. Check Authorization header.
  • 403 FORBIDDEN - Insufficient Permissions. Check SMS permission and authorization for the requested sender.
  • 405 Method Not Allowed - Invalid Method. Check the webhook method is POST.
  • 415 Unsupported Media Type - Invalid Content-Type. Check the webhook is JSON.
  • 422 Unprocessable Entity - Invalid Content. Check the webhook schema is valid.
  • 500 Internal Server Error - API Server Fault

Examples

Use placeholders to personalise your SMS

A placeholder tells TNZ which detail to copy from the application's webhook into the SMS. For example [[order_number]].

When the webhook body is flat, this is quite simple:

Example: Flat Webhook Body
{
  "name": "John Doe",
  "order_number": "ORD123",
  "status": "completed",
  "phone_number": "021001234"
}

Valid placeholders for this webhook are:

  • [[name]]
  • [[order_number]]
  • [[status]]
  • [[phone_number]]

When the webhook body includes nested objects, use a dot to separate the field names:

Example: Nested Object Webhook Body
{
  "name": "John Doe",
  "order_data": {
    "order_number": "ORD123",
    "status": "completed"
  },
  "phone_number": "021001234"
}

Valid placeholders for this webhook are:

  • [[name]]
  • [[order_data.order_number]]
  • [[order_data.status]]
  • [[phone_number]]

When the webhook includes arrays, specify the index of the item to use:

Example: Array Webhook Body
{
  "name": "John Doe",
  "order_number": "ORD123",
  "status": "completed",
  "items": [
    {
      "quantity": 10,
      "description": "Apple"
    },
    {
      "quantity": 3,
      "description": "Banana"
    }
  ],
  "phone_number": "021001234"
}

Valid placeholders for this webhook are:

  • [[name]]
  • [[order_number]]
  • [[status]]
  • [[phone_number]]
  • [[items[0].quantity]] (First item's quantity)
  • [[items[0].description]] (First item's description)
  • [[items[1].quantity]] (Second item's quantity)
  • [[items[1].description]] (Second item's description)

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.