If you don't have an account, head to https://www.tnz.co.nz/Customer/SignUp/ and fill in the form.
To access the API, you'll need a User with API access:
The API v2.02 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.
Save hundreds of lines of code and hours of time by dropping the .NET DLL into your project. Using one DLL and simple code tweaks, your software can send Email, SMS, Fax, Voice and Text-to-Speech messages.
For a brief overview of the API, see the TNZ API Structure guide.
Download and extract the .NET library DLL: TNZAPI.dll.zip
Reference the library in your code:
using TNZAPI;
using TNZAPI.Messaging;
using TNZAPI.Messaging.Functions;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
using TNZAPI.Messaging.Get;
Using the [MessageType].SendMessage()
function, the DLL will connect to TNZ's REST API (in XML format) and send messages.
Message Status and Received Messages can be captured using a Webhook (a POST to your nominated URL), or can be Polled for using the DLL's GET function.
See Status Reporting and Receive Messages.
Find instructions for each Message Type:
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
namespace TNZEmailBasic
{
class Program
{
static void Main(string[] args)
{
Email EmailMessage = new Email();
//
// You can use AuthToken (can find it from our web portal) if you prefer
//
EmailMessage.AuthToken = "YOUR_AUTH_TOKEN"; // Auth Token
EmailMessage.FromEmail = "from@test.com"; // Optional : Sets From Email Address - leave blank to use your api username as email sender
EmailMessage.EmailSubject = "Test Email"; // Email Subject
EmailMessage.MessagePlain = "Test Email Body"; // Email Body
EmailMessage.AddRecipient("email.one@test.com"); // Recipient 1
EmailMessage.AddRecipient("email.two@test.com"); // Recipient 2
MessageResult response = EmailMessage.SendMessage();
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
namespace TNZEmailSimple
{
class Program
{
static void Main(string[] args)
{
const string authToken = "YOUR_AUTH_TOKEN"; // Auth Token
const string from_email = "from@test.com"; // Optional : Sets From Email Address - leave blank to use your api username as email sender
const string subject = "Test Email"; // Email Subject
const string message_plain = "Test Email Body"; // Email Body (Plain Text)
const string recipient = "email@test.com"; // Recipient
Email EmailMessage = new Email(authToken);
EmailMessage.SetEmailFrom(from_email);
EmailMessage.AddRecipient(recipient);
MessageResult response = EmailMessage.SendMessage(
subject,
message_plain
);
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
namespace TNZEmailBuilder
{
internal class Program
{
static void Main(string[] args)
{
//
// Sample code using EmailBuilder()
//
var request = new EmailBuilder()
.SetAuthToken("[Your Auth Token]") // Auth Token
.SetEmailFrom("from@test.com") // Optional : Sets From Email Address - leave blank to use your api username as email sender
.SetEmailSubject("Test Email") // Email Subject
.SetMessagePlain("Test Email Body") // Email Body (Plain Text)
.AddRecipient("to@test.com") // Recipient
.SetSendMode(Enums.SendModeType.Test) // TEST/Live mode
.Build(); // Build Email() object
var response = request.SendMessage();
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
using TNZAPI.Messaging.Functions;
namespace TNZEmailAdvanced
{
class Program
{
static void Main(string[] args)
{
#region Declarations
const string auth_token = "YOUR_AUTH_TOKEN";
const string reference = "Test Email - Advanced version";
const string webhook_callback_url = "https://example.com/webhook";
const Enums.WebhookCallbackType webhook_callback_format = Enums.WebhookCallbackType.XML;
const string error_email_notify = "notify@example.com";
const string recipient1 = "emailTo@test.com";
const string recipient2 = "emailTo@test.com";
const string recipient3 = "emailTo@test.com";
const string recipient4 = "emailTo@test.com";
const string file1 = "c:\\File1.pdf";
const string file2 = "c:\\File2.pdf";
const string file3 = "c:\\File3.pdf";
const string file4 = "c:\\File4.pdf";
const string smtp_from = "from@test.com";
const string from_name = "Email From";
const string from_email = "email@test.com";
const string reply_to = "email@test.com";
const string subject = "Test Email 123";
const string message_plain = "Test Email Body";
const string message_html = "This is Test message body. Thank you so much!
";
#endregion Declarations
Email EmailMessage = new Email()
{
AuthToken = auth_token,
WebhookCallbackURL = webhook_callback_url,
WebhookCallbackFormat = webhook_callback_format,
ErrorEmailNotify = error_email_notify
};
#region Add Recipients
//
// Add Recipient Method 1 - AddRecipient(string recipient);
//
EmailMessage.AddRecipient(recipient1);
//
// Add Recipient Method 2 - AddRecipient(new Recipient())
//
Recipient recipient = new Recipient(recipient2);
recipient.CompanyName = "Test Company"; // Company Name
recipient.Attention = "Test Recipient 2"; // Attention
recipient.Custom1 = "Custom1"; // Custom1
recipient.Custom2 = "Custom2"; // Custom2
recipient.Custom3 = "Custom3"; // Custom3
recipient.Custom4 = "Custom4"; // Custom4
recipient.Custom5 = "Custom5"; // Custom5
EmailMessage.AddRecipient(recipient);
//
// Add Recipient Method 3 - AddRecipients(new List()); using simple destination
//
List recipients = new List();
recipients.Add(new Recipient(recipient3));
//
// Add Recipient Method 4 - AddRecipients(new List()) using Recipient objects
//
recipients.Add(new Recipient(
recipient4, // Recipient
"Test Company", // Company Name
"Test Recipient 3", // Attention
"Custom1", // Custom1
"Custom2", // Custom2
"Custom3", // Custom3
"Custom4", // Custom4
"Custom5" // Custom5
));
EmailMessage.AddRecipients(recipients);
#endregion Add Recipients
#region Add Attachments
//
// Add Attachment Method 1 - AddAttachment(file_location);
//
EmailMessage.AddAttachment(file1);
//
// Add Attachment Method 2 - AddAttachment(new Attachment());
//
Attachment attachment = new Attachment();
attachment.FileName = FileHandlers.GetFileName(file2);
attachment.FileContent = FileHandlers.GetFileContents(file2);
EmailMessage.AddAttachment(attachment);
//
// Add Attachment Method 3 - AddAttachments(new List()) using simple file locations
//
List attachments = new List();
attachments.Add(new Attachment(file3));
//
// Add Attachment Method 4 - AddAttachments(new List()) using Attachment objects
//
attachments.Add(new Attachment(
FileHandlers.GetFileName(file4),
FileHandlers.GetFileContents(file4)
));
EmailMessage.AddAttachments(attachments);
#endregion Add Attachments
#region Set SMTP Headers
// Set email sender
EmailMessage.SetEmailFrom(
smtp_from,
from_name,
from_email,
reply_to
);
#endregion Set SMTP Headers
MessageResult response = EmailMessage.SendMessage(
subject, //Subject
message_plain, //MessagePlain
message_html, //MessageHTML
"", //MessageID
reference, //Reference
new DateTime(), //SendTime
"New Zealand", //Timezone
"", //SubAccount
"", //Department
"" //ChargeCode
);
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - "+response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
Console.ReadLine();
}
}
}
Parameter | Example Value | Description | |
---|---|---|---|
AuthToken | eyJhbGciOiJI...adQssw5c | Auth Token value set up in Create a new API Auth token | |
EmailSubject | Test Email | Sets the email subject | |
MessagePlain | Hello, This is a test message. Thank you. |
Content used for the message/plain section of the email (overrides 'Template') | |
Recipient | john.doe@example.com | Email address to receive the message (for detailed formatting, see the Destinations parameter below) |
Parameter | Example Value | Description | |
---|---|---|---|
MessageID | ID12345 | Tracking ID or message description. Leave black if you want us to generate one. | |
Reference | Test1 | Reference of your message | |
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 | new DateTime() | Delay sending until the specified date/time (dd/mm/yyyy HH:mm 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) | |
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) | |
ReplyTo | reply@example.com | Sets the email sender's Reply-To Address (if the recipient replies, the Reply To will receive the reply) | |
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') | |
Recipients | > Recipient | john.doe@example.com | Recipient of the email |
> Attention | John Doe | Recipient's name | |
> Company | Example Corp | Recipient's company | |
> Custom1 | Customisable field | ||
> Custom2 | Customisable field | ||
Attachments | > Name | Sample.pdf | Attachment's filename |
> Data | %%Base-64%% | Base-64 encoded value of the attached file |
Function | Usage | Description | |
---|---|---|---|
AddRecipient() |
AddRecipient(string recipient) AddRecipient(Recipient recipient) |
Function to add a single message recipient | |
AddRecipients() |
AddRecipients(List<string> recipients) AddRecipients(List<Recipient> recipients) |
Function to add a list of message recipients | |
AddAttachment() |
AddAttachment(string file_location) AddAttachment(Attachment attachment) |
Function to add a single attachment to the message (the .NET library will grab the file contents from the specified file location) | |
AddAttachments() |
AddAttachments(List<string> file_locations) AddAttachments(List<Attachment> attachments) |
Function to add multiple attachment to the message (the .NET library will grab the file contents from the specified file location) | |
SetEmailFrom() |
SetEmailFrom(string from_email) SetEmailFrom(string from_name, string from_email) SetEmailFrom(string from_name, string from_email, string reply_to) SetEmailFrom(string smtp_from, string from_name, string from_email, string reply_to) |
Function to set the SMTP From headers (domains require SPF and other security features enabled - contact your Sales Representative for details) | |
SendMessage() |
SendMessage() SendMessage(string message_text) SendMessage( string message_id, string reference, DateTime send_time, string timezone, string subaccount, string department, string charge_code, string sms_email_reply, string force_gsm_chars, string message_text ) |
Function to submit messages to TNZ REST API Returns MessageResult object |
Function | Usage | Description | |
---|---|---|---|
AddAttachmentAsync() |
AddAttachmentAsync(string file_location) AddAttachmentAsync(Attachment attachment) |
Function to add a single attachment to the message (the .NET library will grab the file contents from the specified file location) | |
AddAttachmentsAsync() |
AddAttachmentsAsync(List<string> file_locations) AddAttachmentsAsync(List<Attachment> attachments) |
Function to add multiple attachment to the message (the .NET library will grab the file contents from the specified file location) | |
SendMessageAsync() |
SendMessageAsync() SendMessageAsync(string message_text) SendMessageAsync( string message_id, string reference, DateTime send_time, string timezone, string subaccount, string department, string charge_code, string sms_email_reply, string force_gsm_chars, string message_text ) |
Function to submit messages to TNZ REST API Returns Task<IMessageResult> object |
Function | Usage | Description | |
---|---|---|---|
SetAuthToken() | SetAuthToken(string token) | Function to set Auth Token to send message [Required] |
|
SetAPIUser() | SetAPIUser(APIUser api_user) | Function to set APIUser to send message | |
SetAPISender() | SetAPISender(string sender) | Function to set API Sender (need to set SetAPIKey() with this) | |
SetAPIKey() | SetAPIKey(string api_key) | Function to set API Key (need to set SetAPISender() with this) | |
SetErrorEmailNotify() | SetErrorEmailNotify(string email) | Function to set Email Address to receive error notifications | |
SetWebhookCallbackURL() | SetWebhookCallbackURL(string url) | Overrides your Sender's default Webhook URL. Requires a default webhook to be configured. A full path including https:// is required. | |
SetWebhookCallbackFormat() | SetWebhookCallbackFormat(WebhookCallbackType type) | Overrides your Sender's default Webhook format ('JSON' or 'XML') | |
SetMessageID() | SetMessageID(string message_id) | Tracking ID or message description. Leave black if you want us to generate one. | |
SetReference() | SetReference(string reference) | Reference of your message | |
SetSendTime() | SetSendTime(DateTime time) | Delay sending until the specified date/time (dd/mm/yyyy HH:mm in your local timezone, specified by your Sender setting or overridden using the TimeZone command) | |
SetTimezone() | SetTimezone(string timezone) | User's local timezone (see Setting Timezones) | |
SetSubAccount() | SetSubAccount(string subaccount) | Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section. | |
SetDepartment() | SetDepartment(string department) | Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section. | |
SetChargeCode() | SetChargeCode(string code) | Bespoke app cost allocation code (for invoice segmentation) | |
SetEmailSubject() | SetEmailSubject(string email_subject) | Sets the email subject | |
SetMessagePlain() | SetMessagePlain(string message) | Content used for the message/plain section of the email (overrides 'Template') [Required] |
|
SetMessageHTML() | SetMessageHTML(string message_html) | Content used for the message/html section of the email (overrides 'Template' and 'MessagePlain') | |
SetEmailFrom() |
SetEmailFrom(string from_email) SetEmailFrom(string from_name, string from_email) SetEmailFrom(string from_name, string from_email, string reply_to) SetEmailFrom(string smtp_from, string from_name, string from_email, string reply_to) |
Sets the email sender's Friendly Name (seen by the email recipient) | |
AddRecipient() |
AddRecipient(string recipient) AddRecipient(IRecipient recipient) |
Function to add a single message recipient [Required] |
|
AddRecipients() |
AddRecipients(List<string> recipients) AddRecipients(List<IRecipient> recipients) |
Function to add a list of message recipients | |
AddAttachment() | AddAttachment(string file_location) | Function to add a single attachment to the message (the .NET library will grab the file contents from the specified file location) | |
AddAttachments() | AddAttachments(List<string> file_locations) | Function to add multiple attachments to the message (the .NET library will grab the file contents from the specified file location) | |
Build() | Build() | Builds the Email() object and return IMessage [Required] |
|
BuildAsync() | BuildAsync() | Builds the Email() object asynchronous and return Task<IMessage> |
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
namespace TNZSMSBasic
{
class Program
{
static void Main(string[] args)
{
SMS SMSMessage = new SMS();
//
// You can use AuthToken (can find it from our web portal) if you prefer
//
SMSMessage.AuthToken = "YOUR_AUTH_TOKEN"; // Auth Token
SMSMessage.MessageText = "Test SMS"; // SMS Message
SMSMessage.AddRecipient("+64211111111"); // Recipient
SMSMessage.AddRecipient("+64222222222"); // Recipient
MessageResult response = SMSMessage.SendMessage();
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
namespace TNZTTSSimple
{
class Program
{
static void Main(string[] args)
{
const string authToken = "YOUR_AUTH_TOKEN"; // Auth Token
const string recipient = "+64211111111"; // Recipient
const string message_to_people = "Hello, this is a call from test. This is relevant information.";
TTS TTSMessage = new TTS(authToken);
TTSMessage.AddMessageData(TTS.MessageDataType.MessageToPeople, message_to_people);
TTSMessage.AddRecipient(recipient);
MessageResult response = TTSMessage.SendMessage();
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
namespace TNZSMSBuilder
{
class Program
{
static void Main(string[] args)
{
//
// Sample code using SMSBuilder()
//
var request = new SMSBuilder()
.SetAuthToken("[Your Auth Token]") // Auth Token
.SetMessageText("Test SMS") // SMS Message
.AddRecipient("+64211111111") // Recipient
.SetSendMode(Enums.SendModeType.Test) // TEST/Live mode
.Build(); // Build SMS() object
var response = request.SendMessage();
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
using TNZAPI.Messaging.Functions;
using System.Threading.Tasks;
namespace TNZSMSAdvanced
{
class Program
{
static void Main(string[] args)
{
#region Declarations
const string auth_token = "YOUR_AUTH_TOKEN";
const string reference = "Test SMS - Advanced version";
const string webhook_callback_url = "https://example.com/webhook";
const Enums.WebhookCallbackType webhook_callback_format = Enums.WebhookCallbackType.XML;
const string error_email_notify = "notify@example.com";
const string sms_email_reply = "reply@test.com";
const string force_gsm_chars = "True";
const string recipient1 = "+64211111111";
const string recipient2 = "+64212222222";
const string recipient3 = "+64213333333";
const string recipient4 = "+64214444444";
const string file1 = "D:\\file1.pdf";
const string file2 = "D:\\file2.pdf";
const string file3 = "D:\\file3.pdf";
const string file4 = "D:\\file4.pdf";
const string message_text = "Test SMS Message [[File1]] | [[File2]] | [[File3]] | [[File4]]";
#endregion Declarations
SMS SMSMessage = new SMS()
{
AuthToken = auth_token,
WebhookCallbackURL = webhook_callback_url,
WebhookCallbackFormat = webhook_callback_format,
ErrorEmailNotify = error_email_notify
};
#region Add Recipients
//
// Add Recipient Method 1 - AddRecipient(string recipient);
//
SMSMessage.AddRecipient(recipient1);
//
// Add Recipient Method 2 - AddRecipient(new Recipient())
//
Recipient recipient = new Recipient(recipient2);
recipient.CompanyName = "Test Company"; // Company Name
recipient.Attention = "Test Recipient 2"; // Attention
recipient.Custom1 = "Custom1"; // Custom1
recipient.Custom2 = "Custom2"; // Custom2
recipient.Custom3 = "Custom3"; // Custom3
recipient.Custom4 = "Custom4"; // Custom4
recipient.Custom5 = "Custom5"; // Custom5
SMSMessage.AddRecipient(recipient);
//
// Add Recipient Method 3 - AddRecipients(new List()); using simple destination
//
List recipients = new List();
recipients.Add(new Recipient(recipient3));
//
// Add Recipient Method 4 - AddRecipients(new List()) using Recipient objects
//
recipients.Add(new Recipient(
recipient4, // Recipient
"Test Company", // Company Name
"Test Recipient 4", // Attention
"Custom1", // Custom1
"Custom2", // Custom2
"Custom3", // Custom3
"Custom4", // Custom4
"Custom5" // Custom5
));
SMSMessage.AddRecipients(recipients);
#endregion Add Recipients
#region Add Attachments
/*
* Please note:
*
* Attachments are only supported with MessageLink - Please ask us to enable MessageLink
*
* Attachments will get ignored if you have not MessageLink functionality
*/
//
// Add Attachment Method 1 - AddAttachment(file_location);
//
SMSMessage.AddAttachment(file1);
//
// Add Attachment Method 2 - AddAttachment(new Attachment());
//
Attachment attachment = new Attachment();
attachment.FileName = FileHandlers.GetFileName(file2);
attachment.FileContent = FileHandlers.GetFileContents(file2);
SMSMessage.AddAttachment(attachment);
//
// Add Attachment Method 3 - AddAttachments(new List()) using simple file locations
//
List attachments = new List();
attachments.Add(new Attachment(file3));
//
// Add Attachment Method 4 - AddAttachments(new List()) using Attachment objects
//
attachments.Add(new Attachment(
FileHandlers.GetFileName(file4),
FileHandlers.GetFileContents(file4)
));
SMSMessage.AddAttachments(attachments);
#endregion Add Attachments
MessageResult response = SMSMessage.SendMessage(
"", // MessageID - Leave blank to auto-generate
reference, // Reference
new DateTime(), // SendTime
"New Zealand", // Timezone
"", // SubAccount
"", // Department
"", // ChargeCode
sms_email_reply, // SMSEmailReply - For email (SMTP) reply receipt notifications
force_gsm_chars, // ForceGSMChars
message_text
);
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
Console.ReadLine();
}
}
}
Parameter | Example Value | Description | |
---|---|---|---|
AuthToken | eyJhbGciOiJI...adQssw5c | Auth Token value set up in Create a new API Auth token | |
MessageText | Hello, this is a test message from Department01. Thank you. | Plain or UTF-8 formatted SMS message | |
Recipient | +6421000002 | Mobile number to receive the message (for detailed formatting, see the Destinations parameter below) |
Parameter | Example Value | Description | |
---|---|---|---|
MessageID | ID12345 | Tracking ID or message description. Leave black if you want us to generate one. | |
Reference | Test1 | Tracking ID or message description | |
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 | new DateTime() | Delay sending until the specified date/time (dd/mm/yyyy HH:mm 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 | |
ForceGSMChars | 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 | |
Recipients | > MobileNumber | +6421000001 | Recipient of the SMS in E.164 internationalised format (for localized or friendly formatting, contact your account manager) |
> Attention | John Doe | Recipient's name | |
> Company | Example Corp | Recipient's company | |
> Custom1 | Customisable field | ||
> Custom2 | Customisable field |
Function | Usage | Description | |
---|---|---|---|
AddRecipient() |
AddRecipient(string recipient) AddRecipient(Recipient recipient) |
Function to add a single message recipient | |
AddRecipients() |
AddRecipients(List<string> recipients) AddRecipients(List<Recipient> recipients) |
Function to add a list of message recipients | |
AddAttachment() |
AddAttachment(string file_location) AddAttachment(Attachment attachment) |
Function to add a single attachment to the message (the .NET library will grab the file contents from the specified file location) | |
AddAttachments() |
AddAttachments(List<string> file_locations) AddAttachments(List<Attachment> attachments) |
Function to add multiple attachments to the message (the .NET library will grab the file contents from the specified file location) | |
SendMessage() |
SendMessage() SendMessage(string message_text) SendMessage( string message_id, string reference, DateTime send_time, string timezone, string subaccount, string department, string charge_code, string sms_email_reply, string force_gsm_chars, string message_text ) |
Function to submit messages to TNZ REST API Returns MessageResult object |
Function | Usage | Description | |
---|---|---|---|
AddAttachmentAsync() |
AddAttachmentAsync(string file_location) AddAttachmentAsync(Attachment attachment) |
Function to add a single attachment to the message (the .NET library will grab the file contents from the specified file location) | |
AddAttachmentsAsync() |
AddAttachmentsAsync(List<string> file_locations) AddAttachmentsAsync(List<Attachment> attachments) |
Function to add multiple attachments to the message (the .NET library will grab the file contents from the specified file location) | |
SendMessageAsync() |
SendMessageAsync() SendMessageAsync(string message_text) SendMessageAsync( string message_id, string reference, DateTime send_time, string timezone, string subaccount, string department, string charge_code, string sms_email_reply, string force_gsm_chars, string message_text ) |
Function to submit messages to TNZ REST API Returns Task<IMessageResult> object |
Function | Usage | Description | |
---|---|---|---|
SetAuthToken() | SetAuthToken(string token) | Function to set Auth Token to send message [Required] |
|
SetAPIUser() | SetAPIUser(APIUser api_user) | Function to set APIUser to send message | |
SetAPISender() | SetAPISender(string sender) | Function to set API Sender (need to set SetAPIKey() with this) | |
SetAPIKey() | SetAPIKey(string api_key) | Function to set API Key (need to set SetAPISender() with this) | |
SetErrorEmailNotify() | SetErrorEmailNotify(string email) | Function to set Email Address to receive error notifications | |
SetWebhookCallbackURL() | SetWebhookCallbackURL(string url) | Overrides your Sender's default Webhook URL. Requires a default webhook to be configured. A full path including https:// is required. | |
SetWebhookCallbackFormat() | SetWebhookCallbackFormat(WebhookCallbackType type) | Overrides your Sender's default Webhook format ('JSON' or 'XML') | |
SetMessageID() | SetMessageID(string message_id) | Tracking ID or message description. Leave black if you want us to generate one. | |
SetReference() | SetReference(string reference) | Reference of your message | |
SetSendTime() | SetSendTime(DateTime time) | Delay sending until the specified date/time (dd/mm/yyyy HH:mm in your local timezone, specified by your Sender setting or overridden using the TimeZone command) | |
SetTimezone() | SetTimezone(string timezone) | User's local timezone (see Setting Timezones) | |
SetSubAccount() | SetSubAccount(string subaccount) | Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section. | |
SetDepartment() | SetDepartment(string department) | Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section. | |
SetChargeCode() | SetChargeCode(string code) | Bespoke app cost allocation code (for invoice segmentation) | |
SetFromNumber() | SetFromNumber(string number) | Setting SMS origination number, short code(s) will override in New Zealand - Not for New Zealand. | |
SetSMSEmailReply() | SetSMSEmailReply(string email) | For email (SMTP) reply receipt notifications | |
SetCharacterConversion() |
SetCharacterConversion(bool truefalse) SetCharacterConversion(string truefalse) |
Convert multi-byte characters into normalised GSM character format. ie. © to (C) | |
SetMessageText() | SetMessageText(string message) | An example Message that uses the URL Shortener, File Link, Reply Link and Unsubscribe functions [Required] |
|
AddRecipient() |
AddRecipient(string recipient) AddRecipient(IRecipient recipient) |
Function to add a single message recipient [Required] |
|
AddRecipients() |
AddRecipients(List<string> recipients) AddRecipients(List<IRecipient> recipients) |
Function to add a list of message recipients | |
AddAttachment() | AddAttachment(string file_location) | Function to add a single attachment to the message (the .NET library will grab the file contents from the specified file location) | |
AddAttachments() | AddAttachments(List<string> file_locations) | Function to add multiple attachments to the message (the .NET library will grab the file contents from the specified file location) | |
Build() | Build() | Builds the SMS() object and return IMessage [Required] |
|
BuildAsync() | BuildAsync() | Builds the SMS() object asynchronous and return Task<IMessage> |
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
namespace TNZFaxBasic
{
class Program
{
static void Main(string[] args)
{
Fax FaxMessage = new Fax();
FaxMessage.AuthToken = "YOUR_AUTH_TOKEN"; // Auth Token
FaxMessage.AddRecipient("+6491111111"); // Recipient 1
FaxMessage.AddRecipient("+6491111112"); // Recipient 2
FaxMessage.AddAttachment("C:\\File1.pdf"); // Attach File
MessageResult response = FaxMessage.SendMessage();
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
namespace TNZFaxSimple
{
class Program
{
static void Main(string[] args)
{
const string authToken = "YOUR_AUTH_TOKEN"; // Auth Token
const string recipient = "+6491111111";
const string file = "C:\\File1.pdf"; // File location
Fax FaxMessage = new Fax(authToken); // Initializer
FaxMessage.AddRecipient(recipient);
FaxMessage.AddAttachment(file);
MessageResult response = FaxMessage.SendMessage();
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
namespace TNZFaxBuilder
{
class Program
{
static void Main(string[] args)
{
//
// Sample code using FaxBuilder()
//
var request = new FaxBuilder()
.SetAuthToken("[Your Auth Token]") // Auth Token
.AddAttachment("D:\\File1.pdf") // Attachment location
.AddRecipient("+6491111111") // Recipient
.SetSendMode(Enums.SendModeType.Test) // TEST/Live mode
.Build(); // Build Email() object
var response = request.SendMessage();
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
using TNZAPI.Messaging.Functions;
namespace TNZFaxAdvanced
{
class Program
{
static void Main(string[] args)
{
#region Declarations
const string auth_token = "YOUR_AUTH_TOKEN";
const string reference = "Test Fax - Advanced version";
const string webhook_callback_url = "https://example.com/webhook";
const Enums.WebhookCallbackType webhook_callback_format = Enums.WebhookCallbackType.XML;
const string error_email_notify = "notify@example.com";
const string recipient1 = "+6491111111";
const string recipient2 = "+6492222222";
const string recipient3 = "+6493333333";
const string recipient4 = "+6494444444";
const string file1 = "C:\\file1.pdf";
const string file2 = "C:\\file2.pdf";
const string file3 = "C:\\file3.pdf";
const string file4 = "C:\\file4.pdf";
const string resolution = "High";
const string csid = "TEST FAX";
const int retry_attempts = 3;
const int retry_period = 1;
#endregion Declarations
Fax FaxMessage = new Fax()
{
AuthToken = auth_token,
WebhookCallbackURL = webhook_callback_url,
WebhookCallbackFormat = webhook_callback_format,
ErrorEmailNotify = error_email_notify
};
#region Add Recipients
//
// Add Recipient Method 1 - AddRecipient(string recipient);
//
FaxMessage.AddRecipient(recipient1);
//
// Add Recipient Method 2 - AddRecipient(new Recipient())
//
Recipient recipient = new Recipient(recipient2);
recipient.CompanyName = "Test Company"; // Company Name
recipient.Attention = "Test Recipient 2"; // Attention
recipient.Custom1 = "Custom1"; // Custom1
recipient.Custom2 = "Custom2"; // Custom2
recipient.Custom3 = "Custom3"; // Custom3
recipient.Custom4 = "Custom4"; // Custom4
recipient.Custom5 = "Custom5"; // Custom5
FaxMessage.AddRecipient(recipient);
//
// Add Recipient Method 3 - AddRecipients(new List()); using simple destination
//
List recipients = new List();
recipients.Add(new Recipient(recipient3));
//
// Add Recipient Method 4 - AddRecipients(new List()) using Recipient objects
//
recipients.Add(new Recipient(
recipient4, // Recipient
"Test Company", // Company Name
"Test Recipient 4", // Attention
"Custom1", // Custom1
"Custom2", // Custom2
"Custom3", // Custom3
"Custom4", // Custom4
"Custom5" // Custom5
));
FaxMessage.AddRecipients(recipients);
#endregion Add Recipients
#region Add Attachments
//
// Add Attachment Method 1 - AddAttachment(file_location);
//
FaxMessage.AddAttachment(file1);
//
// Add Attachment Method 2 - AddAttachment(new Attachment());
//
Attachment attachment = new Attachment();
attachment.FileName = FileHandlers.GetFileName(file2);
attachment.FileContent = FileHandlers.GetFileContents(file2);
FaxMessage.AddAttachment(attachment);
//
// Add Attachment Method 3 - AddAttachments(new List()) using simple file locations
//
List attachments = new List();
attachments.Add(new Attachment(file3));
//
// Add Attachment Method 4 - AddAttachments(new List()) using Attachment objects
//
attachments.Add(new Attachment(
FileHandlers.GetFileName(file4),
FileHandlers.GetFileContents(file4)
));
FaxMessage.AddAttachments(attachments);
#endregion Add Attachments
MessageResult response = FaxMessage.SendMessage(
"", // MessageID - Leave blank to auto-generate
reference, // Reference
new DateTime(), // SendTime
"New Zealand", // Timezone
"", // SubAccount
"", // Department
"", // ChargeCode
resolution, // Resolution - High/Low
csid, // CSID
"", // WaterMarkFolder
"", // WaterMarkFirstPage
"", // WaterMarkAllPages
retry_attempts, // RetryAttempts - no of retries
retry_period // RetryPeriod - no of minutes between retries
);
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
Console.ReadLine();
}
}
}
Parameter | Example Value | Description | |
---|---|---|---|
AuthToken | eyJhbGciOiJI...adQssw5c | Auth Token value set up in Create a new API Auth token | |
Recipient | +6495005001 | Fax number(s) to receive the message (for detailed formatting, see the Destinations parameter below) | |
Attachment | > Name | Sample.pdf | Fax document's filename |
> Data | %%Base-64%% | Base-64 encoded value of the document |
Parameter | Example Value | Description | |
---|---|---|---|
MessageID | ID12345 | Tracking ID or message description. Leave black if you want us to generate one. | |
Reference | Test1 | Reference of your message | |
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 | new DateTime() | Delay sending until the specified date/time (dd/mm/yyyy HH:mm 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 | |
RetryAttempts | 3 | Number of retries (retry_period required) | |
RetryPeriod | 1 | Minutes between retries (retry_attempts required) | |
Recipients | > Recipient | +6495005000 | Recipient of the Fax in E.164 internationalised format (for localized or friendly formatting, contact your account manager) |
> Attention | John Doe | Recipient's name | |
> Company | Example Corp | Recipient's company | |
> Custom1 | Customisable field | ||
> Custom2 | Customisable field |
Function | Usage | Description | |
---|---|---|---|
AddRecipient() |
AddRecipient(string recipient) AddRecipient(Recipient recipient) |
Function to add a single message recipient | |
AddRecipients() |
AddRecipients(List<string> recipients) AddRecipients(List<Recipient> recipients) |
Function to add a list of message recipients | |
AddAttachment() |
AddAttachment(string file_location) AddAttachment(Attachment attachment) |
Function to add a single attachment to the message (the .NET library will grab the file contents from the specified file location) | |
AddAttachments() |
AddAttachments(List<string> file_locations) AddAttachments(List<Attachment> attachments) |
Function to add multiple attachments to the message (the .NET library will grab the file contents from the specified file location) | |
SendMessage() |
SendMessage() SendMessage( string message_id, string reference, DateTime send_time, string timezone, string subaccount, string department, string charge_code, string resolution, string csid ) SendMessage( string message_id, string reference, DateTime send_time, string timezone, string subaccount, string department, string charge_code, string resolution, string csid, string watermark_folder, string watermark_firstpage, string watermark_allpages, int retry_attempts, int retry_period ) |
Function to submit messages to TNZ REST API Returns MessageResult object |
Function | Usage | Description | |
---|---|---|---|
AddAttachmentAsync() |
AddAttachmentAsync(string file_location) AddAttachmentAsync(Attachment attachment) |
Function to add a single attachment to the message (the .NET library will grab the file contents from the specified file location) | |
AddAttachmentsAsync() |
AddAttachmentsAsync(List<string> file_locations) AddAttachmentsAsync(List<Attachment> attachments) |
Function to add multiple attachments to the message (the .NET library will grab the file contents from the specified file location) | |
SendMessageAsync() |
SendMessageAsync() SendMessageAsync( string message_id, string reference, DateTime send_time, string timezone, string subaccount, string department, string charge_code, string resolution, string csid ) SendMessageAsync( string message_id, string reference, DateTime send_time, string timezone, string subaccount, string department, string charge_code, string resolution, string csid, string watermark_folder, string watermark_firstpage, string watermark_allpages, int retry_attempts, int retry_period ) |
Function to submit messages to TNZ REST API Returns Task<IMessageResult> object |
Function | Usage | Description | |
---|---|---|---|
SetAuthToken() | SetAuthToken(string token) | Function to set Auth Token to send message [Required] |
|
SetAPIUser() | SetAPIUser(APIUser api_user) | Function to set APIUser to send message | |
SetAPISender() | SetAPISender(string sender) | Function to set API Sender (need to set SetAPIKey() with this) | |
SetAPIKey() | SetAPIKey(string api_key) | Function to set API Key (need to set SetAPISender() with this) | |
SetErrorEmailNotify() | SetErrorEmailNotify(string email) | Function to set Email Address to receive error notifications | |
SetWebhookCallbackURL() | SetWebhookCallbackURL(string url) | Overrides your Sender's default Webhook URL. Requires a default webhook to be configured. A full path including https:// is required. | |
SetWebhookCallbackFormat() | SetWebhookCallbackFormat(WebhookCallbackType type) | Overrides your Sender's default Webhook format ('JSON' or 'XML') | |
SetMessageID() | SetMessageID(string message_id) | Tracking ID or message description. Leave black if you want us to generate one. | |
SetReference() | SetReference(string reference) | Reference of your message | |
SetSendTime() | SetSendTime(DateTime time) | Delay sending until the specified date/time (dd/mm/yyyy HH:mm in your local timezone, specified by your Sender setting or overridden using the TimeZone command) | |
SetTimezone() | SetTimezone(string timezone) | User's local timezone (see Setting Timezones) | |
SetSubAccount() | SetSubAccount(string subaccount) | Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section. | |
SetDepartment() | SetDepartment(string department) | Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section. | |
SetChargeCode() | SetChargeCode(string code) | Bespoke app cost allocation code (for invoice segmentation) | |
SetResolution() | SetResolution(string resolution) | Quality of the fax image. High for better quality, low for lower quality (faster delivery speed) | |
SetCSID() | SetCSID(string csid) | Called Subscriber Identification - Maximum 30 characters | |
SetWatermarkFolder() | SetWatermarkFolder(string folder) | Directory/location of Watermark file to use | |
SetWatermarkFirstPage() | SetWatermarkFirstPage(string yesno) | Watermark file to apply to the first page only | |
SetWatermarkFirstPage() | SetWatermarkAllPages(string yesno) | Watermark file to apply to all pages | |
SetRetryAttempts() | SetRetryAttempts(int attempts) | Number of retries (retry_period required) | |
SetRetryPeriod() | SetRetryPeriod(int minutes) | Minutes between retries (retry_attempts required) | |
AddRecipient() |
AddRecipient(string recipient) AddRecipient(IRecipient recipient) |
Function to add a single message recipient [Required] |
|
AddRecipients() |
AddRecipients(List<string> recipients) AddRecipients(List<IRecipient> recipients) |
Function to add a list of message recipients | |
AddAttachment() | AddAttachment(string file_location) | Function to add a single attachment to the message (the .NET library will grab the file contents from the specified file location) [Required] |
|
AddAttachments() | AddAttachments(List<string> file_locations) | Function to add multiple attachments to the message (the .NET library will grab the file contents from the specified file location) | |
Build() | Build() | Builds the Fax() object and return IMessage [Required] |
|
BuildAsync() | BuildAsync() | Builds the Fax() object asynchronous and return Task<IMessage> |
using System;
using TNZAPI.Messaging.Functions;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
namespace TNZVoiceBasic
{
class Program
{
static void Main(string[] args)
{
Voice VoiceMessage = new Voice();
//
// You can use AuthToken (can find it from our web portal) if you prefer
//
VoiceMessage.AuthToken = "YOUR_AUTH_TOKEN"; // Auth Token
VoiceMessage.MessageToPeople = FileHandlers.GetFileContents("C:\\Voice.wav"); // WAV format, 16-bit, 8000hz
VoiceMessage.AddRecipient("+64211111111");
VoiceMessage.AddRecipient("+64222222222");
VoiceMessage.SendMessage();
MessageResult response = VoiceMessage.SendMessage();
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
namespace TNZVoiceSimple
{
class Program
{
static void Main(string[] args)
{
const string authToken = "YOUR_AUTH_TOKEN"; // Auth Token
const string recipient = "+64211111111"; // Recipient
const string file = "C:\\Voice.wav";
Voice VoiceMessage = new Voice(authToken);
VoiceMessage.AddMessageData(Voice.MessageDataType.MessageToPeople, file);
VoiceMessage.AddRecipient(recipient);
MessageResult response = VoiceMessage.SendMessage();
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
namespace TNZTTSBuilder
{
class Program
{
static void Main(string[] args)
{
//
// Sample code using TTSBuilder()
//
var request = new TTSBuilder()
.SetAuthToken("[Your Auth Token]") // Auth Token
.SetMessageToPeople("Hello, this is a call from test. This is relevant information.") // Message to People
.AddRecipient("+64211111111") // Recipient
.SetSendMode(Enums.SendModeType.Test) // TEST/Live mode
.Build(); // Build TTS() object
var response = request.SendMessage();
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
namespace TNZVoiceAdvanced
{
class Program
{
static void Main(string[] args)
{
const string auth_token = "YOUR_AUTH_TOKEN";
const string reference = "Test Voice - Advanced version";
const string webhook_callback_url = "https://example.com/webhook";
const Enums.WebhookCallbackType webhook_callback_format = Enums.WebhookCallbackType.XML;
const string error_email_notify = "notify@example.com";
const string caller_id = "+6499999999";
const string billing_account = "TEST BILLING ACCOUNT";
const string report_to = "report@example.com";
const string recipient1 = "+64211111111";
const string recipient2 = "+64212222222";
const string recipient3 = "+64213333333";
const string recipient4 = "+64214444444";
const string message_to_people = "C:\\Voice1.wav"; // WAV format, 16-bit, 8000hz
const string message_to_answerphones = "C:\\Voice2.wav"; // WAV format, 16-bit, 8000hz
const string call_route_message_to_people = "C:\\Voice3.wav"; // WAV format, 16-bit, 8000hz
const string call_route_message_to_operators = "C:\\Voice4.wav"; // WAV format, 16-bit, 8000hz
const string call_route_message_on_wrong_key = "C:\\Voice5.wav"; // WAV format, 16-bit, 8000hz
const int number_of_operators = 1;
const int retry_attempts = 2;
const int retry_period = 5;
const string keypad1_route = "+6491111111";
const string keypad2_route = "+6492222222";
const string keypad3_route = "+6493333333";
const string keypad4_route = "+6494444444";
Voice VoiceMessage = new Voice()
{
AuthToken = auth_token,
WebhookCallbackURL = webhook_callback_url,
WebhookCallbackFormat = webhook_callback_format,
ErrorEmailNotify = error_email_notify
};
#region Call Options
VoiceMessage.Reference = reference;
VoiceMessage.CallerID = caller_id;
VoiceMessage.SubAccount = billing_account;
VoiceMessage.ReportTo = report_to;
VoiceMessage.NumberOfOperators = number_of_operators;
VoiceMessage.RetryAttempts = retry_attempts;
VoiceMessage.RetryPeriod = retry_period;
#endregion Call Options
#region Submit Audio Files
//
// Submit audio files - WAV format, 16-bit, 8000hz
//
VoiceMessage.AddMessageData(Voice.MessageDataType.MessageToPeople, message_to_people);
VoiceMessage.AddMessageData(Voice.MessageDataType.MessageToAnswerPhones, message_to_answerphones);
VoiceMessage.AddMessageData(Voice.MessageDataType.CallRouteMessageToPeople, call_route_message_to_people);
VoiceMessage.AddMessageData(Voice.MessageDataType.CallRouteMessageToOperators, call_route_message_to_operators);
VoiceMessage.AddMessageData(Voice.MessageDataType.CallRouteMessageOnWrongKey, call_route_message_on_wrong_key);
#endregion Submit Audio Files
#region Add Keypads
//
// Add Keypad Method 1 - VoiceMessage.AddKeypad(int key, string keypad1_route);
//
VoiceMessage.AddKeypad(1, keypad1_route);
//
// Add Keypad Method 2 - AddKeypad(new Keypad());
//
VoiceMessage.AddKeypad(new Keypad(2, keypad2_route));
//
// Add Keypad Method 3 - AddKeypad(new List())
//
List keypad_list = new List();
keypad_list.Add(new Keypad(3, keypad3_route));
//
// Add Keypad Method 4 - AddKeypad(new List()) using Keypad objects
//
Keypad keypad4 = new Keypad();
keypad4.Tone = 4;
keypad4.RouteNumber = keypad4_route;
keypad_list.Add(keypad4);
//
// Add Keypad Method 5 - Add Play (Wave Data)
//
Keypad keypad5 = new Keypad();
keypad5.Tone = 5;
keypad5.PlayFile = "C:\\keypad5.wav";
keypad_list.Add(keypad5);
VoiceMessage.AddKeypads(keypad_list);
#endregion Add Keypads
#region Add Recipients
//
// Add Recipient Method 1 - AddRecipient(string recipient);
//
VoiceMessage.AddRecipient(recipient1);
//
// Add Recipient Method 2 - AddRecipient(new Recipient())
//
Recipient recipient = new Recipient(recipient2);
recipient.CompanyName = "Test Company"; // Company Name
recipient.Attention = "Test Recipient 2"; // Attention
recipient.Custom1 = "Custom1"; // Custom1
recipient.Custom2 = "Custom2"; // Custom2
recipient.Custom3 = "Custom3"; // Custom3
recipient.Custom4 = "Custom4"; // Custom4
recipient.Custom5 = "Custom5"; // Custom5
//VoiceMessage.AddRecipient(recipient);
//
// Add Recipient Method 3 - AddRecipients(new List()); using simple destination
//
List recipients = new List();
recipients.Add(new Recipient(recipient3));
//
// Add Recipient Method 4 - AddRecipients(new List()) using Recipient objects
//
recipients.Add(new Recipient(
recipient4, // Recipient
"Test Company", // Company Name
"Test Recipient 4", // Attention
"Custom1", // Custom1
"Custom2", // Custom2
"Custom3", // Custom3
"Custom4", // Custom4
"Custom5" // Custom5
));
VoiceMessage.AddRecipients(recipients);
#endregion Add Recipients
MessageResult response = VoiceMessage.SendMessage(
"", // MessageID - Leave blank to auto-generate
reference, // Reference
new DateTime(), // SendTime
"New Zealand", // Timezone
billing_account, // Billing Account (Sub Account)
"", // Department
"", // Charge Code
number_of_operators, // No of Operators - Limits the maximum simultaneous calls
caller_id, // Caller ID
"" // Options
);
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
Console.ReadLine();
}
}
}
Parameter | Example Value | Description | |
---|---|---|---|
AuthToken | eyJhbGciOiJI...adQssw5c | Auth Token value set up in Create a new API Auth token | |
MessageToPeople | [Base64encoded data] | The audio data played if the call is answered by a human (WAV format, 16-bit, 8000hz) | |
Recipient | +6495005001 | Telephone number(s) to receive the message (for detailed formatting, see the Destinations parameter below) |
Parameter | Example Value | Description | |
---|---|---|---|
MessageID | ID12345 | Tracking ID or message description. Leave black if you want us to generate one. | |
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') | |
Reference | Test1 | Reference of your message | |
SendTime | new DateTime() | Delay sending until the specified date/time (dd/mm/yyyy HH:mm 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 | [Base64encoded 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 | Telephone number for call routing in dialling format | |
> PlayFile | C:\Message.wav | Audio file played to B-Party when a keypad option is pressed (WAV format, 16-bit, 8000hz), eg "Thank you. You have pressed keypad 1." | |
CallRouteMessageToPeople | [Base64encoded data] | Audio data played when a keypad option is pressed (WAV format, 16-bit, 8000hz), eg "Connecting you now." | |
CallRouteMessageToOperators | [Base64encoded 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 | [Base64encoded 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) | |
RetryAttempts | 3 | Number of retry attempts if the recipients line is busy or unavailable | |
RetryPeriod | 1 | Minutes apart when performing retries | |
CallerID | +6495005000 | Sets the Caller ID used on the call (must be E.164 format) | |
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. | ||
Recipients | > PhoneNumber | +6495005000 | Recipient of the call in E.164 internationalised format (for localized or friendly formatting, contact your account manager) |
> Attention | John Doe | Recipient's name | |
> Company | Example Corp | Recipient's company | |
> Custom1 | Customisable field | ||
> Custom2 | Customisable field |
Function | Usage | Description | |
---|---|---|---|
AddRecipient() |
AddRecipient(string recipient) AddRecipient(Recipient recipient) |
Function to add a single message recipient | |
AddRecipients() |
AddRecipients(List<string> recipients) AddRecipients(List<Recipient> recipients) |
Function to add a list of message recipients | |
AddKeypad() |
AddKeypad(int tone, string route_number) AddKeypad(Keypad keypad) |
Function to add a keypad option (init tone=keypad button, route_number=number to divert the call to) | |
AddKeypads() | AddKeypads(List<Keypad> keypads) | Function to add a list of keypad options (init tone=keypad button, route_number=number to divert the call to) | |
AddMessageData() | AddMessageData(MessageDataType message_data_type, string file_location) | Function to add a WAV audio file to the message (the .NET library will grab the file contents from the specified file location) | |
SendMessage() |
SendMessage() SendMessage( string message_id, string reference, DateTime send_time, string timezone, string subaccount, string department, string charge_code, int number_of_operators, string caller_id, string options ) SendMessage( string message_id, string reference, DateTime send_time, string timezone, string subaccount, string department, string charge_code, string message_to_people, string message_to_answerphones, string call_route_message_to_people, string call_route_message_to_operators, string call_route_message_on_wrong_key, int number_of_operators, string caller_id, string options ) |
Function to submit messages to TNZ REST API Returns MessageResult object |
Function | Usage | Description | |
---|---|---|---|
AddMessageDataAsync() | AddMessageDataAsync(Voice.MessageDataType message_data_type, string file_location) | Function to add a WAV audio file to the message (the .NET library will grab the file contents from the specified file location) | |
SendMessageAsync() |
SendMessageAsync() SendMessageAsync( string message_id, string reference, DateTime send_time, string timezone, string subaccount, string department, string charge_code, int number_of_operators, string caller_id, string options ) SendMessageAsync( string message_id, string reference, DateTime send_time, string timezone, string subaccount, string department, string charge_code, string message_to_people, string message_to_answerphones, string call_route_message_to_people, string call_route_message_to_operators, string call_route_message_on_wrong_key, int number_of_operators, string caller_id, string options ) |
Function to submit messages to TNZ REST API Returns Task<IMessageResult> object |
Function | Usage | Description | |
---|---|---|---|
SetAuthToken() | SetAuthToken(string token) | Function to set Auth Token to send message [Required] |
|
SetAPIUser() | SetAPIUser(APIUser api_user) | Function to set APIUser to send message | |
SetAPISender() | SetAPISender(string sender) | Function to set API Sender (need to set SetAPIKey() with this) | |
SetAPIKey() | SetAPIKey(string api_key) | Function to set API Key (need to set SetAPISender() with this) | |
SetErrorEmailNotify() | SetErrorEmailNotify(string email) | Function to set Email Address to receive error notifications | |
SetWebhookCallbackURL() | SetWebhookCallbackURL(string url) | Overrides your Sender's default Webhook URL. Requires a default webhook to be configured. A full path including https:// is required. | |
SetWebhookCallbackFormat() | SetWebhookCallbackFormat(WebhookCallbackType type) | Overrides your Sender's default Webhook format ('JSON' or 'XML') | |
SetMessageID() | SetMessageID(string message_id) | Tracking ID or message description. Leave black if you want us to generate one. | |
SetReference() | SetReference(string reference) | Reference of your message | |
SetSendTime() | SetSendTime(DateTime time) | Delay sending until the specified date/time (dd/mm/yyyy HH:mm in your local timezone, specified by your Sender setting or overridden using the TimeZone command) | |
SetTimezone() | SetTimezone(string timezone) | User's local timezone (see Setting Timezones) | |
SetSubAccount() | SetSubAccount(string subaccount) | Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section. | |
SetDepartment() | SetDepartment(string department) | Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section. | |
SetChargeCode() | SetChargeCode(string code) | Bespoke app cost allocation code (for invoice segmentation) | |
SetCallerID() | SetCallerID(string caller_id) | Sets the Caller ID used on the call (must be E.164 format) | |
SetReportTo() | SetReportTo(string email) | For email (SMTP) message delivery report notifications. | |
SetOptions() | SetOptions(string 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. | |
SetNumberOfOperators() | SetNumberOfOperators(int operators) | Limits the maximum simultaneous calls (where multiple 'Destinations' are listed) | |
SetRetryAttempts() | SetRetryAttempts(int attempts) | Number of retries (retry_period required) | |
SetRetryPeriod() | SetRetryPeriod(int minutes) | Minutes between retries (retry_attempts required) | |
SetMessageToPeople() | SetMessageToPeople(string file_location) | The audio file played if the call is answered by a human (WAV format, 16-bit, 8000hz) - The .NET library will grab the file contents from the specified file location [Required] |
|
SetMessageToAnswerPhones() | SetMessageToAnswerPhones(string file_location) | The audio file played when the call is answered by an answering machine/voicemail service (WAV format, 16-bit, 8000hz) - The .NET library will grab the file contents from the specified file location | |
SetCallRouteMessageToPeople() | SetCallRouteMessageToPeople(string file_location) | The audio file played when a keypad option is pressed (WAV format, 16-bit, 8000hz), eg "Connecting you now." - The .NET library will grab the file contents from the specified file location | |
SetCallRouteMessageToOperators() | SetCallRouteMessageToOperators(string file_location) | The audio file played to the call centre representative answering the connected call (WAV format, 16-bit, 8000hz), eg "Incoming Text To Speech call." - The .NET library will grab the file contents from the specified file location | |
SetCallRouteMessageOnWrongKey() | SetCallRouteMessageOnWrongKey(string file_location) | The audio file played when an unregistered keypad button is pressed (WAV format, 16-bit, 8000hz), eg "Sorry, you have pressed an invalid key. Please try again" - The .NET library will grab the file contents from the specified file location | |
AddRecipient() |
AddRecipient(string recipient) AddRecipient(IRecipient recipient) |
Function to add a single message recipient [Required] |
|
AddRecipients() |
AddRecipients(List<string> recipients) AddRecipients(List<IRecipient> recipients) |
Function to add a list of message recipients | |
AddAttachment() | AddAttachment(string file_location) | Function to add a single attachment to the message (the .NET library will grab the file contents from the specified file location) [Required] |
|
AddAttachments() | AddAttachments(List<string> file_locations) | Function to add multiple attachments to the message (the .NET library will grab the file contents from the specified file location) | |
Build() | Build() | Builds the Voice() object and return IMessage [Required] |
|
BuildAsync() | BuildAsync() | Builds the Voice() object asynchronous and return Task<IMessage> |
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
namespace TNZTTSBasic
{
class Program
{
static void Main(string[] args)
{
TTS TTSMessage = new TTS();
//
// You can use AuthToken (can find it from our web portal) if you prefer
//
TTSMessage.AuthToken = "YOUR_AUTH_TOKEN"; // Auth Token
TTSMessage.MessageToPeople = "Hello, this is a call from test. This is relevant information.";
TTSMessage.AddRecipient("+64211111111");
TTSMessage.AddRecipient("+64222222222");
TTSMessage.TTSVoice = TTS.TTSVoiceType.Emma;
MessageResult response = TTSMessage.SendMessage();
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
namespace TNZTTSSimple
{
class Program
{
static void Main(string[] args)
{
const string authToken = "YOUR_AUTH_TOKEN"; // Auth Token
const string recipient = "+64211111111"; // Recipient
const string message_to_people = "Hello, this is a call from test. This is relevant information.";
TTS TTSMessage = new TTS(authToken);
TTSMessage.AddMessageData(TTS.MessageDataType.MessageToPeople, message_to_people);
TTSMessage.AddRecipient(recipient);
MessageResult response = TTSMessage.SendMessage();
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
namespace TNZTTSBuilder
{
class Program
{
static void Main(string[] args)
{
//
// Sample code using TTSBuilder()
//
var request = new TTSBuilder()
.SetAuthToken("[Your Auth Token]") // Auth Token
.SetMessageToPeople("Hello, this is a call from test. This is relevant information.") // Message to People
.AddRecipient("+64211111111") // Recipient
.SetSendMode(Enums.SendModeType.Test) // TEST/Live mode
.Build(); // Build TTS() object
var response = request.SendMessage();
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Send;
namespace TNZTTSAdvanced
{
class Program
{
static void Main(string[] args)
{
const string auth_token = "YOUR_AUTH_TOKEN";
const string reference = "Test TTS - Advanced version";
const string webhook_callback_url = "https://example.com/webhook";
const Enums.WebhookCallbackType webhook_callback_format = Enums.WebhookCallbackType.XML;
const string error_email_notify = "notify@example.com";
const string caller_id = "+6499999999";
const string billing_account = "TEST BILLING ACCOUNT";
const string report_to = "report@example.com";
const string recipient1 = "+64211111111";
const string recipient2 = "+64212222222";
const string recipient3 = "+64213333333";
const string recipient4 = "+64214444444";
const string message_to_people = "Hello, this is a call from Department01. This is relevant information. Press one to be connected to our call centre.";
const string message_to_answerphones = "Hello, sorry we missed you. This is a call from Department 01. Please contact us on 0800 123123.";
const string call_route_message_to_people = "Connecting you now.";
const string call_route_message_to_operators = "Incoming Text To Speech call.";
const string call_route_message_on_wrong_key = "Sorry, you have pressed an invalid key. Please try again.";
const int number_of_operators = 1;
const int retry_attempts = 3;
const int retry_period = 1;
const TTS.TTSVoiceType tts_voice = TTS.TTSVoiceType.Female1;
const string keypad1_route = "+6491111111";
const string keypad2_route = "+6492222222";
const string keypad3_play = "Hello, you have pressed 3.";
const string keypad4_route = "+6493333333";
const string keypad5_route = "+6494444444";
const string keypad6_play = "Hello, you have pressed 5.";
const string keypad7_route = "+6497777777";
const string keypad7_play = "Hello, you have pressed 6.";
TTS TTSMessage = new TTS()
{
AuthToken = auth_token,
WebhookCallbackURL = webhook_callback_url,
WebhookCallbackFormat = webhook_callback_format,
ErrorEmailNotify = error_email_notify
};
#region Call Options
TTSMessage.Reference = reference;
TTSMessage.CallerID = caller_id;
TTSMessage.SubAccount = billing_account;
TTSMessage.ReportTo = report_to;
TTSMessage.NumberOfOperators = number_of_operators;
TTSMessage.RetryAttempts = retry_attempts;
TTSMessage.RetryPeriod = retry_period;
#endregion Call Options
#region Submit TextToSpeech Messagess
//
// Submit TextToSpeech Messagess (Text format only)
//
TTSMessage.AddMessageData(TTS.MessageDataType.MessageToPeople, message_to_people);
TTSMessage.AddMessageData(TTS.MessageDataType.MessageToAnswerPhones, message_to_answerphones);
TTSMessage.AddMessageData(TTS.MessageDataType.CallRouteMessageToPeople, call_route_message_to_people);
TTSMessage.AddMessageData(TTS.MessageDataType.CallRouteMessageToOperators, call_route_message_to_operators);
TTSMessage.AddMessageData(TTS.MessageDataType.CallRouteMessageOnWrongKey, call_route_message_on_wrong_key);
#endregion Submit Audio Files
#region Add Keypads
//
// Add Keypad Method 1 - VoiceMessage.AddKeypad(int key, string keypad1_route);
//
TTSMessage.AddKeypad(1, keypad1_route);
//
// Add Keypad Method 2 - AddKeypad(new Keypad());
//
TTSMessage.AddKeypad(new Keypad(2, keypad2_route));
//
// Add Keypad Method 3 - AddKeypad with Play data
//
TTSMessage.AddKeypad(3, Keypad.KeypadType.Play, keypad3_play);
//
// Add Keypad Method 4 - AddKeypad(new List())
//
List keypad_list = new List();
keypad_list.Add(new Keypad(4, keypad4_route));
//
// Add Keypad Method 5 - AddKeypad(new List()) using Keypad objects
//
Keypad keypad5 = new Keypad();
keypad5.Tone = 5;
keypad5.RouteNumber = keypad5_route;
keypad_list.Add(keypad5);
//
// Add Keypad Method 6 - AddKeypad(new List()) with Play using Keypad objects
//
Keypad keypad6 = new Keypad();
keypad6.Tone = 6;
keypad6.Play = keypad6_play;
keypad_list.Add(keypad6);
//
// Add Keypad Method 7 - AddKeypad(new List()) with RouteNumber and Play using Keypad objects
//
Keypad keypad7 = new Keypad();
keypad7.Tone = 7;
keypad7.Play = keypad7_play;
keypad7.RouteNumber = keypad7_route;
keypad_list.Add(keypad7);
TTSMessage.AddKeypads(keypad_list);
#endregion Add Keypads
#region Add Recipients
//
// Add Recipient Method 1 - AddRecipient(string recipient);
//
TTSMessage.AddRecipient(recipient1);
//
// Add Recipient Method 2 - AddRecipient(new Recipient())
//
Recipient recipient = new Recipient(recipient2);
recipient.CompanyName = "Test Company"; // Company Name
recipient.Attention = "Test Recipient 2"; // Attention
recipient.Custom1 = "Custom1"; // Custom1
recipient.Custom2 = "Custom2"; // Custom2
recipient.Custom3 = "Custom3"; // Custom3
recipient.Custom4 = "Custom4"; // Custom4
recipient.Custom5 = "Custom5"; // Custom5
TTSMessage.AddRecipient(recipient);
//
// Add Recipient Method 3 - AddRecipients(new List()); using simple destination
//
List recipients = new List();
recipients.Add(new Recipient(recipient3));
//
// Add Recipient Method 4 - AddRecipients(new List()) using Recipient objects
//
recipients.Add(new Recipient(
recipient4, // Recipient
"Test Company", // Company Name
"Test Recipient 4", // Attention
"Custom1", // Custom1
"Custom2", // Custom2
"Custom3", // Custom3
"Custom4", // Custom4
"Custom5" // Custom5
));
TTSMessage.AddRecipients(recipients);
#endregion Add Recipients
MessageResult response = TTSMessage.SendMessage(
"", // MessageID - Leave blank to auto-generate
reference, // Reference
new DateTime(), // SendTime
"New Zealand", // Timezone
billing_account, // Billing Account (SubAccount)
"", // Department
"", // ChargeCode
number_of_operators, // No of Operators - Limits the maximum simultaneous calls
caller_id, // Caller ID
tts_voice, // Text-to-Speech voice to use (Male1, Female1, Female2, Female3, Female4)
"" // Options
);
if (response.Result == MessageResult.ResultCode.Success)
{
Console.WriteLine("Success - " + response.MessageID);
}
else
{
Console.WriteLine("Error - " + response.ErrorMessage);
}
Console.ReadLine();
}
}
}
Parameter | Example Value | Description | |
---|---|---|---|
AuthToken | eyJhbGciOiJI...adQssw5c | Auth Token value set up in Create a new API Auth token | |
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 | +6495005001 | Telephone number(s) to receive the message (for detailed formatting, see the Destinations parameter below) |
Parameter | Example Value | Description | |
---|---|---|---|
MessageID | ID12345 | Tracking ID or message description. Leave black if you want us to generate one. | |
Reference | Test1 | Reference of your message | |
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 | new DateTime() | Delay sending until the specified date/time (dd/mm/yyyy HH:mm 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 | Telephone number for call routing in dialling format | |
> Play | You pressed Keypad 1 | Message played to B-Party when a keypad option is pressed | |
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) | |
RetryAttempts | 3 | Number of retry attempts if the recipients line is busy or unavailable | |
RetryPeriod | 1 | Minutes apart when performing retries | |
CallerID | 6495005000 | Sets the Caller ID used on the call (must be E.164 format) | |
TTSVoice | TTSVoiceType.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 | > PhoneNumber | +6495005000 | Recipient of the call in E.164 internationalised format (for localized or friendly formatting, contact your account manager) |
> Attention | John Doe | Recipient's name | |
> Company | Example Corp | Recipient's company | |
> Custom1 | Customisable field | ||
> Custom2 | Customisable field |
Function | Usage | Description | |
---|---|---|---|
AddRecipient() |
AddRecipient(string recipient) AddRecipient(Recipient recipient) |
Function to add a single message recipient | |
AddRecipients() |
AddRecipients(List<string> recipients) AddRecipients(List<Recipient> recipients) |
Function to add a list of message recipients | |
AddKeypad() |
AddKeypad(int tone, string route_number) AddKeypad(Keypad keypad) |
Function to add a keypad option (init tone=keypad button, route_number=number to divert the call to) | |
AddKeypads() | AddKeypads(List<Keypad> keypads) | Function to add a list of keypads option (init tone=keypad button, route_number=number to divert the call to) | |
AddMessageData() | AddMessageData(MessageDataType message_data_type, string tts_message) | Function to add Text-To-Speech content into message (text will be converted to speech) | |
SendMessage() |
SendMessage() SendMessage( string message_id, string reference, DateTime send_time, string timezone, string subaccount, string department, string charge_code, int number_of_operators, string caller_id, TTS.TTSVoiceType tts_voice, string options ) SendMessage( string message_id, string reference, DateTime send_time, string timezone, string subaccount, string department, string charge_code, string message_to_people, string message_to_answerphones, string call_route_message_to_people, string call_route_message_to_operators, string call_route_message_on_wrong_key, int number_of_operators, string caller_id, TTS.TTSVoiceType tts_voice, string options ) |
Function to submit messages to TNZ REST API Returns MessageResult object |
Function | Usage | Description | |
---|---|---|---|
SendMessageAsync() |
SendMessageAsync() SendMessageAsync( string message_id, string reference, DateTime send_time, string timezone, string subaccount, string department, string charge_code, int number_of_operators, string caller_id, TTS.TTSVoiceType tts_voice, string options ) SendMessageAsync( string message_id, string reference, DateTime send_time, string timezone, string subaccount, string department, string charge_code, string message_to_people, string message_to_answerphones, string call_route_message_to_people, string call_route_message_to_operators, string call_route_message_on_wrong_key, int number_of_operators, string caller_id, TTS.TTSVoiceType tts_voice, string options ) |
Function to submit messages to TNZ REST API Returns Task<IMessageResult> object |
Function | Usage | Description | |
---|---|---|---|
SetAuthToken() | SetAuthToken(string token) | Function to set Auth Token to send message [Required] |
|
SetAPIUser() | SetAPIUser(APIUser api_user) | Function to set APIUser to send message | |
SetAPISender() | SetAPISender(string sender) | Function to set API Sender (need to set SetAPIKey() with this) | |
SetAPIKey() | SetAPIKey(string api_key) | Function to set API Key (need to set SetAPISender() with this) | |
SetErrorEmailNotify() | SetErrorEmailNotify(string email) | Function to set Email Address to receive error notifications | |
SetWebhookCallbackURL() | SetWebhookCallbackURL(string url) | Overrides your Sender's default Webhook URL. Requires a default webhook to be configured. A full path including https:// is required. | |
SetWebhookCallbackFormat() | SetWebhookCallbackFormat(WebhookCallbackType type) | Overrides your Sender's default Webhook format ('JSON' or 'XML') | |
SetMessageID() | SetMessageID(string message_id) | Tracking ID or message description. Leave black if you want us to generate one. | |
SetReference() | SetReference(string reference) | Reference of your message | |
SetSendTime() | SetSendTime(DateTime time) | Delay sending until the specified date/time (dd/mm/yyyy HH:mm in your local timezone, specified by your Sender setting or overridden using the TimeZone command) | |
SetTimezone() | SetTimezone(string timezone) | User's local timezone (see Setting Timezones) | |
SetSubAccount() | SetSubAccount(string subaccount) | Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section. | |
SetDepartment() | SetDepartment(string department) | Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section. | |
SetChargeCode() | SetChargeCode(string code) | Bespoke app cost allocation code (for invoice segmentation) | |
SetCallerID() | SetCallerID(string caller_id) | Sets the Caller ID used on the call (must be E.164 format) | |
SetTTSVoice() | SetTTSVoice(TTSVoiceType type) | Text-to-Speech voice to use (Male1, Female1, Nicole, Russell, Amy, Brian, Emma) | |
SetReportTo() | SetReportTo(string email) | For email (SMTP) message delivery report notifications. | |
SetOptions() | SetOptions(string 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. | |
SetNumberOfOperators() | SetNumberOfOperators(int operators) | Limits the maximum simultaneous calls (where multiple 'Destinations' are listed) | |
SetRetryAttempts() | SetRetryAttempts(int attempts) | Number of retries (retry_period required) | |
SetRetryPeriod() | SetRetryPeriod(int minutes) | Minutes between retries (retry_attempts required) | |
SetMessageToPeople() | SetMessageToPeople(string message) | The text-to-speech message played if the call is answered by a human (may optionally include SSML commands) [Required] |
|
SetMessageToAnswerPhones() | SetMessageToAnswerPhones(string message) | The text-to-speech message played when the call is answered by an answering machine/voicemail service (may optionally include SSML commands) | |
SetCallRouteMessageToPeople() | SetCallRouteMessageToPeople(string message) | Text-to-speech message played when a keypad option is pressed< | |
SetCallRouteMessageToOperators() | SetCallRouteMessageToOperators(string message) | Text-to-speech message played to the call centre representative answering the connected call | |
SetCallRouteMessageOnWrongKey() | SetCallRouteMessageOnWrongKey(string message) | Text-to-speech message played when an unregistered keypad button is pressed | |
AddRecipient() |
AddRecipient(string recipient) AddRecipient(IRecipient recipient) |
Function to add a single message recipient [Required] |
|
AddRecipients() |
AddRecipients(List<string> recipients) AddRecipients(List<IRecipient> recipients) |
Function to add a list of message recipients | |
AddAttachment() | AddAttachment(string file_location) | Function to add a single attachment to the message (the .NET library will grab the file contents from the specified file location) [Required] |
|
AddAttachments() | AddAttachments(List<string> file_locations) | Function to add multiple attachments to the message (the .NET library will grab the file contents from the specified file location) | |
Build() | Build() | Builds the TTS() object and return IMessage [Required] |
|
BuildAsync() | BuildAsync() | Builds the TTS() object asynchronous and return Task<IMessage> |
Under Message
object you can specify an additional SendMode=Test parameter.
SendMode=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.
// For Email
EmailMessage.SendMode = Enums.SendModeType.Test;
// For SMS
SMSMessage.SendMode = Enums.SendModeType.Test;
// For Fax
FaxMessage.SendMode = Enums.SendModeType.Test;
// For Voice
VoiceMessage.SendMode = Enums.SendModeType.Test;
// For TTS
TTSMessage.SendMode = Enums.SendModeType.Test;
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.
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.
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Set;
namespace TNZSetResubmit
{
class Program
{
static void Main(string[] args)
{
ResubmitRequest request = new ResubmitRequest
{
AuthToken = "YOUR_AUTH_TOKEN", // Auth Token
//Sender = "application@domain.com", // API Sender - Using Auth Token is recommended
//APIKey = "ta8wr7ymd", // API Key - Using Auth Token is recommended
MessageID = "ID123456" // MessageID
};
ResubmitRequestResult response = request.Submit();
if (response.Result == ResubmitRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + response.MessageID + "':");
Console.WriteLine(" => Status: '" + response.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + response.JobNum + "'");
Console.WriteLine(" => Action: '" + response.Action + "'");
}
else
{
Console.WriteLine("Cannot find MessageID '" + request.MessageID + "' : '" + response.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Set;
namespace TNZSetResubmit
{
class Program
{
static void Main(string[] args)
{
ResubmitRequest request = new ResubmitRequest
{
AuthToken = "YOUR_AUTH_TOKEN", // Auth Token
//Sender = "application@domain.com", // API Sender - Using Auth Token is recommended
//APIKey = "ta8wr7ymd", // API Key - Using Auth Token is recommended
MessageID = "ID123456" // MessageID
};
ResubmitRequestResult response = request.Submit();
if (response.Result == ResubmitRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + response.MessageID + "':");
Console.WriteLine(" => Status: '" + response.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + response.JobNum + "'");
Console.WriteLine(" => Action: '" + response.Action + "'");
}
else
{
Console.WriteLine("Cannot find MessageID '" + request.MessageID + "' : '" + response.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Set;
namespace TNZSetResubmitBuilder
{
class Program
{
static void Main(string[] args)
{
//
// Sample code using ResubmitRequestBuilder()
//
var request = new ResubmitRequestBuilder()
.SetAuthToken("[Your Auth Token]") // Auth Token
.SetMessageID("ID123456") // MessageID
.SetSendTime(new DateTime().AddMinutes(5)) // Optional: Set SendTime
.Build(); // Build ResubmitRequestBuilder() object
var result = request.Submit();
if (result.Result == ResubmitRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + result.MessageID + "':");
Console.WriteLine(" => Status: '" + result.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + result.JobNum + "'");
Console.WriteLine(" => Action: '" + result.Action + "'");
}
else
{
Console.WriteLine("Cannot find MessageID '" + request.MessageID + "' : '" + result.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Set;
namespace TNZSetResubmit
{
class Program
{
static void Main(string[] args)
{
ResubmitRequest request = new ResubmitRequest
{
AuthToken = "YOUR_AUTH_TOKEN", // Auth Token
//Sender = "application@domain.com", // API Sender - Using Auth Token is recommended
//APIKey = "ta8wr7ymd", // API Key - Using Auth Token is recommended
MessageID = "ID123456" // MessageID
};
ResubmitRequestResult response = request.Submit();
if (response.Result == ResubmitRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + response.MessageID + "':");
Console.WriteLine(" => Status: '" + response.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + response.JobNum + "'");
Console.WriteLine(" => Action: '" + response.Action + "'");
}
else
{
Console.WriteLine("Cannot find MessageID '" + request.MessageID + "' : '" + response.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
Parameter | Example Value | Description | |
---|---|---|---|
AuthToken | eyJhbGciOiJI...adQssw5c | Auth Token value set up in Create a new API Auth token | |
MessageID | ID123456 | MessageID the Action should apply to |
Parameter | Type | Example Value | Description | |
---|---|---|---|---|
ResultCode | enum | Success | Types of ResultCode | |
Result | ResultCode | ResultCode.Success | Result of your API call (not the result of the message) | |
StatusCode | enum | Transmit | Types of StatusCode | |
Status | Status | Status.Transmit | Current Status of your message | |
JobNum | String | ABCD1234 | Your Job Number | |
Action | String | Resubmit | What action (Resubmit) was requested | |
ErrorMessage | String | Missing Sender | Reason for the API call failure (see a list of possible values: TNZ API Errors) |
Function | Usage | Description | |
---|---|---|---|
SetAuthToken() | SetAuthToken(string token) | Function to set Auth Token to send message [Required] |
|
SetAPIUser() | SetAPIUser(APIUser api_user) | Function to set APIUser to send message | |
SetAPISender() | SetAPISender(string sender) | Function to set API Sender (need to set SetAPIKey() with this) | |
SetAPIKey() | SetAPIKey(string api_key) | Function to set API Key (need to set SetAPISender() with this) | |
SetMessageID() | SetMessageID(string message_id) | MessageID the Action should apply to [Required] |
|
SetSendTime() | SetSendTime(DateTime send_time) | Delay sending until the specified date/time | |
Build() | Build() | Builds the ResubmitRequest() object and return IResubmitRequest [Required] |
|
BuildAsync() | BuildAsync() | Builds the ResubmitRequest() object asynchronous and return Task<IResubmitRequest> |
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.
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Set;
namespace TNZSetReschedule
{
class Program
{
static void Main(string[] args)
{
RescheduleRequest request = new RescheduleRequest
{
AuthToken = "YOUR_AUTH_TOKEN", // Auth Token
//Sender = "application@domain.com", // API Sender - Using Auth Token is recommended
//APIKey = "ta8wr7ymd", // API Key - Using Auth Token is recommended
MessageID = "ID123456", // MessageID
SendTime = DateTime.Parse("2021-12-31 12:00:00") // Set send time
};
RescheduleRequestResult result = request.Submit();
if (result.Result == RescheduleRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + result.MessageID + "':");
Console.WriteLine(" => Status: '" + result.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + result.JobNum + "'");
Console.WriteLine(" => Action: '" + result.Action + "'");
}
else
{
Console.WriteLine("Error occurred while processing MessageID '" + request.MessageID + "' : '" + result.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Set;
namespace TNZSetReschedule
{
class Program
{
static void Main(string[] args)
{
RescheduleRequest request = new RescheduleRequest
{
AuthToken = "YOUR_AUTH_TOKEN", // Auth Token
//Sender = "application@domain.com", // API Sender - Using Auth Token is recommended
//APIKey = "ta8wr7ymd", // API Key - Using Auth Token is recommended
MessageID = "ID123456", // MessageID
SendTime = DateTime.Parse("2021-12-31 12:00:00") // Set send time
};
RescheduleRequestResult result = request.Submit();
if (result.Result == RescheduleRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + result.MessageID + "':");
Console.WriteLine(" => Status: '" + result.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + result.JobNum + "'");
Console.WriteLine(" => Action: '" + result.Action + "'");
}
else
{
Console.WriteLine("Error occurred while processing MessageID '" + request.MessageID + "' : '" + result.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Set;
namespace TNZSetRescheduleBuilder
{
class Program
{
static void Main(string[] args)
{
//
// Sample code using RescheduleRequestBuilder()
//
var request = new RescheduleRequestBuilder()
.SetAuthToken("[Your Auth Token]") // Auth Token
.SetMessageID("ID123456") // MessageID
.SetSendTime(new DateTime().AddMinutes(5)) // Set SendTime
.Build(); // Build AbortRequest() object
var result = request.Submit();
if (result.Result == RescheduleRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + result.MessageID + "':");
Console.WriteLine(" => Status: '" + result.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + result.JobNum + "'");
Console.WriteLine(" => Action: '" + result.Action + "'");
}
else
{
Console.WriteLine("Error occurred while processing MessageID '" + request.MessageID + "' : '" + result.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Set;
namespace TNZSetReschedule
{
class Program
{
static void Main(string[] args)
{
RescheduleRequest request = new RescheduleRequest
{
AuthToken = "YOUR_AUTH_TOKEN", // Auth Token
//Sender = "application@domain.com", // API Sender - Using Auth Token is recommended
//APIKey = "ta8wr7ymd", // API Key - Using Auth Token is recommended
MessageID = "ID123456", // MessageID
SendTime = DateTime.Parse("2021-12-31 12:00:00") // Set send time
};
RescheduleRequestResult result = request.Submit();
if (result.Result == RescheduleRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + result.MessageID + "':");
Console.WriteLine(" => Status: '" + result.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + result.JobNum + "'");
Console.WriteLine(" => Action: '" + result.Action + "'");
}
else
{
Console.WriteLine("Error occurred while processing MessageID '" + request.MessageID + "' : '" + result.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
Parameter | Example Value | Description | |
---|---|---|---|
AuthToken | eyJhbGciOiJI...adQssw5c | Auth Token value set up in Create a new API Auth token | |
MessageID | ID123456 | MessageID the Action should apply to | |
SendTime | 2020-05-12 14:05:00 | Reschedule sending for the specified date/time (dd/mm/yyyy HH:mm in your Account/Sender's default timezone setting) |
Parameter | Type | Example Value | Description | |
---|---|---|---|---|
ResultCode | enum | Success | Types of ResultCode | |
Result | ResultCode | ResultCode.Success | Result of your API call (not the result of the message) | |
StatusCode | enum | Delayed | Types of StatusCode | |
Status | Status | Status.Delayed | Current Status of your message | |
JobNum | String | ABCD1234 | Your Job Number | |
Action | String | Reschedule | What action (Reschedule) was requested | |
ErrorMessage | String | Missing Sender | Reason for the API call failure (see a list of possible values: TNZ API Errors) |
Function | Usage | Description | |
---|---|---|---|
SetAuthToken() | SetAuthToken(string token) | Function to set Auth Token to send message [Required] |
|
SetAPIUser() | SetAPIUser(APIUser api_user) | Function to set APIUser to send message | |
SetAPISender() | SetAPISender(string sender) | Function to set API Sender (need to set SetAPIKey() with this) | |
SetAPIKey() | SetAPIKey(string api_key) | Function to set API Key (need to set SetAPISender() with this) | |
SetMessageID() | SetMessageID(string message_id) | MessageID the Action should apply to [Required] |
|
SetSendTime() | SetSendTime(DateTime send_time) | Reschedule specified date/time[Required] | |
Build() | Build() | Builds the RescheduleRequest() object and return IRescheduleRequest [Required] |
|
BuildAsync() | BuildAsync() | Builds the RescheduleRequest() object asynchronous and return Task<IRescheduleRequest> |
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.
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Set;
namespace TNZSetAbort
{
class Program
{
static void Main(string[] args)
{
//
// AuthToken can be found from our web portal
//
AbortRequest request = new AbortRequest
{
AuthToken = "[YOUR_AUTH_TOKEN]", // Auth Token
//Sender = "application@domain.com", // API Sender - Using Auth Token is recommended
//APIKey = "ta8wr7ymd", // API Key - Using Auth Token is recommended
MessageID = "ID123456" // MessageID
};
AbortRequestResult result = request.Submit();
if (result.Result == AbortRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + result.MessageID + "':");
Console.WriteLine(" => Status: '" + result.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + result.JobNum + "'");
Console.WriteLine(" => Action: '" + result.Action + "'");
}
else
{
Console.WriteLine("Error occurred while processing MessageID '" + request.MessageID + "' : '" + result.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Set;
namespace TNZSetAbort
{
class Program
{
static void Main(string[] args)
{
//
// AuthToken can be found from our web portal
//
AbortRequest request = new AbortRequest
{
AuthToken = "[YOUR_AUTH_TOKEN]", // Auth Token
//Sender = "application@domain.com", // API Sender - Using Auth Token is recommended
//APIKey = "ta8wr7ymd", // API Key - Using Auth Token is recommended
MessageID = "ID123456" // MessageID
};
AbortRequestResult result = request.Submit();
if (result.Result == AbortRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + result.MessageID + "':");
Console.WriteLine(" => Status: '" + result.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + result.JobNum + "'");
Console.WriteLine(" => Action: '" + result.Action + "'");
}
else
{
Console.WriteLine("Error occurred while processing MessageID '" + request.MessageID + "' : '" + result.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Set;
namespace TNZSetAbortBuilder
{
class Program
{
static void Main(string[] args)
{
//
// Sample code using AbortRequestBuilder()
//
var request = new AbortRequestBuilder()
.SetAuthToken("[Your Auth Token]") // Auth Token
.SetMessageID("ID123456") // MessageID
.Build(); // Build AbortRequest() object
var result = request.Submit();
if (result.Result == AbortRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + result.MessageID + "':");
Console.WriteLine(" => Status: '" + result.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + result.JobNum + "'");
Console.WriteLine(" => Action: '" + result.Action + "'");
}
else
{
Console.WriteLine("Error occurred while processing MessageID '" + request.MessageID + "' : '" + result.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Set;
namespace TNZSetAbort
{
class Program
{
static void Main(string[] args)
{
//
// AuthToken can be found from our web portal
//
AbortRequest request = new AbortRequest
{
AuthToken = "[YOUR_AUTH_TOKEN]", // Auth Token
//Sender = "application@domain.com", // API Sender - Using Auth Token is recommended
//APIKey = "ta8wr7ymd", // API Key - Using Auth Token is recommended
MessageID = "ID123456" // MessageID
};
AbortRequestResult result = request.Submit();
if (result.Result == AbortRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + result.MessageID + "':");
Console.WriteLine(" => Status: '" + result.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + result.JobNum + "'");
Console.WriteLine(" => Action: '" + result.Action + "'");
}
else
{
Console.WriteLine("Error occurred while processing MessageID '" + request.MessageID + "' : '" + result.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
Parameter | Example Value | Description | |
---|---|---|---|
AuthToken | eyJhbGciOiJI...adQssw5c | Auth Token value set up in Create a new API Auth token | |
MessageID | ID123456 | MessageID the Action should apply to |
Parameter | Type | Example Value | Description | |
---|---|---|---|---|
ResultCode | enum | Success | Types of ResultCode | |
Result | ResultCode | ResultCode.Success | Result of your API call (not the result of the message) | |
StatusCode | enum | Pending | Types of StatusCode | |
Status | Status | Status.Pending | Current Status of your message | |
JobNum | String | ABCD1234 | Your Job Number | |
Action | String | Abort | What action (Abort) was requested | |
ErrorMessage | String | Missing Sender | Reason for the API call failure (see a list of possible values: TNZ API Errors) |
Function | Usage | Description | |
---|---|---|---|
SetAuthToken() | SetAuthToken(string token) | Function to set Auth Token to send message [Required] |
|
SetAPIUser() | SetAPIUser(APIUser api_user) | Function to set APIUser to send message | |
SetAPISender() | SetAPISender(string sender) | Function to set API Sender (need to set SetAPIKey() with this) | |
SetAPIKey() | SetAPIKey(string api_key) | Function to set API Key (need to set SetAPISender() with this) | |
SetMessageID() | SetMessageID(string message_id) | MessageID the Action should apply to [Required] |
|
Build() | Build() | Builds the AbortRequest() object and return IAbortRequest [Required] |
|
BuildAsync() | BuildAsync() | Builds the AbortRequest() object asynchronous and return Task<IAbortRequest> |
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.
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Set;
namespace TNZSetPacing
{
class Program
{
static void Main(string[] args)
{
PacingRequest request = new PacingRequest
{
AuthToken = "[YOUR_AUTH_TOKEN]", // Auth Token
//Sender = "application@domain.com", // API Sender - Using Auth Token is recommended
//APIKey = "ta8wr7ymd", // API Key - Using Auth Token is recommended
MessageID = "ID123456", // MessageID
NumberOfOperators = 1 // No. of concurrent calls
};
PacingRequestResult result = request.Submit();
if (result.Result == PacingRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + result.MessageID + "':");
Console.WriteLine(" => Status: '" + result.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + result.JobNum + "'");
Console.WriteLine(" => Action: '" + result.Action + "'");
}
else
{
Console.WriteLine("Error occurred while processing MessageID '" + request.MessageID + "' : '" + result.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Set;
namespace TNZSetPacing
{
class Program
{
static void Main(string[] args)
{
PacingRequest request = new PacingRequest
{
AuthToken = "[YOUR_AUTH_TOKEN]", // Auth Token
//Sender = "application@domain.com", // API Sender - Using Auth Token is recommended
//APIKey = "ta8wr7ymd", // API Key - Using Auth Token is recommended
MessageID = "ID123456", // MessageID
NumberOfOperators = 1 // No. of concurrent calls
};
PacingRequestResult result = request.Submit();
if (result.Result == PacingRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + result.MessageID + "':");
Console.WriteLine(" => Status: '" + result.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + result.JobNum + "'");
Console.WriteLine(" => Action: '" + result.Action + "'");
}
else
{
Console.WriteLine("Error occurred while processing MessageID '" + request.MessageID + "' : '" + result.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Set;
namespace TNZSetPacingBuilder
{
class Program
{
static void Main(string[] args)
{
//
// Sample code using PacingRequestBuilder()
//
var request = new PacingRequestBuilder()
.SetAuthToken("[Your Auth Token]") // Auth Token
.SetMessageID("ID123456") // MessageID
.SetNumberOfOperators(5) // No. of concurrent calls
.Build(); // Build PacingRequest() object
var result = request.Submit();
if (result.Result == PacingRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + result.MessageID + "':");
Console.WriteLine(" => Status: '" + result.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + result.JobNum + "'");
Console.WriteLine(" => Action: '" + result.Action + "'");
}
else
{
Console.WriteLine("Error occurred while processing MessageID '" + request.MessageID + "' : '" + result.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Set;
namespace TNZSetPacing
{
class Program
{
static void Main(string[] args)
{
PacingRequest request = new PacingRequest
{
AuthToken = "[YOUR_AUTH_TOKEN]", // Auth Token
//Sender = "application@domain.com", // API Sender - Using Auth Token is recommended
//APIKey = "ta8wr7ymd", // API Key - Using Auth Token is recommended
MessageID = "ID123456", // MessageID
NumberOfOperators = 1 // No. of concurrent calls
};
PacingRequestResult result = request.Submit();
if (result.Result == PacingRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + result.MessageID + "':");
Console.WriteLine(" => Status: '" + result.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + result.JobNum + "'");
Console.WriteLine(" => Action: '" + result.Action + "'");
}
else
{
Console.WriteLine("Error occurred while processing MessageID '" + request.MessageID + "' : '" + result.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
Parameter | Example Value | Description | |
---|---|---|---|
AuthToken | eyJhbGciOiJI...adQssw5c | Auth Token value set up in Create a new API Auth token | |
MessageID | ID123456 | MessageID the Action should apply to | |
NumberOfOperators | 4 | NumberOfOperators value to apply |
Parameter | Type | Example Value | Description | |
---|---|---|---|---|
ResultCode | enum | Success | Types of ResultCode | |
Result | ResultCode | ResultCode.Success | Result of your API call (not the result of the message) | |
StatusCode | enum | Pending | Types of StatusCode | |
Status | Status | Status.Pending | Current Status of your message | |
JobNum | String | ABCD1234 | Your Job Number | |
Action | String | Pacing | What action (Pacing) was requested | |
ErrorMessage | String | Missing Sender | Reason for the API call failure (see a list of possible values: TNZ API Errors) |
Function | Usage | Description | |
---|---|---|---|
SetAuthToken() | SetAuthToken(string token) | Function to set Auth Token to send message [Required] |
|
SetAPIUser() | SetAPIUser(APIUser api_user) | Function to set APIUser to send message | |
SetAPISender() | SetAPISender(string sender) | Function to set API Sender (need to set SetAPIKey() with this) | |
SetAPIKey() | SetAPIKey(string api_key) | Function to set API Key (need to set SetAPISender() with this) | |
SetMessageID() | SetMessageID(string message_id) | MessageID the Action should apply to [Required] |
|
SetNumberOfOperators() | SetNumberOfOperators(int count) | Limits the maximum simultaneous calls (where multiple 'Destinations' are listed) [Required] |
|
Build() | Build() | Builds the PacingRequest() object and return IPacingRequest [Required] |
|
BuildAsync() | BuildAsync() | Builds the PacingRequest() object asynchronous and return Task<IPacingRequest> |
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.
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.
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.
The email address to receive SMS Reply reports can be specified on the original message submission using the SMSEmailReply
parameter.
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).
Webhook failures are retried every five minutes for a maximum of 24 hours.
Supplied parameters are:
Parameter | Example Value | Description | |
---|---|---|---|
AuthToken | eyJhbGciOiJI...adQssw5c | Auth Token value set up in Create a new API Auth token | |
Type | SMS | Type of Message ('Email', 'SMS', 'Fax', 'Voice' or 'TextToSpeech') | |
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. 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. | |
JobNumber | 10C7B9A0 | Eight digit alphanumeric tracking number (our internal Job Number) | |
SentTime | 16/10/2018 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 |
|
Message | Field will be blank; it is used by the Receive Messages webhook only | ||
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 |
You are able to poll for the status of a message via the GET Status API.
The Poll should be configured to timeout after 48 hours with no result.
Reference : TNZAPI.Messaging.Get
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Get;
namespace TNZGetStatus
{
class Program
{
static void Main(string[] args)
{
StatusRequest request = new StatusRequest();
request.AuthToken = "YOUR_AUTH_TOKEN"; // Auth Token
request.MessageID = "ID123456";
StatusRequestResult response = request.Poll();
if (response.Result == StatusRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + response.MessageID + "':");
Console.WriteLine(" => Status: '" + response.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + response.JobNum + "'");
Console.WriteLine(" => Account: '" + response.Account + "'");
Console.WriteLine(" => SubAccount: '" + response.SubAccount + "'");
Console.WriteLine(" => Department: '" + response.Department + "'");
Console.WriteLine(" => Count: " + response.Count.ToString());
Console.WriteLine(" => Complete: " + response.Complete.ToString());
Console.WriteLine(" => Success: " + response.Success.ToString());
Console.WriteLine(" => Failed: " + response.Failed.ToString());
}
else
{
Console.WriteLine("Cannot find MessageID '" + request.MessageID + "' : '" + response.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Get;
namespace TNZGetStatus
{
class Program
{
static void Main(string[] args)
{
StatusRequest request = new StatusRequest();
request.AuthToken = "YOUR_AUTH_TOKEN"; // Auth Token
request.MessageID = "ID123456";
StatusRequestResult response = request.Poll();
if (response.Result == StatusRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + response.MessageID + "':");
Console.WriteLine(" => Status: '" + response.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + response.JobNum + "'");
Console.WriteLine(" => Account: '" + response.Account + "'");
Console.WriteLine(" => SubAccount: '" + response.SubAccount + "'");
Console.WriteLine(" => Department: '" + response.Department + "'");
Console.WriteLine(" => Count: " + response.Count.ToString());
Console.WriteLine(" => Complete: " + response.Complete.ToString());
Console.WriteLine(" => Success: " + response.Success.ToString());
Console.WriteLine(" => Failed: " + response.Failed.ToString());
}
else
{
Console.WriteLine("Cannot find MessageID '" + request.MessageID + "' : '" + response.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Get;
using TNZAPI.Messaging.Objects;
namespace TNZGetStatusBuilder
{
class Program
{
static void Main(string[] args)
{
// Sample code use StatusRequestBuilder()
var request = new StatusRequestBuilder()
.SetAuthToken("[Your Auth Token]") // Auth Token
.SetMessageID("ID123456") // MessageID
.Build(); // Build StatusRequest() object
var response = request.Poll();
if (response.Result == StatusRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + response.MessageID + "':");
Console.WriteLine(" => Status: '" + response.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + response.JobNum + "'");
Console.WriteLine(" => Account: '" + response.Account + "'");
Console.WriteLine(" => SubAccount: '" + response.SubAccount + "'");
Console.WriteLine(" => Department: '" + response.Department + "'");
Console.WriteLine(" => Count: " + response.Count.ToString());
Console.WriteLine(" => Complete: " + response.Complete.ToString());
Console.WriteLine(" => Success: " + response.Success.ToString());
Console.WriteLine(" => Failed: " + response.Failed.ToString());
}
else
{
Console.WriteLine("Cannot find MessageID '" + request.MessageID + "' : '" + response.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Get;
namespace TNZGetStatus
{
class Program
{
static void Main(string[] args)
{
StatusRequest request = new StatusRequest();
request.AuthToken = "YOUR_AUTH_TOKEN"; // Auth Token
request.MessageID = "ID123456";
StatusRequestResult response = request.Poll();
if (response.Result == StatusRequestResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + response.MessageID + "':");
Console.WriteLine(" => Status: '" + response.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + response.JobNum + "'");
Console.WriteLine(" => Account: '" + response.Account + "'");
Console.WriteLine(" => SubAccount: '" + response.SubAccount + "'");
Console.WriteLine(" => Department: '" + response.Department + "'");
Console.WriteLine(" => Count: " + response.Count.ToString());
Console.WriteLine(" => Complete: " + response.Complete.ToString());
Console.WriteLine(" => Success: " + response.Success.ToString());
Console.WriteLine(" => Failed: " + response.Failed.ToString());
}
else
{
Console.WriteLine("Cannot find MessageID '" + request.MessageID + "' : '" + response.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
Parameter | Example Value | Description | |
---|---|---|---|
AuthToken | eyJhbGciOiJI...adQssw5c | Auth Token value set up in Create a new API Auth token | |
MessageID | ID123456 | Your provided Message ID or TNZ Group generated Message ID |
Function | Usage | Description | |
---|---|---|---|
SetAuthToken() | SetAuthToken(string token) | Function to set Auth Token to send message [Required] |
|
SetAPIUser() | SetAPIUser(APIUser api_user) | Function to set APIUser to send message | |
SetAPISender() | SetAPISender(string sender) | Function to set API Sender (need to set SetAPIKey() with this) | |
SetAPIKey() | SetAPIKey(string api_key) | Function to set API Key (need to set SetAPISender() with this) | |
SetMessageID() | SetMessageID(string message_id) | MessageID the Action should apply to [Required] |
|
Build() | Build() | Builds the StatusRequest() object and return IStatusRequest [Required] |
|
BuildAsync() | BuildAsync() | Builds the StatusRequest() object asynchronous and return Task<IStatusRequest> |
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.
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.
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.
When submitting SMS messages, specify the SMSEmailReply
parameter.
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).
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.
Supplied parameters are:
Parameter | Example Value | Description | |
---|---|---|---|
AuthToken | eyJhbGciOiJI...adQssw5c | Auth Token value set up in Create a new API Auth token | |
Type | SMSReply | Type of Message ('Email', 'SMS', 'Fax', 'Voice', 'TextToSpeech', 'SMSInbound' or 'SMSReply') | |
Destination | +6421000001 | Mobile number sending the SMS message (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/2018 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 |
You are able to poll for all received SMS messages in a given time-frame.
The Poll should be configured to timeout after 48 hours with no result.
Reference : TNZAPI.Messaging.Get
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Get;
namespace TNZ_Get_SMS_Received
{
class Program
{
static void Main(string[] args)
{
SMSReceivedRequest request = new SMSReceivedRequest();
request.AuthToken = "YOUR_AUTH_TOKEN"; // Auth Token
request.TimePeriod = 1440; // No. of minutes
SMSReceivedResult sms_received_result = request.Poll();
if (sms_received_result.Result == SMSReceivedResult.ResultCode.Success)
{
Console.WriteLine("Inbound SMS Messages for the Time Period '" + request.TimePeriod.ToString() + "':");
foreach (SMSReceivedMessage received in sms_received_result.ReceivedMessages)
{
Console.WriteLine("======================================");
Console.WriteLine(" => MessageReceived");
Console.WriteLine(" -> Date: '" + received.Date.ToString("yyyy-MM-dd hh:mm:ss") + "'");
Console.WriteLine(" -> From: '" + received.From + "'");
Console.WriteLine(" -> MessageText: '" + received.MessageText.Replace("'", "\'") + "'");
}
}
else
{
Console.WriteLine("Could not find any inbound sms messages for the time period '" + request.TimePeriod.ToString() + "' : '" + sms_received_result.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Get;
namespace TNZ_Get_SMS_Received
{
class Program
{
static void Main(string[] args)
{
SMSReceivedRequest request = new SMSReceivedRequest();
request.AuthToken = "YOUR_AUTH_TOKEN"; // Auth Token
request.TimePeriod = 1440; // No. of minutes
SMSReceivedResult sms_received_result = request.Poll();
if (sms_received_result.Result == SMSReceivedResult.ResultCode.Success)
{
Console.WriteLine("Inbound SMS Messages for the Time Period '" + request.TimePeriod.ToString() + "':");
foreach (SMSReceivedMessage received in sms_received_result.ReceivedMessages)
{
Console.WriteLine("======================================");
Console.WriteLine(" => MessageReceived");
Console.WriteLine(" -> Date: '" + received.Date.ToString("yyyy-MM-dd hh:mm:ss") + "'");
Console.WriteLine(" -> From: '" + received.From + "'");
Console.WriteLine(" -> MessageText: '" + received.MessageText.Replace("'", "\'") + "'");
}
}
else
{
Console.WriteLine("Could not find any inbound sms messages for the time period '" + request.TimePeriod.ToString() + "' : '" + sms_received_result.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Get;
using TNZAPI.Messaging.Objects;
namespace TNZGetSMSReceivedBuilder
{
internal class Program
{
static void Main(string[] args)
{
// Sample code use SMSReceivedRequestBuilder()
var request = new SMSReceivedRequestBuilder()
.SetAuthToken("[Your Auth Token]") // Auth Token
.SetTimePeriod(1440) // No. of minutes
.SetDateFrom( // Optional: Set DateFrom
DateTime.Parse("2022-08-01 00:00:00")
)
.SetDateTo( // Optional: Set DateTo
DateTime.Parse("2022-08-01 23:59:59")
)
.SetRecordsPerPage(10) // Optional: Set Records Per Page
.SetPage(1) // Optional: Current page
.Build(); // Build SMSReceivedRequest() object
var response = request.Poll();
if (response.Result == SMSReceivedResult.ResultCode.Success)
{
Console.WriteLine($"Inbound SMS Messages ( found):");
Console.WriteLine($" => {response.ReceivedMessages.Count} MessageReceived");
foreach (var message in response.ReceivedMessages)
{
Console.WriteLine("======================================");
Console.WriteLine(" => MessageReceived");
Console.WriteLine(" -> Date: '" + message.Date.ToString("yyyy-MM-dd hh:mm:ss") + "'");
Console.WriteLine(" -> From: '" + message.From + "'");
Console.WriteLine(" -> MessageText: '" + message.MessageText.Replace("'", "\'") + "'");
}
}
else
{
Console.WriteLine($"Error occurred while processing - '{response.ErrorMessage}'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Get;
namespace TNZ_Get_SMS_Received
{
class Program
{
static void Main(string[] args)
{
SMSReceivedRequest request = new SMSReceivedRequest();
request.AuthToken = "YOUR_AUTH_TOKEN"; // Auth Token
request.DateFrom = DateTime.Parse("2022-08-01T00:00:00"); // Return results from the date/time
request.DateTo = DateTime.Parse("2022-08-01T23:59:59"); // Return results to the date/time
request.RecordsPerPage = 10; // x numbers of records to return per request
request.Page = 1; // current location
SMSReceivedResult sms_received_result = request.Poll();
if (sms_received_result.Result == SMSReceivedResult.ResultCode.Success)
{
Console.WriteLine("Inbound SMS Messages for the Time Period '" + request.TimePeriod.ToString() + "':");
foreach (SMSReceivedMessage received in sms_received_result.ReceivedMessages)
{
Console.WriteLine("======================================");
Console.WriteLine(" => MessageReceived");
Console.WriteLine(" -> Date: '" + received.Date.ToString("yyyy-MM-dd hh:mm:ss") + "'");
Console.WriteLine(" -> From: '" + received.From + "'");
Console.WriteLine(" -> MessageText: '" + received.MessageText.Replace("'", "\'") + "'");
}
}
else
{
Console.WriteLine("Could not find any inbound sms messages for the time period '" + request.TimePeriod.ToString() + "' : '" + sms_received_result.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
Parameter | Example Value | Description | |
---|---|---|---|
AuthToken | eyJhbGciOiJI...adQssw5c | Auth Token value set up in Create a new API Auth token | |
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) |
Function | Usage | Description | |
---|---|---|---|
SetAuthToken() | SetAuthToken(string token) | Function to set Auth Token to send message [Required] |
|
SetAPIUser() | SetAPIUser(APIUser api_user) | Function to set APIUser to send message | |
SetAPISender() | SetAPISender(string sender) | Function to set API Sender (need to set SetAPIKey() with this) | |
SetAPIKey() | SetAPIKey(string api_key) | Function to set API Key (need to set SetAPISender() with this) | |
SetMessageID() | SetTimePeriod(int time_period) | Return results from the last x minutes [Required] |
|
SetDateFrom() | SetDateFrom(DateTime dateFrom) | Return results from the date, also need to set DateTo using SetDateTo() function | |
SetDateTo() | SetDateTo(DateTime dateFrom) | Return results to the date, also need to set DateTo using SetDateFrom() function | |
SetRecordsPerPage() | SetRecordsPerPage(int count) | Return x number of records per request | |
SetPage(int page) | SetPage(int page) | Current location (page number) | |
Build() | Build() | Builds the SMSReceivedRequest() object and return ISMSReceivedRequest [Required] |
|
BuildAsync() | BuildAsync() | Builds the SMSReceivedRequest() object asynchronous and return Task<ISMSReceivedRequest> |
Parameter | Type | Example Value | Description | |
---|---|---|---|---|
ResultCode | enum | Success | Types of ResultCode | |
Result | ResultCode | ResultCode.Success | Result of your API call (not the result of the message) | |
ReceivedMessages | List<SMSReceivedMessage> | SMSReceivedMessage | List of SMS messages received | |
ErrorMessage | String | Missing Sender | Reason for the API call failure (see a list of possible values: TNZ API Errors) |
Parameter | Type | Example Value | Description | |
---|---|---|---|---|
Date | DateTime | 2019-12-01 14:02:03 | Date/Time SMS was received (yyyy-mm-dd HH:mm:ss) | |
From | String | +6421000001 | Sender of the SMS in E.164 internationalised format | |
MessageText | String | This is a reply back from the mobile phone. | The SMS message received |
You are able to poll for replies to a specific SMS message, tracked using the MessageID on the outbound message.
The Poll should be configured to timeout after 48 hours with no result.
Reference : TNZAPI.Messaging.Get
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Get;
namespace TNZGetSMSReply
{
class Program
{
static void Main(string[] args)
{
SMSReplyRequest request = new SMSReplyRequest();
request.AuthToken = "YOUR_AUTH_TOKEN"; // Auth Token
request.MessageID = "ID123456";
SMSReplyResult response = request.Poll();
if (response.Result == SMSReplyResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + response.MessageID + "':");
Console.WriteLine(" => Status: '" + response.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + response.JobNum + "'");
Console.WriteLine(" => Account: '" + response.Account + "'");
Console.WriteLine(" => SubAccount: '" + response.SubAccount + "'");
Console.WriteLine(" => Department: '" + response.Department + "'");
Console.WriteLine("======================================");
Console.WriteLine(" => MessageSent");
Console.WriteLine(" -> Date: '" + response.SentMessage.Date.ToString("yyyy-MM-dd hh:mm:ss") + "'");
Console.WriteLine(" -> Destination: '" + response.SentMessage.Destination + "'");
Console.WriteLine(" -> MessageText: '" + response.SentMessage.MessageText + "'");
foreach (SMSReceivedMessage received in response.ReceivedMessages)
{
Console.WriteLine("======================================");
Console.WriteLine(" => MessageReceived");
Console.WriteLine(" -> Date: '" + received.Date.ToString("yyyy-MM-dd hh:mm:ss") + "'");
Console.WriteLine(" -> From: '" + received.From + "'");
Console.WriteLine(" -> MessageText: '" + received.MessageText + "'");
}
}
else
{
Console.WriteLine("Cannot find MessageID '" + request.MessageID + "' : '" + response.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Get;
namespace TNZGetSMSReply
{
class Program
{
static void Main(string[] args)
{
SMSReplyRequest request = new SMSReplyRequest();
request.AuthToken = "YOUR_AUTH_TOKEN"; // Auth Token
request.MessageID = "ID123456";
SMSReplyResult response = request.Poll();
if (response.Result == SMSReplyResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + response.MessageID + "':");
Console.WriteLine(" => Status: '" + response.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + response.JobNum + "'");
Console.WriteLine(" => Account: '" + response.Account + "'");
Console.WriteLine(" => SubAccount: '" + response.SubAccount + "'");
Console.WriteLine(" => Department: '" + response.Department + "'");
Console.WriteLine("======================================");
Console.WriteLine(" => MessageSent");
Console.WriteLine(" -> Date: '" + response.SentMessage.Date.ToString("yyyy-MM-dd hh:mm:ss") + "'");
Console.WriteLine(" -> Destination: '" + response.SentMessage.Destination + "'");
Console.WriteLine(" -> MessageText: '" + response.SentMessage.MessageText + "'");
foreach (SMSReceivedMessage received in response.ReceivedMessages)
{
Console.WriteLine("======================================");
Console.WriteLine(" => MessageReceived");
Console.WriteLine(" -> Date: '" + received.Date.ToString("yyyy-MM-dd hh:mm:ss") + "'");
Console.WriteLine(" -> From: '" + received.From + "'");
Console.WriteLine(" -> MessageText: '" + received.MessageText + "'");
}
}
else
{
Console.WriteLine("Cannot find MessageID '" + request.MessageID + "' : '" + response.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Get;
using TNZAPI.Messaging.Objects;
namespace TNZGetSMSReplyBuilder
{
class Program
{
static void Main(string[] args)
{
// Sample code use SMSReplyRequestBuilder()
var request = new SMSReplyRequestBuilder()
.SetAuthToken("[Your Auth Token]") // Auth Token
.SetMessageID("ID123456") // MessageID
.Build(); // Build SMSReplyRequest() object
var response = request.Poll();
if (response.Result == SMSReplyResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + response.MessageID + "':");
Console.WriteLine(" => Status: '" + response.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + response.JobNum + "'");
Console.WriteLine(" => Account: '" + response.Account + "'");
Console.WriteLine(" => SubAccount: '" + response.SubAccount + "'");
Console.WriteLine(" => Department: '" + response.Department + "'");
Console.WriteLine("======================================");
Console.WriteLine(" => MessageSent");
Console.WriteLine(" -> Date: '" + response.SentMessage.Date.ToString("yyyy-MM-dd hh:mm:ss") + "'");
Console.WriteLine(" -> Destination: '" + response.SentMessage.Destination + "'");
Console.WriteLine(" -> MessageText: '" + response.SentMessage.MessageText + "'");
foreach (SMSReceivedMessage received in response.ReceivedMessages)
{
Console.WriteLine("======================================");
Console.WriteLine(" => MessageReceived");
Console.WriteLine(" -> Date: '" + received.Date.ToString("yyyy-MM-dd hh:mm:ss") + "'");
Console.WriteLine(" -> From: '" + received.From + "'");
Console.WriteLine(" -> MessageText: '" + received.MessageText + "'");
}
}
else
{
Console.WriteLine("Cannot find MessageID '" + request.MessageID + "' : '" + response.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
using System;
using TNZAPI.Messaging.Objects;
using TNZAPI.Messaging.Get;
namespace TNZGetSMSReply
{
class Program
{
static void Main(string[] args)
{
SMSReplyRequest request = new SMSReplyRequest();
request.AuthToken = "YOUR_AUTH_TOKEN"; // Auth Token
request.MessageID = "ID123456";
SMSReplyResult response = request.Poll();
if (response.Result == SMSReplyResult.ResultCode.Success)
{
Console.WriteLine("Status of MessageID '" + response.MessageID + "':");
Console.WriteLine(" => Status: '" + response.GetStatusString() + "'");
Console.WriteLine(" => JobNum: '" + response.JobNum + "'");
Console.WriteLine(" => Account: '" + response.Account + "'");
Console.WriteLine(" => SubAccount: '" + response.SubAccount + "'");
Console.WriteLine(" => Department: '" + response.Department + "'");
Console.WriteLine("======================================");
Console.WriteLine(" => MessageSent");
Console.WriteLine(" -> Date: '" + response.SentMessage.Date.ToString("yyyy-MM-dd hh:mm:ss") + "'");
Console.WriteLine(" -> Destination: '" + response.SentMessage.Destination + "'");
Console.WriteLine(" -> MessageText: '" + response.SentMessage.MessageText + "'");
foreach (SMSReceivedMessage received in response.ReceivedMessages)
{
Console.WriteLine("======================================");
Console.WriteLine(" => MessageReceived");
Console.WriteLine(" -> Date: '" + received.Date.ToString("yyyy-MM-dd hh:mm:ss") + "'");
Console.WriteLine(" -> From: '" + received.From + "'");
Console.WriteLine(" -> MessageText: '" + received.MessageText + "'");
}
}
else
{
Console.WriteLine("Cannot find MessageID '" + request.MessageID + "' : '" + response.ErrorMessage + "'");
}
Console.ReadLine();
}
}
}
Parameter | Example Value | Description | |
---|---|---|---|
AuthToken | eyJhbGciOiJI...adQssw5c | Auth Token value set up in Create a new API Auth token | |
MessageID | ID123456 | Your provided Message ID or TNZ Group generated Message ID |
Function | Usage | Description | |
---|---|---|---|
SetAuthToken() | SetAuthToken(string token) | Function to set Auth Token to send message [Required] |
|
SetAPIUser() | SetAPIUser(APIUser api_user) | Function to set APIUser to send message | |
SetAPISender() | SetAPISender(string sender) | Function to set API Sender (need to set SetAPIKey() with this) | |
SetAPIKey() | SetAPIKey(string api_key) | Function to set API Key (need to set SetAPISender() with this) | |
SetMessageID() | SetTimePeriod(int time_period) | Return results from the last x minutes [Required] |
|
Build() | Build() | Builds the SMSReplyRequest() object and return ISMSReplyRequest [Required] |
|
BuildAsync() | BuildAsync() | Builds the SMSReplyRequest() object asynchronous and return Task<ISMSReplyRequest> |
Parameter | Type | Example Value | Description | |
---|---|---|---|---|
ResultCode | enum | Success | Types of ResultCode | |
StatusCode | enum | Success | Types of StatusCode | |
Result | ResultCode | ResultCode.Success | Result of your API call (not the result of the message) | |
Status | StatusCode | StatusCode.Received | Status of your job | |
MessageID | String | AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD | Your provided Message ID or TNZ Group generated Message ID | |
JobNum | String | 10AB20CE | Eight digit alphanumeric tracking number (our internal Job Number) | |
Account | String | 102030 | Your TNZ Account | |
SubAccount | String | Your supplied TNZ SubAccount | ||
Department | String | Your supplied TNZ Department | ||
SentMessage | SMSSentMessage | SMSSentMessage Object | Details of your sent message | |
ReplyMessages | List<SMSReplyMessage> | SMSReplyMessage Objects | Details of your received message(s) | |
ErrorMessage | String | Missing Sender | Reason for the API call failure (see a list of possible values: TNZ API Errors) |
Parameter | Type | Example Value | Description | |
---|---|---|---|---|
Date | DateTime | 2019-12-01 14:02:03 | Date/Time SMS was received (yyyy-mm-dd HH:mm:ss) | |
Destination | String | 6421000001 | Recipient of the SMS in E.164 internationalised format | |
MessageText | String | This is an outbound message sent via API. | Plain or UTF-8 formatted SMS message sent |
Parameter | Type | Example Value | Description | |
---|---|---|---|---|
Date | DateTime | 2019-12-01 14:02:03 | Date/Time SMS was received (yyyy-mm-dd HH:mm:ss) | |
From | Text | +6421000001 | Sender of the SMS in E.164 internationalised format | |
MessageText | Text | This is a reply back from the mobile phone. | The SMS message received |
As new versions of the APIs are released, this API reference guide will be updated to reflect the latest version and features supported:
API Version ChangeLog