Last updated: June 22th 2023

API Introduction

Use just one API to send Email, SMS, Fax and Voice Calls -

Register your account

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


Create an API user

To access the API, you'll need a User with API access:

  1. Log into the TNZ Dashboard
  2. Select Users from the menu, then click Create to create a new user, or select an existing user from the list.
  3. Under the API Options tab, if API access isn't set up, toggle Enable API, then create an "API Key" (you can click the Generate button to auto-create one), then click Update to save your changes.
  4. Under the API Options tab, next to "Auth Token" click Copy button. This will copy your Auth Token to your clipboard.

The API v2.03 uses JWT token Authentication. Contact your TNZ Representative for OAuth2 authentication.

You can use one Auth Token for multiple use-cases, using the SubAccount and Department values to track reporting and billing.


Understanding the 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://api.tnz.co.nz/api/[Version]/[Action]/[MessageType]


  • [Version] is the API Version ('v2.03')
  • [Action] defines the module ('send' a message or 'get' a status)
  • [MessageType] is the type of message ('email', 'sms', 'fax', etc.)


The API HTTP Headers:

The HTTP Headers define the API call's formatting -


> Headers for JSON formatted calls:

Content-Type="application/json; encoding='utf-8'"
Accept="application/json; encoding='utf-8'"
Authorization="Basic [Auth Token]"

** The 'Accept' header is optional but encouraged


> Headers for XML formatted calls:

Content-Type="application/xml; encoding='utf-8'"
Accept="application/xml; encoding='utf-8'"
Authorization="Basic [Auth Token]"

** Both 'Content-Type' and 'Accept' headers are mandatory



An API Send Example

An example for sending an outbound SMS using Raw JSON -

URL:
- https://api.tnz.co.nz/api/v2.03/send/sms

Headers:
- Content-Type="application/json; encoding='utf-8'"
- Accept="application/json; encoding='utf-8'"
- Authorization="Basic eyJ0eXA....436k0-E4"

Data:
{
"MessageData" : {
  "Message": "Hello, this is a test.",
  "Destinations" : [ { "Recipient": "+6421000001" } ]
  }
}


Possible HTTP status values are:

  • 200 OK - Message Accepted
  • 400 BAD REQUEST - Invalid Variables
  • 401 Unauthorized - Invalid Auth Token
  • 500 Internal Server Error - API Server Fault

An example JSON response value:

  • {
      "Result": "%STATUS%",
      "MessageID": "%MESSAGEID%"
    }
  • Status - 'Success' or 'Failed' refers to your API POST result (explains whether your POST was accepted by our server). This is not your message's delivery result - to track message delivery, see API - Status Reporting.
  • MessageID - A message tracking identifier (maximum 40 characters, alphanumeric). If you do not supply this field in your submitted MessageData, the API will return one for you in the response body (UUID v4 of 36 characters).
  • Note - The API will verify that required fields are supplied, however it will not validate data. See TNZ API Errors for error descriptions.

API - Send Messages

Find instructions for each Message Type:

HTTP Method: POST

Sending Email - Send Email via REST API

 
 
API URL:        https://api.tnz.co.nz/api/v2.03/send/email
HTTP Method:    POST

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required MessageData parameters

Parameter Example Value Description
EmailSubject Test Email Subject Subject field used in the email
SMTPFrom noreply@example.com Sets the email Sender/Return-Path at the SMTP level (this address receives bounce-back emails and is used for SPF/DKIM type authentication; 'FromEmail' is used if not specified)
From noreply Sets the email sender's Friendly Name (seen by the email recipient)
FromEmail noreply@example.com Sets the email sender's Email Address (seen by the email recipient; API 'Sender' is used if not specified)
CCEmail archives@example.com Adds a CC to the email
ReplyTo reply@example.com Adds a Reply-To to the email (if the recipient replies, the Reply To will receive the reply)
MessagePlain Hello,

This is a test message.

Thank you.
Content used for the message/plain section of the email (overrides 'Template')
Destinations > Recipient john.doe@example.com
recipient.three@example.com
recipient.four@example.com
Email address(es) to receive the message (for detailed formatting, see the Destinations parameter below)

Optional MessageData parameters

Parameter Example Value Description
MessageID ID123456 A Message Identifier helps you keep track of each message (maximum 40 characters, alphanumeric). Use a unique MessageID for each request. If you leave this field blank, the API will generate a 36-character UUID (v4) for you and include it in the response body.
Reference Test1 Human readable message description (free format field, maximum 80 characters).
WebhookCallbackURL https://www.example.com/webhook Overrides your Sender's default Webhook URL. Requires a default webhook to be configured. A full path including https:// is required.
WebhookCallbackFormat JSON Overrides your Sender's default Webhook format ('JSON' or 'XML')
SendTime 2022-12-31T23:00 Delay sending until the specified date/time, a single point of time in a combined date and time representation ({date}T{time}; for example, 2022-08-29T04:00 in your local timezone, specified by your Sender setting or overridden using the TimeZone command).
TimeZone New Zealand User's local timezone (see Setting Timezones)
SubAccount SubAccount01 Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section.
Department Department01 Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section.
ChargeCode BillingGroup01 Bespoke app cost allocation code (for invoice segmentation)
TemplateLocation Folder 01 Directory/location of Template to use
Template Template File Name Preloaded Template to use for email body (overridden by MessagePlain and/or MessageHTML parameters)
MessageHTML <html>Hello,<br /><br />This is a test message.<br /><br />Thank you.</html> Content used for the message/html section of the email (overrides 'Template' and 'MessagePlain')
Destinations > Recipient john.doe@example.com Recipient of the email
> Attention John Doe Recipient's name
> First Name John Recipient's first name
> Last Name Doe Recipient's last name
> Company Example Corp Recipient's company
> Custom1 Reference Number ABC123 Customisable tracking and personalisation field
> Custom2 Reference Code WWW222 Customisable tracking and personalisation field
Files > Name Sample.pdf Attachment's filename
> Data %%Base-64%% Base-64 encoded value of the attached file
HTTP Method: POST

Sending SMS - Send SMS/TXT via REST API

 
 
API URL:        https://api.tnz.co.nz/api/v2.03/send/sms
HTTP Method:    POST

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required MessageData parameters

Parameter Example Value Description
Message Hello, this is a test message from Department01. Thank you. Plain or UTF-8 formatted SMS message
Destinations > Recipient +6421000002 Receiving mobile number. See the Destinations parameter below for more information.

Optional MessageData parameters

Parameter Example Value Description
MessageID ID123456 A Message Identifier helps you keep track of each message (maximum 40 characters, alphanumeric). Use a unique MessageID for each request. If you leave this field blank, the API will generate a 36-character UUID (v4) for you and include it in the response body.
Reference Test1 Human readable message description (free format field, maximum 80 characters).
WebhookCallbackURL https://www.example.com/webhook Overrides your Sender's default Webhook URL. Requires a default webhook to be configured. A full path including https:// is required.
WebhookCallbackFormat JSON Overrides your Sender's default Webhook format ('JSON' or 'XML')
SendTime 2021-12-31T23:00 Delay sending until the specified date/time, a single point of time in a combined date and time representation ({date}T{time}; for example, 2017-08-29T04:00 in your local timezone, specified by your Sender setting or overridden using the TimeZone command).
TimeZone New Zealand User's local timezone (see Setting Timezones)
SubAccount SubAccount01 Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section.
Department Department01 Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section.
ChargeCode BillingGroup01 Bespoke app cost allocation code (for invoice segmentation)
FromNumber 6421000001 Setting SMS origination number, short code(s) will override in New Zealand - Not for New Zealand.
SMSEmailReply person.one@domain.com For email (SMTP) reply receipt notifications
CharacterConversion true Convert multi-byte characters into normalised GSM character format. ie. © to (C)
Message Hello, view the link at [[Link:https://www.example.com/path/to/page.html]] or view the file at [[File1]] or reply at [[REPLY]] or OptOut at [[STOP]] An example Message that uses the URL Shortener, File Link, Reply Link and Unsubscribe functions
Destinations > Recipient +6421000001 Recipient of the SMS. See number formatting for more information.

We recommend implementing a prefix check to limit potential Toll Fraud.
> Attention John Doe Recipient's name
> First Name John Recipient's first name
> Last Name Doe Recipient's last name
> Company Example Corp Recipient's company
> Custom1 Customisable tracking and personalisation field
> Custom2 Customisable tracking and personalisation field
Files > Name File Name.pdf Files referenced in [[File1]] commands (for MessageLink)
> Data %%Base-64%% Base-64 encoded value of the attached file
HTTP Method: POST

Sending Faxes - Send Fax via REST API

 
 
API URL:        https://api.tnz.co.nz/api/v2.03/send/fax
HTTP Method:    POST

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required MessageData parameters

Parameter Example Value Description
Destinations > Recipient +6495005001 Receiving fax number. See the Destinations parameter below for more information.
Files > Name Sample.pdf Fax document's filename
> Data %%Base-64%% Base-64 encoded value of the document

Optional MessageData parameters

Parameter Example Value Description
MessageID ID123456 A Message Identifier helps you keep track of each message (maximum 40 characters, alphanumeric). Use a unique MessageID for each request. If you leave this field blank, the API will generate a 36-character UUID (v4) for you and include it in the response body.
Reference Test1 Human readable message description (free format field, maximum 80 characters).
WebhookCallbackURL https://www.example.com/webhook Overrides your Sender's default Webhook URL. Requires a default webhook to be configured. A full path including https:// is required.
WebhookCallbackFormat JSON Overrides your Sender's default Webhook format ('JSON' or 'XML')
SendTime 2022-12-31T23:00 Delay sending until the specified date/time, a single point of time in a combined date and time representation ({date}T{time}; for example, 2022-08-29T04:00 in your local timezone, specified by your Sender setting or overridden using the TimeZone command).
TimeZone New Zealand User's local timezone (see Setting Timezones)
SubAccount SubAccount01 Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section.
Department Department01 Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section.
ChargeCode BillingGroup01 Bespoke app cost allocation code (for invoice segmentation)
WatermarkFolder Folder01 Directory/location of Watermark file to use
WatermarkFirstPage Watermark File Name Watermark file to apply to the first page only
WatermarkAllPages Watermark File Name Watermark file to apply to all pages
Resolution High Quality of the fax image. High for better quality, low for lower quality (faster delivery speed)
CSID Station ID Called Subscriber Identification - Maximum 30 characters
Destinations > Recipient +6495005000 Recipient of the Fax. See number formatting for more information.

We recommend implementing a prefix check to limit potential Toll Fraud.
> Attention John Doe Recipient's name
> First Name John Recipient's first name
> Last Name Doe Recipient's last name
> Company Example Corp Recipient's company
> Custom1 Customisable tracking and personalisation field
> Custom2 Customisable tracking and personalisation field
HTTP Method: POST

Sending Voice (Voicemail) - Send VoiceCast via REST API

 
 
API URL:        https://api.tnz.co.nz/api/v2.03/send/voice
HTTP Method:    POST

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required MessageData parameters

Parameter Example Value Description
MessageToPeople [Base64 encoded data] The audio data played if the call is answered by a human (WAV format, 16-bit, 8000hz)
Destinations > Recipient +6495005001 Receiving telephone number. See the Destinations parameter below for more information.

Optional MessageData parameters

Parameter Example Value Description
MessageID ID123456 A Message Identifier helps you keep track of each message (maximum 40 characters, alphanumeric). Use a unique MessageID for each request. If you leave this field blank, the API will generate a 36-character UUID (v4) for you and include it in the response body.
Reference Test1 Human readable message description (free format field, maximum 80 characters).
WebhookCallbackURL https://www.example.com/webhook Overrides your Sender's default Webhook URL. Requires a default webhook to be configured. A full path including https:// is required.
WebhookCallbackFormat JSON Overrides your Sender's default Webhook format ('JSON' or 'XML')
SendTime 2021-12-31T23:00 Delay sending until the specified date/time, a single point of time in a combined date and time representation ({date}T{time}; for example, 2017-08-29T04:00 in your local timezone, specified by your Sender setting or overridden using the TimeZone command).
TimeZone New Zealand User's local timezone (see Setting Timezones)
SubAccount SubAccount01 Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section.
Department Department01 Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section.
ChargeCode BillingGroup01 Bespoke app cost allocation code (for invoice segmentation)
ReportTo report@example.com For email (SMTP) message delivery report notifications.
MessageToAnswerphones [Base64 encoded data] The audio data played when the call is answered by an answering machine/voicemail service (WAV format, 16-bit, 8000hz)
Keypads > Tone 1 Keypad for call connection (supports buttons 1-9)
> RouteNumber +64800123123 Connects the callee to the specified number (number must be in E164 format)
> Play [Base64 encoded data] Audio data played to B-Party when a keypad option is pressed (WAV format, 16-bit, 8000hz), eg "Thank you. You have pressed keypad 1."
> PlaySection Main Plays the MessageToPeople ('Main') or MessageToAnswerphones ('AnswerPhone'). Useful for replaying the message
KeypadOptionRequired BETA true Requires the callee presses a keypad option. If no keypad button is pressed, the call is marked as a failure (and the call is eligible for automated retrying)
CallRouteMessageToPeople [Base64 encoded data] Audio data played when a keypad option is pressed (WAV format, 16-bit, 8000hz), eg "Connecting you now."
CallRouteMessageToOperators [Base64 encoded data] Audio data played to the call centre representative answering the connected call (WAV format, 16-bit, 8000hz), eg "Incoming Text To Speech call."
CallRouteMessageOnWrongKey [Base64 encoded data] Audio data played when an unregistered keypad button is pressed (WAV format, 16-bit, 8000hz), eg "Sorry, you have pressed an invalid key. Please try again"
NumberOfOperators 5 Limits the maximum simultaneous calls (where multiple 'Destinations' are listed). Set 99999 for max throughput
RetryAttempts 3 Number of retry attempts if the call fails (for example, the recipients line is busy or unavailable). If an Alt Phone is specified, the contact's Main Phone will be attempted until RetryAttempts is exhausted, then the Alt Phone will be tried.
RetryPeriod 1 Minutes apart when performing retries
CallerID +6495005000 Sets the Caller ID used on the call (must be E.164 format and previously whitelisted under your account)
Options Customisable field that allows advanced voice options including recording survey responses, recording phone numbers, playing IVR options, capturing DTMF tones for account numbers or credit card numbers, etc.
Destinations > Recipient +6495005000 Recipient of the call. See number formatting for more information.

We recommend implementing a prefix check to limit potential Toll Fraud.
> Attention John Doe Recipient's name
> First Name John Recipient's first name
> Last Name Doe Recipient's last name
> Company Example Corp Recipient's company
> Custom1 Customisable tracking and personalisation field
> Custom2 Customisable tracking and personalisation field
HTTP Method: POST

Sending Voice Text To Speech - Send TTS via REST API

 
 
API URL:        https://api.tnz.co.nz/api/v2.03/send/tts
HTTP Method:    POST

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required MessageData parameters

Parameter Example Value Description
MessageToPeople Hello, this is a call from Department01. This is relevant information. Press one to be connected to our call centre. The text-to-speech message played if the call is answered by a human (may optionally include SSML commands)
Destinations > Recipient +6495005001 Receiving telephone number. See the Destinations parameter below for more information.

Optional MessageData parameters

Parameter Example Value Description
MessageID ID123456 A Message Identifier helps you keep track of each message (maximum 40 characters, alphanumeric). Use a unique MessageID for each request. If you leave this field blank, the API will generate a 36-character UUID (v4) for you and include it in the response body.
Reference Test1 Human readable message description (free format field, maximum 80 characters).
WebhookCallbackURL https://www.example.com/webhook Overrides your Sender's default Webhook URL. Requires a default webhook to be configured. A full path including https:// is required.
WebhookCallbackFormat JSON Overrides your Sender's default Webhook format ('JSON' or 'XML')
SendTime 2021-12-31T23:00 Delay sending until the specified date/time, a single point of time in a combined date and time representation ({date}T{time}; for example, 2017-08-29T04:00 in your local timezone, specified by your Sender setting or overridden using the TimeZone command).
TimeZone New Zealand User's local timezone (see Setting Timezones)
SubAccount SubAccount01 Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section.
Department Department01 Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section.
ChargeCode BillingGroup01 Bespoke app cost allocation code (for invoice segmentation)
ReportTo report@example.com For email (SMTP) message delivery report notifications.
MessageToAnswerphones Hello, sorry we missed you. This is a call from Department 01. Please contact us on 0800 123123. The text-to-speech message played when the call is answered by an answering machine/voicemail service (may optionally include SSML commands)
Keypads > Tone 1 Keypad for call connection (supports buttons 1-9)
> RouteNumber +64800123123 Connects the callee to the specified number (number must be in E164 format)
> Play You pressed Keypad 1 Message played to B-Party when a keypad option is pressed
> PlaySection Main Plays the MessageToPeople ('Main') or MessageToAnswerphones ('AnswerPhone'). Useful for replaying the message
KeypadOptionRequired BETA true Requires the callee presses a keypad option. If no keypad button is pressed, the call is marked as a failure (and the call is eligible for automated retrying)
CallRouteMessageToPeople Connecting you now. Text-to-speech message played when a keypad option is pressed
CallRouteMessageToOperators Incoming Text To Speech call. Text-to-speech message played to the call centre representative answering the connected call
CallRouteMessageOnWrongKey Sorry, you have pressed an invalid key. Please try again. Text-to-speech message played when an unregistered keypad button is pressed
NumberOfOperators 5 Limits the maximum simultaneous calls (where multiple 'Destinations' are listed). Set 99999 for max throughput
RetryAttempts 3 Number of retry attempts if the call fails (for example, the recipients line is busy or unavailable). If an Alt Phone is specified, the contact's Main Phone will be attempted until RetryAttempts is exhausted, then the Alt Phone will be tried.
RetryPeriod 1 Minutes apart when performing retries
CallerID +6495005000 Sets the Caller ID used on the call (must be E.164 format and previously whitelisted under your account)
Voice Female1 Text-to-Speech voice to use (Male1, Female1, Nicole, Russell, Amy, Brian, Emma)
Options Customisable field that allows advanced voice options including recording survey responses, recording phone numbers, playing IVR options, capturing DTMF tones for account numbers or credit card numbers, etc.
Destinations > Recipient +6495005000 Recipient of the call. See number formatting for more information.

We recommend implementing a prefix check to limit potential Toll Fraud.
> Attention John Doe Recipient's name
> First Name John Recipient's first name
> Last Name Doe Recipient's last name
> Company Example Corp Recipient's company
> Custom1 Customisable tracking and personalisation field
> Custom2 Customisable tracking and personalisation field

Sending messages in test mode

Under MessageData you can specify an additional Mode=Test parameter.

Mode=Test means any messages will be handled by the API, instantly called a SUCCESS and the success report will be delivered to you. This is a useful way to end-to-end test without sending a live message.


...
  "MessageData" :
  {
      ...
      "Mode": "Test"
  }
...
                                            
HTTP Method: PATCH

API - Edit Messages - Edit a submitted message

Once a message has been sent, you can retry a failed message, reschedule a delayed message, abort a delayed message and edit the NumberOfOperators value on Voice/TTS messages.


Retry Sending - Resubmit a failed message

If your message is 'Failed' (sending completed and was unsuccessful), you can use this API module to retry sending.

The Retry is applied to a specific MessageID. If you use common MessageID values across multiple messages, it will apply to the most recent message and only if the Status was Failed.


 
API URL:        https://api.tnz.co.nz/api/v2.03/set/resubmit/[MessageID]
HTTP Method:    PATCH

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required parameters

Parameter Example Value Description
MessageID ID123456 MessageID the Action should apply to
SendTime (Optional) 2021-12-31T23:00 Delay sending until the specified date/time, a single point of time in a combined date and time representation ({date}T{time}; for example, 2022-08-29T04:00 in your local timezone, specified by your Sender setting or overridden using the TimeZone command).

SUCCESS response parameters

Parameter Example Value Description
Result Success Result of your API call (not the result of the message)
MessageID ID123456 MessageID the Action was applied to
Status Transmit State of the message prior to performing the Action ('Transmit', 'Pending', 'Delayed', 'CreditHold', 'Deleted')
JobNum ABCD1234 Eight digit alphanumeric tracking number (our internal Job Number)
Action Resubmit The Action performed

FAILED response parameters

Parameter Example Value Description
Result Failed Result of your API call (not the result of the message)
MessageID ID123456 MessageID provided in your request
Message Message not found Reason for the API call failure (see a list of possible values: TNZ API Errors)



HTTP Method: PATCH

Reschedule Sending - Adjust the Delayed Sending Date/Time

If you have an existing Delayed message (scheduled for sending at a future date/time), you can use this API module to adjust the sending date/time.

The adjustment is applied to a specific MessageID. If you use common MessageID values across multiple messages, it will apply to the most recent message.


 
API URL:        https://api.tnz.co.nz/api/v2.03/set/reschedule/[MessageID]
HTTP Method:    PATCH

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required parameters

Parameter Example Value Description
MessageID ID123456 MessageID the Action should apply to
SendTime 2021-12-31T23:00 Reschedule sending for the specified date/time, a single point of time in a combined date and time representation ({date}T{time}; for example, 2017-08-29T04:00 in your local timezone, specified by your Sender setting or overridden using the TimeZone command).

SUCCESS response parameters

Parameter Example Value Description
Result Success Result of your API call (not the result of the message)
MessageID ID123456 MessageID the Action was applied to
Status Transmit State of the message prior to performing the Action ('Transmit', 'Pending', 'Delayed', 'CreditHold', 'Deleted')
JobNum ABCD1234 Eight digit alphanumeric tracking number (our internal Job Number)
Action Reschedule The Action performed

FAILED response parameters

Parameter Example Value Description
Result Failed Result of your API call (not the result of the message)
MessageID ID123456 MessageID provided in your request
Message Message not found Reason for the API call failure (see a list of possible values: TNZ API Errors)



HTTP Method: PATCH

Abort Sending - Cancel/Delete a Message from the Queue

If you have an existing Delayed message (scheduled for sending at a future date/time) you can use this API module to Cancel sending of the message.

The cancellation is applied to a specific MessageID. If you use common MessageID values across multiple messages, it will apply to the most recent message.


 
API URL:        https://api.tnz.co.nz/api/v2.03/set/abort/[MessageID]
HTTP Method:    PATCH

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required parameters

Parameter Example Value Description
MessageID ID123456 MessageID the Action should apply to

SUCCESS response parameters

Parameter Example Value Description
Result Success Result of your API call (not the result of the message)
MessageID ID123456 MessageID the Action was applied to
Status Delayed State of the message prior to performing the Action ('Transmit', 'Pending', 'Delayed', 'CreditHold', 'Deleted')
JobNum ABCD1234 Eight digit alphanumeric tracking number (our internal Job Number)
Action Abort The Action performed

FAILED response parameters

Parameter Example Value Description
Result Failed Result of your API call (not the result of the message)
MessageID ID123456 MessageID provided in your request
Message Message not found Reason for the API call failure (see a list of possible values: TNZ API Errors)



HTTP Method: PATCH

Adjust NumberOfOperators - Change the Voice/Text-to-Speech NumberOfOperators Value

When sending a Voice/Text-to-Speech message, you may specify the NumberOfOperators value (limits the quantity of simultaneous/concurrent calls). You can use this API module to adjust the NumberOfOperators value in real-time.

The cancellation is applied to a specific MessageID. If you use common MessageID values across multiple messages, it will apply to the most recent message.


 
API URL:        https://api.tnz.co.nz/api/v2.03/set/pacing/[MessageID]
HTTP Method:    PATCH

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required parameters

Parameter Example Value Description
MessageID ID123456 MessageID the Action should apply to
NumberOfOperators 4 NumberOfOperators value to apply

SUCCESS response parameters

Parameter Example Value Description
Result Success Result of your API call (not the result of the message)
MessageID ID123456 MessageID the Action was applied to
Status Pending State of the message prior to performing the Action ('Transmit', 'Pending', 'Delayed', 'CreditHold', 'Deleted')
JobNum ABCD1234 Eight digit alphanumeric tracking number (our internal Job Number)
Action NumberOfOperators The Action performed

FAILED response parameters

Parameter Example Value Description
Result Failed Result of your API call (not the result of the message)
MessageID ID123456 MessageID provided in your request
Message Message not found Reason for the API call failure (see a list of possible values: TNZ API Errors)

API - Status Reporting - Reporting and event tracking

Delivery Reports advise whether delivery was successful. If not, it will describe why.

Each delivery report type is optional and multiple delivery report types can be used.



Web Dashboard - Tracking message statuses via the online dashboard

You will be supplied with a Web Dashboard login at registration. The Dashboard can be used to set up new sender/token pairs, as well as track sent and replied messages. You can drill into specific messages to view individual events, such as delivery attempts, retries, replies, results, clicks, etc.



SMTP Email - Receive message statuses via email

Delivery reports are emailed as an HTML email for viewing by an end-user. Your sales representative can enable this for you.

Whitelabelling of SMTP Email reports is available.



HTTP Method: POST

Webhook - Message statuses delivered via a webhook

To receive Delivery Reports via Webhook, please advise the URL to submit to.

Webhooks are delivered as an HTTP POST in either XML or JSON format (your preference; defined by the WebhookCallbackFormat in your outbound message).

Webhook failures are retried every five minutes for a maximum of 24 hours.


 
 
API URL:        https://www.example.com/webhook
HTTP Method:    POST
HTTP Headers:   Content-Type="application/json"

{
  "Sender": "application@domain.com",
  "APIKey": "ta8wr7ymd",
  "Type": "SMS",
  "Destination": "+6421000001",
  "MessageID": "js82hn8n",
  "SubAccount": "SubAccount01",
  "Department": "Department01",
  "JobNumber": "10C7B9A0",
  "SentTime": "16/10/2019 13:43 p.m.",
  "Status": "SUCCESS",
  "Result": "delivered",
  "Price": "0.10",
  "Detail": "SMSParts:1",
  "URL": "https://www.example.com/webhook",
  "RESPONSEMODE": "JSON"
}          

Copy code

API URL:        https://www.example.com/webhook
HTTP Method:    POST
HTTP Headers:   Content-Type="text/xml"

<?xml version='1.0' encoding='UTF-8'?>
<root>
  <Sender>application@domain.com</Sender>
  <APIKey>ta8wr7ymd</APIKey>
  <Type>SMS</Type>
  <Destination>+6421000001</Destination>
  <MessageID>js82hn8n</MessageID>
  <SubAccount>SubAccount01</SubAccount>
  <Department>Department01</Department>
  <JobNumber>10C7B9A0</JobNumber>
  <SentTime>2019-10-16 14:52 p.m.</SentTime>
  <Status>SUCCESS</Status>
  <Result>delivered</Result>
  <Price>0.10</Price>
  <Detail>SMSParts:1</Detail>
  <URL>https://www.example.com/webhook</URL>
  <RESPONSEMODE>XML</RESPONSEMODE>
</root>          

Copy code

Parameters:

Parameter Example Value Description
Destination +6421000001 Destination that the webhook is for (alphanumeric field, where telephone/mobile numbers are supplied in E.164 internationalised format)
MessageID js82hn8n MessageID parameter supplied when sending your original API call
SubAccount SubAccount01 Used for reporting, billing and Web Dashboard segmentation
Department Department01 Used for reporting, billing and Web Dashboard segmentation
JobNumber 10C7B9A0 Eight digit alphanumeric tracking number (our internal Job Number)
SentTime 16/10/2019 13:43 p.m. Time message was completed (Sender's local time time in 'dd/MM/yyyy HH:mm tt' format)
Status SUCCESS For submission results, values are SUCCESS, FAILED, PENDING
For reply reports, this will be RECEIVED
For additional analytics, this will be UPDATED
Result Sent OK Final delivery result and/or the cause for a message delivery failure
For a list of possible values, see SMS, Fax, Voice, TextToSpeech
Email result codes are defined by the receiving email server
For reply reports, this will be RECEIVED
For additional analytics, this will be the event description
Price 0.20 Your cost for this transaction, charged by us to you
Detail SMSParts:2 Additional billing detail: "SMSParts", "FaxPages", "VoiceMinutes", "Size", "Prompts"
URL https://www.example.com/webhook The URL this webhook is sent to
RESPONSEMODE JSON This webhook's format


HTTP Method: GET

GET Status Poll - Track message statuses using a GET poll

API users are able to poll for the status of a message via the GET Status API.

The GET Poll should be configured to timeout after 48 hours with no result.


 
 
API URL:        https://api.tnz.co.nz/api/v2.03/get/status/[MessageID]
HTTP Method:    GET

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required parameters

Parameter Example Value Description
MessageID ID123456 Your provided Message ID or TNZ Group generated Message ID

Success Response parameters

Parameter Example Value Description
Result Success Result of your API call (not the result of the message)
MessageID AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD Your provided Message ID or TNZ Group generated Message ID
Status Completed Current state of the message ('Unknown', 'Pending', 'Delayed', 'Completed', 'CreditHold')
JobNum 10AB20CE Eight digit alphanumeric tracking number (our internal Job Number)
Account 102030 Your TNZ Account
SubAccount Your supplied TNZ SubAccount
Department Your supplied TNZ Department
Count 5 Total Destinations specified in the message
Complete 5 Total Destinations where message transmission has completed
Success 4 Total Destinations where message result is Success
Failed 1 Total Destinations where message result is Failed

Failed Response parameters

Parameter Example Value Description
Result Failed Result of your API call (not the result of the message)
MessageID AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD Your provided Message ID or TNZ Group generated Message ID
Message Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

API - Receive Messages - Track messages received

Currently, tracking SMS Received is supported.

Tracking of faxes and voicemail received is scheduled for a future release. Let your account manager know if this interests you.



Web Dashboard - Tracking messages received via the online dashboard

You will be supplied with a Web Dashboard login at registration. The Dashboard can be used to set up new sender/token pairs, as well as track sent and replied messages. You can drill into specific messages to view individual events, such as delivery attempts, retries, replies, results, clicks, etc.



SMTP Email - Track messages received via email

Reply message reports are emailed as an HTML email for viewing by an end-user.
Whitelabelling of SMTP Email reports is available.

When submitting SMS messages, specify the SMSEmailReply parameter.



Webhook - Messages received data delivered via a webhook

If you are set up to receive Status webhooks, you will also be receiving SMS Received webhooks.

To receive SMS replies via Webhook, please advise the URL to submit to.

Webhooks are delivered as an HTTP POST in either XML or JSON format (your preference; defined by the WebhookCallbackFormat in your outbound message).

Webhook failures are retried every five minutes for a maximum of 24 hours.

The mobile has 7 days to reply to a message. Any replies received after the 7 day window will be treated as a new message.


 
 
API URL:        https://www.example.com/webhook
HTTP Method:    POST
HTTP Headers:   Content-Type="application/json"

{
  "Sender": "application@domain.com",
  "APIKey": "ta8wr7ymd",
  "Type": "SMSReply",
  "Destination": "+6421000001",
  "MessageID": "js82hn8n",
  "SubAccount": "SubAccount01",
  "Department": "Department01",
  "JobNumber": "10C7B9A0",
  "SentTime": "2019-10-16 13:43:00",
  "Status": "RECEIVED",
  "Result": "RECEIVED",
  "Message": "This is a reply.",
  "Price": "",
  "Detail": "",
  "URL": "https://www.example.com/webhook",
  "RESPONSEMODE": "JSON"
}          

Copy code

API URL:        https://www.example.com/webhook
HTTP Method:    POST
HTTP Headers:   Content-Type="text/xml"

<?xml version="1.0" encoding="UTF-8" ?>
<root>
  <Sender>application@domain.com</Sender>
  <APIKey>ta8wr7ymd</APIKey>
  <Type>SMSReply</Type>
  <Destination>+6421000001</Destination>
  <MessageID>js82hn8n</MessageID>
  <SubAccount>SubAccount01</SubAccount>
  <Department>Department01</Department>
  <JobNumber>10C7B9A0</JobNumber>
  <SentTime>2019-10-16 13:43</SentTime>
  <Status>RECEIVED</Status>
  <Result>RECEIVED</Result>
  <Message>This is a reply.</Message>
  <Price></Price>
  <Detail></Detail>
  <URL>https://www.example.com/webhook</URL>
  <RESPONSEMODE>XML</RESPONSEMODE>
</root>          

Copy code

Parameters:

Parameter Example Value Description
Sender application@domain.com Webhook sender authentication (can configure a unique Sender if required)
APIKey ta8wr7ymd Webhook token authentication (can configure a unique APIKey if required)
Type SMSReply Type of Message ('Email', 'SMS', 'Fax', 'Voice', 'TextToSpeech', 'SMSInbound' or 'SMSReply')
Destination +6421000001 Mobile number that sent the SMS (alphanumeric field, where telephone/mobile numbers are supplied in E.164 internationalised format)
MessageID js82hn8n MessageID parameter supplied when sending your original API call
SubAccount SubAccount01 Used for reporting, billing and Web Dashboard segmentation
Department Department01 Used for reporting, billing and Web Dashboard segmentation
JobNumber 10C7B9A0 Eight digit alphanumeric tracking number (our internal Job Number)
SentTime 16/10/2019 13:43 p.m. Time reply message was received
Status RECEIVED For submission results, values are SUCCESS, FAILED, PENDING
For reply reports, this will be RECEIVED
For additional analytics, this will be UPDATED
Result RECEIVED Final delivery result and/or the cause for a message delivery failure
For reply reports, this will be RECEIVED
For additional analytics, this will be the event description
Message This is a reply. The received SMS message (if 'Type=SMSInbound' or 'Type=SMSReply')
Price 0.20 Your cost for the outbound message sent, charged by us to you (no cost for the reply received)
Detail SMSParts:2 Additional billing detail: "SMSParts", "FaxPages", "VoiceMinutes", "Size", "Prompts" on the outbound message sent (not the SMS Received)
URL https://www.example.com/webhook The URL this webhook is sent to
RESPONSEMODE JSON This webhook's format


HTTP Method: GET

GET SMS Received Poll - View all Inbound SMS using a GET poll

API users are able to poll for all received SMS messages in a given time-frame.


 
 
API URL:        https://api.tnz.co.nz/api/v2.03/get/sms/received?timePeriod=[minutes]
URL Parameters: timePeriod=[minuts] //optional
  dateFrom=[From Date] //optional
  dateTo=[To Date] //optional
  page=[Page Number] //optional
  recordsPerPage=[No. of Records Per Page] //optional
HTTP Method:    GET

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

URL parameters

Parameter Example Value Description
TimePeriod 1440 Return results from the last x minutes
dateFrom 2022-08-01T00:00:00 Return results from the specified date (optional)
dateTo 2022-08-01T23:59:59 Return results to the specified date (optional)
recordsPerPage 20 Return x number of records per request (optional)
page 1 Current location of the result set (optional)

SUCCESS Response parameters

Parameter Example Value Description
Result Success Result of your API call (not the result of the message)
Date 2019-12-01 14:02:03 Date/Time SMS was received (yyyy-mm-dd HH:mm:ss)
From +6421000001 Sender of the SMS in E.164 internationalised format
MessageText This is a reply back from the mobile phone. The SMS message received

FAILED Response parameters

Parameter Example Value Description
Result Failed Result of your API call (not the result of the message)
Message Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)


HTTP Method: PATCH

GET SMS Reply Poll - Track individual reply SMS messages using a GET poll

API users are able to poll for replies to a specific SMS message, tracked using the MessageID on the outbound message.

The GET Poll should be configured to timeout after 48 hours with no result.


 
 
API URL:        https://api.tnz.co.nz/api/v2.03/get/sms/reply/[MessageID]
HTTP Method:    GET

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required URL parameters

Parameter Example Value Description
MessageID ID123456 Your provided Message ID or TNZ Group generated Message ID

Success Response parameters

Parameter Example Value Description
Result Success Result of your API call (not the result of the message)
Status Received Static value
JobNum 10AB20CE Eight digit alphanumeric tracking number (our internal Job Number)
Account 102030 Your TNZ Account
SubAccount Your supplied TNZ SubAccount
Department Your supplied TNZ Department
MessageSent Date 2019-12-01 13:45:54 Time SMS was sent (yyyy-mm-dd HH:mm:ss)
Destination 6421000001 Recipient of the SMS in E.164 internationalised format
MessageText This is an outbound message sent via API. Plain or UTF-8 formatted SMS message sent
MessageReceived Date 2019-12-01 14:02:03 Time SMS was received (yyyy-mm-dd HH:mm:ss)
From +6421000001 Sender of the SMS in E.164 internationalised format
MessageText This is a reply back from the mobile phone. Plain or UTF-8 formatted SMS message received

Failed Response parameters

Parameter Example Value Description
Result Failed Result of your API call (not the result of the message)
MessageID AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD Your provided Message ID or TNZ Group generated Message ID
Message Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

HTTP Method: GET

List Contacts- Get Contact List via REST API

 
API URL:        https://api.tnz.co.nz/api/v2.03/addressbook/contact/list
URL Parameters: page=[Page Number] //optional
  recordsPerPage=[No. of Records Per Page] //optional
HTTP Method:    GET

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Optional URL Parameters

Parameter Example Value Description
recordsPerPage 50 Specifies the number of records per page to be returned. If not provided, the default number (100) of records per page will be used.
page 1 Specifies the page number of the contact list to retrieve. If not provided, the default (1) behaviour will be followed.
HTTP Method: GET

Get Contact Detail- Get Contact Detail via REST API

 
API URL:        https://api.tnz.co.nz/api/v2.03/addressbook/contact/[ContactID]
HTTP Method:    GET

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required URL parameters

Parameter Example Value Description
ContactID 17f2b37e-4706-41c8-8dcb-de90e24c2447 Specifies the unique identifier of the contact to retrieve.
HTTP Method: POST

Create Contact - Create Contact via REST API

 
API URL:        https://api.tnz.co.nz/api/v2.03/addressbook/contact
HTTP Method:    POST

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Optional Request Body Properties

Property Example Value Description
ViewBy Account Specifies the visibility of the contact. Values can be "Account", "SubAccount", "Department" or "No" visibility option.
EditBy Account Specifies the permission level required to edit the contact. Values can be "Account", "SubAccount", "Department" or "No" permission option.
Attention Person Attention Indicates the attention or focus associated with the contact.
Title Ms Represents the title or honorific of the contact (e.g., Mr, Mrs, Ms).
Company TNZ Group LTD. Specifies the company or organization associated with the contact.
RecipDepartment Sales Dept. Indicates the department or division within the company associated with the contact.
FirstName Person first name Represents the first name of the contact.
LastName Person last name Represents the last name of the contact.
Position Sales Represent Specifies the job position or role of the contact.
StreetAddress 123 ABC st. Represents the street address or location of the contact.
Suburb My Suburb Specifies the suburb or district associated with the contact's address.
City Auckland Indicates the city or locality associated with the contact's address.
State NZ Represents the state or province associated with the contact's address.
Country New Zealand Specifies the country associated with the contact's address.
Postcode 1234 Represents the postal code or ZIP code associated with the contact's address.
MainPhone 092223333 Specifies the main phone number of the contact. This property typically used for Voice & Text-To-Speech messages.
AltPhone1 093334444 Represents an alternate phone number for the contact. This property typically used for Voice & Text-To-Speech messages.
AltPhone2 094445555 Represents a second alternate phone number for the contact. This property typically used for Voice & Text-To-Speech messages.
DirectPhone 094445555 Indicates the direct phone number of the contact.
MobilePhone 0211144489 Represents the mobile phone number of the contact. This property typically used for SMS messages.
FaxNumber 093334444 Specifies the fax number associated with the contact.
EmailAddress person1@example.com Represents the email address of the contact.
WebAddress https://www.tnz.co.nz Specifies the website address or URL associated with the contact.
Custom1...Custom4 Custom Value Represents custom fields or additional information associated with the contact.
HTTP Method: PATCH

Update Contact - Update Contact via REST API

 
API URL:        https://api.tnz.co.nz/api/v2.03/addressbook/contact/[ContactID]
HTTP Method:    PATCH

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required URL parameters

Parameter Example Value Description
ContactID 17f2b37e-4706-41c8-8dcb-de90e24c2447 Specifies the unique identifier of the contact to retrieve.

Properties Request Body Properties

Property Example Value Description
ViewBy Account Specifies the visibility of the contact. Values can be "Account", "SubAccount", "Department" or "No" visibility option.
EditBy Account Specifies the permission level required to edit the contact. Values can be "Account", "SubAccount", "Department" or "No" permission option.
Attention Person Attention Indicates the attention or focus associated with the contact.
Title Ms Represents the title or honorific of the contact (e.g., Mr, Mrs, Ms).
Company TNZ Group LTD. Specifies the company or organization associated with the contact.
RecipDepartment Sales Dept. Indicates the department or division within the company associated with the contact.
FirstName Person first name Represents the first name of the contact.
LastName Person last name Represents the last name of the contact.
Position Sales Represent Specifies the job position or role of the contact.
StreetAddress 123 ABC st. Represents the street address or location of the contact.
Suburb My Suburb Specifies the suburb or district associated with the contact's address.
City Auckland Indicates the city or locality associated with the contact's address.
State NZ Represents the state or province associated with the contact's address.
Country New Zealand Specifies the country associated with the contact's address.
Postcode 1234 Represents the postal code or ZIP code associated with the contact's address.
MainPhone 092223333 Specifies the main phone number of the contact. This property typically used for Voice & Text-To-Speech messages.
AltPhone1 093334444 Represents an alternate phone number for the contact. This property typically used for Voice & Text-To-Speech messages.
AltPhone2 094445555 Represents a second alternate phone number for the contact. This property typically used for Voice & Text-To-Speech messages.
DirectPhone 094445555 Indicates the direct phone number of the contact.
MobilePhone 0211144489 Represents the mobile phone number of the contact. This property typically used for SMS messages.
FaxNumber 093334444 Specifies the fax number associated with the contact.
EmailAddress person1@example.com Represents the email address of the contact.
WebAddress https://www.tnz.co.nz Specifies the website address or URL associated with the contact.
Custom1...Custom4 Custom Value Represents custom fields or additional information associated with the contact.
HTTP Method: DELETE

Delete Contact - Delete Contact via REST API

 
API URL:        https://api.tnz.co.nz/api/v2.03/addressbook/contact/[ContactID]
HTTP Method:    DELETE

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required URL parameters

Parameter Example Value Description
ContactID 17f2b37e-4706-41c8-8dcb-de90e24c2447 Specifies the unique identifier of the contact to retrieve.
HTTP Method: GET

List Contact Groups- Get Contact Group List via REST API

 
API URL:        https://api.tnz.co.nz/api/v2.03/addressbook/contact/[ContactID]/group/list
URL Parameters: page=[Page Number] //optional
  recordsPerPage=[No. of Records Per Page] //optional
HTTP Method:    GET

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required URL parameters

Parameter Example Value Description
ContactID 17f2b37e-4706-41c8-8dcb-de90e24c2447 Specifies the unique identifier of the contact to retrieve.

Optional URL Parameters

Parameter Example Value Description
recordsPerPage 50 Specifies the number of records per page to be returned. If not provided, the default number (100) of records per page will be used.
page 1 Specifies the page number of the group list to retrieve. If not provided, the default (1) behaviour will be followed.
HTTP Method: GET

Get Contact Group Detail- Get Contact Group Detail via REST API

 
API URL:        https://api.tnz.co.nz/api/v2.03/addressbook/contact/[ContactID]/group/[Group Code]
HTTP Method:    GET

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required URL parameters

Parameter Example Value Description
ContactID 17f2b37e-4706-41c8-8dcb-de90e24c2447 Specifies the unique identifier of the contact to retrieve.
Group Code Test_Group Specifies the unique identifier of the group to retrieve.
HTTP Method: POST

Create Contact Group - Create Contact Group via REST API

 
API URL:        https://api.tnz.co.nz/api/v2.03/addressbook/contact/[ContactID]/group
HTTP Method:    POST

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required URL parameters

Parameter Example Value Description
ContactID 17f2b37e-4706-41c8-8dcb-de90e24c2447 Specifies the unique identifier of the contact to create relationship.

Required Request body properties

Property Example Value Description
GroupCode Test-Group Specifies the code or identifier of the group to which the contact relationship should be added.
HTTP Method: DELETE

Delete Contact Group - Delete Contact Group via REST API

 
API URL:        https://api.tnz.co.nz/api/v2.03/addressbook/contact/[ContactID]/group/[GroupCode]
HTTP Method:    DELETE

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required URL parameters

Parameter Example Value Description
ContactID 17f2b37e-4706-41c8-8dcb-de90e24c2447 Specifies the unique identifier of the contact to delete.
GroupCode Test-Group Specifies the code or identifier of the group to be deleted.
HTTP Method: GET

List Groups- Get Group List via REST API

 
API URL:        https://api.tnz.co.nz/api/v2.03/addressbook/group/list
URL Parameters: page=[Page Number] //optional
  recordsPerPage=[No. of Records Per Page] //optional
HTTP Method:    GET

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Optional URL Parameters

Parameter Example Value Description
recordsPerPage 50 Specifies the number of records per page to be returned. If not provided, the default number (100) of records per page will be used.
page 1 Specifies the page number of the group list to retrieve. If not provided, the default (1) behaviour will be followed.
HTTP Method: GET

Get Group Detail- Get Group Detail via REST API

 
API URL:        https://api.tnz.co.nz/api/v2.03/addressbook/group/[GroupCode]
HTTP Method:    GET

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required URL parameters

Parameter Example Value Description
GroupCode Test-Group Specifies the code or identifier of the group to retrieve.
HTTP Method: POST

Create Group - Create Group via REST API

 
API URL:        https://api.tnz.co.nz/api/v2.03/addressbook/group
HTTP Method:    POST

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required Request Body Properties

Property Example Value Description
GroupName Test Group Specifies the name of the group. If GroupCode is not specified, TNZ API will take group name and replace white space into underscore.

Optional Request Body Properties

Property Example Value Description
GroupCode Test-Group Specifies the code or identifier for the group. Leave empty if you want the system to generate the code from the group name.
SubAccount Test SubAccount Specifies the subaccount associated with the group.
Department Test Department Specifies the department or division associated with the group.
ViewEditBy Account Specifies the visibility and edit permissions for the group. Values can be "Account", "SubAccount", "Department" or "No" permission option.
HTTP Method: PATCH

Update Group - Update Group via REST API

 
API URL:        https://api.tnz.co.nz/api/v2.03/addressbook/group/[GroupCode]
HTTP Method:    PATCH

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required URL parameters

Parameter Example Value Description
GroupCode Test-Group Specifies the code or identifier of the group to be updated.

Optional Request Body Properties

Property Example Value Description
GroupName Test Group Specifies the name of the group. Unlike 'Create' API, updating GroupName will NOT change the GroupCode.
SubAccount Test SubAccount Specifies the subaccount associated with the group.
Department Test Department Specifies the department or division associated with the group.
ViewEditBy Account Specifies the visibility and edit permissions for the group. Values can be "Account", "SubAccount", "Department" or "No" permission option.
HTTP Method: DELETE

Delete Group - Delete Group via REST API

 
API URL:        https://api.tnz.co.nz/api/v2.03/addressbook/group/[GroupCode]
HTTP Method:    DELETE

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required URL parameters

Parameter Example Value Description
GroupCode Test-Group Specifies the code or identifier of the group to be deleted.
HTTP Method: GET

List Group Contacts- Get Group Contact List via REST API

 
API URL:        https://api.tnz.co.nz/api/v2.03/addressbook/group/[GroupCode]/contact/list
URL Parameters: page=[Page Number] //optional
  recordsPerPage=[No. of Records Per Page] //optional
HTTP Method:    GET

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required URL parameters

Parameter Example Value Description
GroupCode Test-Group Specifies the code or identifier of the group to be deleted.

Optional URL Parameters

Parameter Example Value Description
recordsPerPage 50 Specifies the number of records per page to be returned. If not provided, the default number (100) of records per page will be used.
page 1 Specifies the page number of the contact list to retrieve. If not provided, the default (1) behaviour will be followed.
HTTP Method: GET

Get Group Contact Detail- Get Group Contact Detail via REST API

 
API URL:        https://api.tnz.co.nz/api/v2.03/addressbook/group/[Group Code]/contact/[ContactID]
HTTP Method:    GET

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required URL parameters

Parameter Example Value Description
Group Code Test_Group Specifies the unique identifier of the group to retrieve.
ContactID 17f2b37e-4706-41c8-8dcb-de90e24c2447 Specifies the unique identifier of the contact to retrieve.
HTTP Method: POST

Create Group Contact - Create Group Contact via REST API

 
API URL:        https://api.tnz.co.nz/api/v2.03/addressbook/group/[GroupCode]/contact
HTTP Method:    POST

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required URL parameters

Parameter Example Value Description
GroupCode Test-Group Specifies the code or identifier of the group to which the contact relationship should be added.

Required Request body properties

Property Example Value Description
ContactID 17f2b37e-4706-41c8-8dcb-de90e24c2447 Specifies the unique identifier of the contact to create relationship.
HTTP Method: DELETE

Delete Group Contact - Delete Group Contact via REST API

 
API URL:        https://api.tnz.co.nz/api/v2.03/addressbook/group/[GroupCode]/contact/[ContactID]
HTTP Method:    DELETE

    
Sample SUCCESS Response [HTTP Response Status: 200 OK]:
Sample FAILURE Response [HTTP Response Status: 400 Bad Request]:

Required HTTP Headers

Parameter Example Value Description
Content-Type application/json; encoding='utf-8' Sets the request data format. Set 'json' or 'xml' appropriately.
Accept application/json; encoding='utf-8' Sets the return data format. Set 'json' or 'xml' appropriately.
Authorization Basic eyJhbGciOiJI...adQssw5c Auth Token value set up (see Auth Token)

Required URL parameters

Parameter Example Value Description
GroupCode Test-Group Specifies the code or identifier of the group to be deleted.
ContactID 17f2b37e-4706-41c8-8dcb-de90e24c2447 Specifies the unique identifier of the contact to delete.

Versioning/Changelog

When a new version of the API is released, the APIVersion url parameter is incremented.
This allows you to use a different API version based on the API URL, limiting the testing you require should you wish to update one API URL to a later version of the API.

Want to upgrade to a new version for SMS but don't want to break and retest Email? Use the newer APIVersion for SMS while using the older APIVersion for Email.

For example, you may be using:
https://api.tnz.co.nz/api/v2.03/send/email
However, you may also dynamically use:
https://api.tnz.co.nz/api/v2.02/send/email

As new versions of the API are released, this API reference guide will be updated to reflect the latest version and features supported:

 API Version ChangeLog


Frequently Asked Questions

Yes, full international delivery is supported.
The maximum request size supported is 20MB. This is our server side limitation. Your client side limitation may be smaller.
There is no limit to the number of Destinations (in either format), provided you do not breach the 20MB maximum REST request size.
There is a limit of 10 files specified in a single request. There is no file size limitation, provided you do not breach the 20MB maximum REST request size.
Yes, we support email security measures. Contact us for further information on setting up your own security measures for whitelabeled messages delivered with the API.
You can send a wide range of file types, including Microsoft Office® documents (doc, docx, ppt, pptx, xls, xlsx, etc), Openoffice/Libreoffice documents (odt, ods, etc), Adobe® documents (pdf, etc), image file types (jpg, gif, tif, bmp, etc) and more (txt, html, etc).
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.
Yes, we can provide a daily or monthly email report (as an attached CSV file) containing data on messages sent. This can be used for billing (contains costs) or for reporting (doesn’t contain costs).
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.
Some networks support customised SMS Caller IDs. This can be configured using your Web Dashboard.
Your Fax Caller ID can be configured using your Web Dashboard.
Your Voice and TextToSpeech Caller ID is specified on a per-message basis using the 'CallerID' parameter.
");