Last updated: Aug 13th 2024

Register your account

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


Create an API user

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

  1. Login to the TNZ Dashboard
  2. Navigate to 'Users'
  3. Create a new user or select an existing one
  4. Enable API access (if it's not already enabled)
  5. Click on the 'API' tab
  6. Enable 'Auth Token' and create a new Auth Token
  7. Click the ' Copy' button to copy it to your clipboard
  8. Paste the Auth Token into the Authorization Header in your application or code

At any time, you can refresh your Auth Token by clicking the button and exporting your new Auth Token. This action will invalidate any apps using your old Auth Token.

Auth Tokens can be used for multiple use-cases, with SubAccount and Department values helping in tracking reporting and billing.

API v2.04 utilizes JWT token Authentication. For OAuth2 authentication options, contact your TNZ representative.


Understanding the .NET Library basics

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 the Library:

Now we are supporting NuGet package, from the .NET CLI run:

> dotnet add package TNZAPI.NET


Download the Source:

Alternatively you can download source code from GitHub and build your own.


Capture Status & Replies using the Library:

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.

Authorization basics

TNZAPI.NET uses Auth Token to communicate with TNZ REST API, recommended format is:


// Construct TNZApiUser() object first
var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

// Now construct TNZApiClient() which references to all the functions for TNZAPI.NET library
var client = new TNZApiClient(apiUser);
											

Send Messages - build your application with the .NET Library

Find instructions for each Message Type:

Sending Email - Send Email via .NET

 

Send Email (Basic):


using TNZAPI.NET.Core;
using TNZAPI.NET.Api.Addressbook.Contact.Dto;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Messaging.Email.SendMessage(
    fromEmail: "from@test.com",             // Optional : Sets From Email Address - leave blank to use your api username as email sender
    emailSubject: "Test Email",             // Email Subject
    messagePlain: "Test Email Body",        // Email Body
    destination: "email.one@test.com",      // Recipient 1
    sendMode: Enums.SendModeType.Test       // TEST Mode - Remove this to send live traffic
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Success - " + response.MessageID);
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Send Email (Simple):


using TNZAPI.NET.Core;
using TNZAPI.NET.Api.Addressbook.Contact.Dto;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Messaging.Email.SendMessage(
    fromEmail: "from@test.com",             // Optional : Sets From Email Address - leave blank to use your api username as email sender
    emailSubject: "Test Email",             // Email Subject
    messagePlain: "Test Email Body",        // Email Body
    groupIDs: new List<GroupID>()            // List of Addressbook Group IDs
    {
        groupID
    },
    contactIDs: new List<ContactID>()          // List of Addressbook Contact IDs
    { 
        contactID
    },
    destinations: new List<string>() {
        "email.one@test.com",               // Recipient 1
        "email.two@test.com"                // Recipient 2
    },
    files: new List<string>()
    {
        "d:\\File1.pdf",                    // Attachment 1
        "d:\\File2.pdf"                     // Attachment 2
    },
    sendMode: Enums.SendModeType.Test       // TEST Mode - Remove this to send live traffic
);

if (response.Result == Enums.ResultCode.Success)
{
	Console.WriteLine("Success - " + response.MessageID);
}
else
{
	Console.WriteLine("Error occurred while processing.");

	foreach (var error in response.ErrorMessage)
	{
		Console.WriteLine($"- Error={error}");
	}
}            

Copy code

Send Email (Builder):


using TNZAPI.NET.Core;
using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Messaging.Email;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var message = new EmailBuilder()
    .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)
    .AddRecipients(groupID)                 // Add Recipients by GroupID using TNZ Addressbook 
    .AddRecipient(contactID)                // Add Recipient by ContactID using TNZ Addressbook 
    .AddRecipient("to@test.com")            // Recipient (Email Address)
    .AddAttachment("d:\\File1.pdf")         // Attachment
    .SetSendMode(Enums.SendModeType.Test)   // TEST/Live mode
    .Build();                               // Build Email() object

var response = client.Messaging.Email.SendMessage(message);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Success - " + response.MessageID);
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Send Email (Advanced):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Messaging.Common.Components;
using TNZAPI.NET.Api.Messaging.Common.Components.List;
using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Api.Messaging.TTS.Dto;
using TNZAPI.NET.Core;
using static TNZAPI.NET.Core.Enums;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

#region Declarations

var messageID = new MessageID("ABCD12345");

var reference = "Test Email - Advanced version";

var webhookCallbackURL = "https://example.com/webhook";
var webhookCallbackFormat = Enums.WebhookCallbackType.XML;
var errorEmailNotify = "notify@example.com";

var recipient1 = "emailTo@test.com";
var recipient2 = "emailTo@test.com";
var recipient3 = "emailTo@test.com";
var recipient4 = "emailTo@test.com";

var file1 = "d:\\File1.pdf";
var file2 = "d:\\File2.pdf";
var file3 = "d:\\File3.pdf";
var file4 = "d:\\File4.pdf";

var smtpFrom = "from@test.com";
var fromName = "Email From";
var fromEmail = "email@test.com";
var replyTo = "email@test.com";

var subject = "Test Email 123";
var messagePlain = "Test Email Body";
var messageHtml = "This is Test message body. Thank you so much!";

var recipients = new RecipientList();

#endregion Declarations

#region Add Recipients

//
// Add Recipient Method 1 - AddRecipient(string recipient);
//

recipients.Add(recipient1);

//
// Add Recipient Method 2 - AddRecipient(new Recipient())
//

var 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

recipients.Add(recipient);

//
// Add Recipient Method 3 - AddRecipients(new List<string>()); using simple destination
//

recipients.Add(new List<string>() { recipient3 });

//
// Add Recipient Method 4 - AddRecipients(new List<Recipient>()) using Recipient objects
//

recipients.Add(
    new List<Recipient>()
    {
        new Recipient(
            recipient4,             // Recipient
            "Test Company",         // Company Name
            "Test Recipient 3",     // Attention
            "Custom1",              // Custom1
            "Custom2",              // Custom2
            "Custom3",              // Custom3
            "Custom4",              // Custom4
            "Custom5"               // Custom5
        )
    }
);

#endregion Add Recipients

#region Add Recipients using TNZ Addressbook

//
// Add Recipient Method 5 - Add Recipients using GroupID
//

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

recipients.Add(groupID);

//
// Add Recipient Method 6 - Add Recipients using list of GroupIDs
//

var groupIDs = new List<GroupID>()
{
    new GroupID("HHHHHHHH-BBBB-BBBB-CCCC-DDDDDDDDDDDD"),
    new GroupID("IIIIIIII-BBBB-BBBB-CCCC-DDDDDDDDDDDD")
};

recipients.Add(groupIDs);

//
// Add Recipient Method 7 - Add Recipient using ContactID 
//

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

recipients.Add(contactID);

//
// Add Recipient Method 8 - Add Recipients using list of ContactIDs
//

var contactIDs = new List<ContactID>()
{
    new ContactID("DDDDDDDD-BBBB-BBBB-CCCC-DDDDDDDDDDDD"),
    new ContactID("EEEEEEEE-BBBB-BBBB-CCCC-DDDDDDDDDDDD")
};

recipients.Add(contactIDs);

#endregion

#region Add Attachments

var attachments = new AttachmentList();

//
// Add Attachment Method 1 - AddAttachment(file_location);
//

attachments.Add(file1);

//
// Add Attachment Method 2 - AddAttachment(new Attachment());
//

Attachment attachment = new Attachment();
attachment.FileName = FileHandlers.GetFileName(file2);
attachment.FileContent = FileHandlers.GetFileContents(file2);

attachments.Add(attachment);

//
// Add Attachment Method 3 - AddAttachments(new List<Attachment>()) using simple file locations
//

attachments.Add(new Attachment(file3));

//
// Add Attachment Method 4 - AddAttachments(new List<Attachment>()) using Attachment objects
//

attachments.Add(new Attachment(
  FileHandlers.GetFileName(file4),
  FileHandlers.GetFileContents(file4)
));

#endregion Add Attachments

var response = client.Messaging.Email.SendMessage(
    new EmailModel()
    {
        MessageID = messageID,                              // Message/Tracking ID, leave blank to auto-generate

        WebhookCallbackURL = webhookCallbackURL,            // Webhook Callback URL
        WebhookCallbackFormat = webhookCallbackFormat,      // Webhook Callback Format (XML/JSON)

        ErrorEmailNotify = errorEmailNotify,                // Error Email Notify (Receive email when it errored)

        EmailSubject = subject,                             // Subject
        MessagePlain = messagePlain,                        // MessagePlain
        MessageHTML = messageHtml,                          // MessageHTML
        Reference = reference,                              // Reference

        // Set SMTP Headers
        SMTPFrom = smtpFrom,                                // SMTP From
        From = fromName,                                    // From Name
        FromEmail = fromEmail,                              // From Email
        ReplyTo = replyTo,                                  // Reply-To

        Recipients = recipients.ToList(),                   // Recipient List
        Attachments = attachments.ToList(),                 // Attachment List

        SendTime = DateTime.Now,                            // SendTime
        Timezone = "New Zealand",                           // Timezone for SendTime

        SendMode = Enums.SendModeType.Test                  // TEST Mode - Remove this to send live traffic
    }
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Success - " + response.MessageID);
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}
            

Copy code

Required parameters

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)

Optional parameters

Parameter Example Value Description
MessageID ID12345 A Message Identifier helps you keep track of each message (maximum 40 characters, alphanumeric). Use a unique MessageID for each request. If you leave this field blank, the API will generate a 36-character UUID (v4) for you and include it in the response body.
Reference Test1 Human readable message description (free format field, maximum 80 characters).
WebhookCallbackURL https://www.example.com/webhook Overrides your Sender's default Webhook URL. Requires a default webhook to be configured. A full path including https:// is required.
WebhookCallbackFormat JSON Overrides your Sender's default Webhook format ('JSON' or 'XML')
SendTime 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')
Destination john.doe@example.com 'Destination' property that will convert string field to Recipient object.
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

client.Messaging.Email.SendMessage() Parameters

Option Structure Description
SendMessage(EmailModel)
MessageApiResult SendMessage(
    EmailModel entity
)                     
Function to send Email message based using EmailModel object.

Usage for this is :
client.Messaging.Email.SendMessage(
  new EmailModel(){...}
);


Returns MessageApiResult.
SendMessage(parameters)
MessageApiResult SendMessage(
    string emailSubject = null,
    string messagePlain = null,
    string messageHTML = null,
    string messageID = null,
    string reference = null,
    DateTime? sendTime = null,
    string timezone = null,
    string subaccount = null,
    string department = null,
    string chargeCode = null,
    string smtpFrom = null,
    string fromName = null,
    string fromEmail = null,
    string replyTo = null,
    GroupModel group = null,
    ICollection<GroupModel> groups = null,
    GroupID groupID = null,
    ICollection<GroupID> groupIDs = null,
    ContactModel contact = null,
    ICollection<ContactModel> contacts = null,
    ContactID contactID = null,
    ICollection<ContactID> contactIDs = null,
    string destination = null,
    ICollection<string> destinations = null,
    Recipient recipient = null,
    ICollection<Recipient> recipients = null,
    string file = null,
    ICollection<string> files = null,
    Attachment attachment = null,
    ICollection<Attachment> attachments = null,
    string webhookCallbackURL = null,
    WebhookCallbackType?
      webhookCallbackFormat = null,
    SendModeType? sendMode = null
)             
Function to send Email message using optional parameters.

Usage for this is :
client.Messaging.Email.SendMessage(
  destination:[email address],
  emailSubject: [email subject],
  messagePlain:[email body]
);


Returns MessageApiResult.
SendMessageAsync(EmailModel)
Task<MessageApiResult> SendMessageAsync(
    EmailModel entity
)                     
Function to send Email message using EmailModel object.

Usage for this is :
await client.Messaging.Email.SendMessageAsync(
  new EmailModel(){...}
);


Returns Task<MessageApiResult>.
SendMessageAsync(parameters)
Task<MessageApiResult> SendMessageAsync(
    string emailSubject = null,
    string messagePlain = null,
    string messageHTML = null,
    string messageID = null,
    string reference = null,
    DateTime? sendTime = null,
    string timezone = null,
    string subaccount = null,
    string department = null,
    string chargeCode = null,
    string smtpFrom = null,
    string fromName = null,
    string fromEmail = null,
    string replyTo = null,
    GroupModel group = null,
    ICollection<GroupModel> groups = null,
    GroupID groupID = null,
    ICollection<GroupID> groupIDs = null,
    ContactModel contact = null,
    ICollection<ContactModel> contacts = null,
    ContactID contactID = null,
    ICollection<ContactID> contactIDs = null,
    string destination = null,
    ICollection<string> destinations = null,
    Recipient recipient = null,
    ICollection<Recipient> recipients = null,
    string file = null,
    ICollection<string> files = null,
    Attachment attachment = null,
    ICollection<Attachment> attachments = null,
    string webhookCallbackURL = null,
    WebhookCallbackType?
      webhookCallbackFormat = null,
    SendModeType? sendMode = null
)             
Function to send Email message using optional parameters.

Usage for this is :
await client.Messaging.Email.SendMessageAsync(
  destination:[email address],
  emailSubject: [email subject],
  messagePlain:[email body]
);


Returns Task<MessageApiResult>.

Useful Functions

Function Usage Description
AddRecipient()

AddRecipient(string recipient)

AddRecipient(Recipient recipient)

AddRecipient(ContactModel contact)

AddRecipient(ContactID contactID)

Function to add a single message recipient
AddRecipients()

AddRecipients(List<string> recipients)

AddRecipients(List<Recipient> recipients)

AddRecipients(GroupModel group)

AddRecipients(GroupID groupID)

AddRecipients(List<ContactModel> contacts)

AddRecipients(List<ContactID> contactIDs)

AddRecipients(List<GroupModel> groups)

AddRecipients(List<GroupID> groupIDs)

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)
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)

Builder Class - EmailBuilder()

Function Usage Description
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) A Message Identifier helps you keep track of each message (maximum 40 characters, alphanumeric). Use a unique MessageID for each request. If you leave this field blank, the API will generate a 36-character UUID (v4) for you and include it in the response body.
SetReference() SetReference(string reference) Human readable message description (free format field, maximum 80 characters)
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(Recipient recipient)

AddRecipient(ContactModel contact)

AddRecipient(ContactID contactID)

Function to add a single message recipient
[Required]
AddRecipients()

AddRecipients(List<string> recipients)

AddRecipients(List<Recipient> recipients)

AddRecipients(GroupModel group)

AddRecipients(GroupID groupID)

AddRecipients(List<ContactModel> contacts)

AddRecipients(List<ContactID> contactIDs)

AddRecipients(List<GroupModel> groups)

AddRecipients(List<GroupID> groupIDs)

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 EmailModel() object and return
[Required]
BuildAsync() BuildAsync() Builds the EmailModel() object asynchronous and return

Sending SMS - Send SMS/TXT via .NET

 

Send SMS (Basic):


using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

const string recipient = "+64211111111";

const string message = "Hello, this is a test SMS from test.";

var response = client.Messaging.SMS.SendMessage(
    destination: recipient,                     // Recipient
    messageText: message,                       // SMS Message
    sendMode: Enums.SendModeType.Test           // TEST Mode - Remove this to send live traffic
    );

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Success - " + response.MessageID);
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Send SMS (Simple):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var client = new TNZApiClient(apiUser);

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var message = "Hello, this is a test SMS from test.";

var response = client.Messaging.SMS.SendMessage(
    groupIDs: new List<GroupID>()               // List of Addressbook Group IDs
    {
        groupID
    },
    contactIDs: new List<ContactID>()           // List of Addressbook Contact IDs
    {
        contactID
    },
    destinations: new List<string>() {
        "+64211111111",                         // Recipient 1
        "+64222222222"                          // Recipient 2
    },
    messageText: message,                       // SMS Message
    sendMode: Enums.SendModeType.Test           // TEST Mode - Remove this to send live traffic
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Success - " + response.MessageID);
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Send SMS (Builder):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Messaging.SMS;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var message = new SMSBuilder()
                .SetMessageText("Test SMS")             // SMS Message
                .AddRecipients(groupID)                 // Add Recipients by GroupID using TNZ Addressbook 
                .AddRecipient(contactID)                // Add Recipient by ContactID using TNZ Addressbook
                .AddRecipient("+64211111111")           // Recipient
                .SetSendMode(Enums.SendModeType.Test)   // TEST/Live mode
                .Build();                               // Build SMS() object

var response = client.Messaging.SMS.SendMessage(message);

DebugUtil.Dump(response);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Success - " + response.MessageID);
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Send SMS (Advanced):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Messaging.Common.Components;
using TNZAPI.NET.Api.Messaging.Common.Components.List;
using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Api.Messaging.SMS.Dto;
using TNZAPI.NET.Core;
using TNZAPI.NET.Helpers;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

#region Declarations

var reference = "Test SMS - Advanced version";

var webhookCallbackURL = "https://example.com/webhook";
var webhookCallbackFormat = Enums.WebhookCallbackType.XML;
var errorEmailNotify = "notify@example.com";

var smsEmailReply = "reply@test.com";
var forceGSMChars = "True";

var recipient1 = "+64211111111";
var recipient2 = "+64212222222";
var recipient3 = "+64213333333";
var recipient4 = "+64214444444";

var file1 = "D:\\file1.pdf";
var file2 = "D:\\file2.pdf";
var file3 = "D:\\file3.pdf";
var file4 = "D:\\file4.pdf";

var messageText = "Test SMS Message [[File1]] | [[File2]] | [[File3]] | [[File4]]";

#endregion Declarations

#region Add Recipients

var recipients = new RecipientList();

//
// Add Recipient Method 1 - Add(string recipient);
//
recipients.Add(recipient1);

//
// Add Recipient Method 2 - Add(new Recipient())
//

var 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

recipients.Add(recipient);

//
// Add Recipient Method 3 - AddRecipients(new List<string>()); using simple destination
//

recipients.Add(new List<string>() { recipient3 });

//
// Add Recipient Method 4 - AddRecipients(new List<Recipient>()) using Recipient objects
//

recipients.Add(
    new List<Recipient>()
    {
        new Recipient(
            recipient4,             // Recipient
            "Test Company",         // Company Name
            "Test Recipient 3",     // Attention
            "Custom1",              // Custom1
            "Custom2",              // Custom2
            "Custom3",              // Custom3
            "Custom4",              // Custom4
            "Custom5"               // Custom5
        )
    }
);

#endregion Add Recipients

#region Add Recipients using TNZ Addressbook

//
// Add Recipient Method 5 - Add Recipients using GroupID
//

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

recipients.Add(groupID);

//
// Add Recipient Method 6 - Add Recipients using list of GroupIDs
//

var groupIDs = new List<GroupID>()
{
    new GroupID("HHHHHHHH-BBBB-BBBB-CCCC-DDDDDDDDDDDD"),
    new GroupID("IIIIIIII-BBBB-BBBB-CCCC-DDDDDDDDDDDD")
};

recipients.Add(groupIDs);

//
// Add Recipient Method 7 - Add Recipient using ContactID 
//

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

recipients.Add(contactID);

//
// Add Recipient Method 8 - Add Recipients using list of ContactIDs
//

var contactIDs = new List<ContactID>()
{
    new ContactID("DDDDDDDD-BBBB-BBBB-CCCC-DDDDDDDDDDDD"),
    new ContactID("EEEEEEEE-BBBB-BBBB-CCCC-DDDDDDDDDDDD")
};

recipients.Add(contactIDs);

#endregion

#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
 */

var attachments = new AttachmentList();

//
// Add Attachment Method 1 - AddAttachment(file_location);
//
attachments.Add(file1);

//
// Add Attachment Method 2 - AddAttachment(new Attachment());
//

var attachment = new Attachment();
attachment.FileName = FileHandlers.GetFileName(file2);
attachment.FileContent = FileHandlers.GetFileContents(file2);

attachments.Add(attachment);

//
// Add Attachment Method 3 - AddAttachments(new List<IAttachment>()) using simple file locations
//

attachments.Add(new Attachment(file3));

//
// Add Attachment Method 4 - AddAttachments(new List<IAttachment>()) using Attachment objects
//

attachments.Add(
    new Attachment(
        FileHandlers.GetFileName(file4),
        FileHandlers.GetFileContents(file4)
    )
);

#endregion Add Attachments

var response = client.Messaging.SMS.SendMessage(
    new SMSModel()
    {
        WebhookCallbackURL = webhookCallbackURL,            // Webhook Callback URL
        WebhookCallbackFormat = webhookCallbackFormat,      // Webhook Callback Format (XML/JSON)

        ErrorEmailNotify = errorEmailNotify,                // Error Email Notify (Receive email when it errored)

        MessageID = new MessageID("ABCD12345"),             // MessageID - Leave blank to auto-generate
        Reference = reference,                              // Reference
        SubAccount = "",                                    // SubAccount
        Department = "",                                    // Department
        SMSEmailReply = smsEmailReply,                      // SMSEmailReply - For email (SMTP) reply receipt notifications
        ForceGSMChars = forceGSMChars,                      // ForceGSMChars
        MessageText = messageText,                          // SMS Message

        Recipients = recipients.ToList(),                   // Recipient List
        Attachments = attachments.ToList(),                 // Attachment List - Attachments only be supported with MessageLink facility

        SendTime = DateTime.Now,                            // SendTime
        Timezone = "New Zealand",                           // Timezone for SendTime

        SendMode = Enums.SendModeType.Test                  // TEST Mode - Remove this to send live traffic
    });

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Success - " + response.MessageID);
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

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)

Optional parameters

Parameter Example Value Description
MessageID ID12345 A Message Identifier helps you keep track of each message (maximum 40 characters, alphanumeric). Use a unique MessageID for each request. If you leave this field blank, the API will generate a 36-character UUID (v4) for you and include it in the response body.
Reference Test1 Human readable message description (free format field, maximum 80 characters)
WebhookCallbackURL https://www.example.com/webhook Overrides your Sender's default Webhook URL. Requires a default webhook to be configured. A full path including https:// is required.
WebhookCallbackFormat JSON Overrides your Sender's default Webhook format ('JSON' or 'XML')
SendTime 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
Destination +6421000001 'Destination' property that will convert string field to Recipient object.
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

client.Messaging.SMS.SendMessage() Parameters

Option Structure Description
SendMessage(SMSModel)
MessageApiResult SendMessage(
    SMSModel entity
)                     
Function to send SMS message based using SMSModel object.

Usage:
client.Messaging.SMS.SendMessage(
  new SMSModel(){...}
);


Returns MessageApiResult.
SendMessage(parameters)
MessageApiResult SendMessage(
    string messageID = null,
    string reference = null,
    DateTime? sendTime = null,
    string timezone = null,
    string subaccount = null,
    string department = null,
    string chargeCode = null,
    string smsEmailReply = null,
    string forceGSMChars = null,
    string messageText = null,
    GroupModel group = null,
    ICollection<GroupModel> groups = null,
    GroupID groupID = null,
    ICollection<GroupID> groupIDs = null,
    ContactModel contact = null,
    ICollection<ContactModel> contacts = null,
    ContactID contactID = null,
    ICollection<ContactID> contactIDs = null,
    string destination = null,
    ICollection<string> destinations = null,
    Recipient recipient = null,
    ICollection<Recipient> recipients = null,
    string file = null,
    ICollection<string> files = null,
    Attachment attachment = null,
    ICollection<Attachment> attachments = null,
    string webhookCallbackURL = null,
    WebhookCallbackType?
        webhookCallbackFormat = null,
    SendModeType? sendMode = null
)             
Function to send SMS message using optional parameters.

Usage:
client.Messaging.SMS.SendMessage(
  destination:[mobile number],
  messageText: [message to send],
);


Returns MessageApiResult.
SendMessageAsync(SMSModel)
Task<MessageApiResult> SendMessageAsync(
    SMSModel entity
)                     
Function to send SMS message using SMSModel object.

Usage:
await client.Messaging.SMS.SendMessageAsync(
  new SMSModel(){...}
);


Returns Task<MessageApiResult>.
SendMessageAsync(parameters)
Task<MessageApiResult> SendMessageAsync(
    string messageID = null,
    string reference = null,
    DateTime? sendTime = null,
    string timezone = null,
    string subaccount = null,
    string department = null,
    string chargeCode = null,
    string smsEmailReply = null,
    string forceGSMChars = null,
    string messageText = null,
    GroupModel group = null,
    ICollection<GroupModel> groups = null,
    GroupID groupID = null,
    ICollection<GroupID> groupIDs = null,
    ContactModel contact = null,
    ICollection<ContactModel> contacts = null,
    ContactID contactID = null,
    ICollection<ContactID> contactIDs = null,
    string destination = null,
    ICollection<string> destinations = null,
    string destination = null,
    ICollection<string> destinations = null,
    Recipient recipient = null,
    ICollection<Recipient> recipients = null,
    string file = null,
    ICollection<string> files = null,
    Attachment attachment = null,
    ICollection<Attachment> attachments = null,
    string webhookCallbackURL = null,
    WebhookCallbackType?
        webhookCallbackFormat = null,
    SendModeType? sendMode = null
)             
Function to send SMS message using optional parameters.

Usage:
await client.Messaging.SMS.SendMessageAsync(
  destination:[mobile number],
  messageText: [message to send],
);


Returns Task<MessageApiResult>.

Useful Functions

Function Usage Description
AddRecipient()

AddRecipient(string recipient)

AddRecipient(Recipient recipient)

AddRecipient(ContactModel contact)

AddRecipient(ContactID contactID)

Function to add a single message recipient
AddRecipients()

AddRecipients(List<string> recipients)

AddRecipients(List<Recipient> recipients)

AddRecipients(GroupModel group)

AddRecipients(GroupID groupID)

AddRecipients(List<ContactModel> contacts)

AddRecipients(List<ContactID> contactIDs)

AddRecipients(List<GroupModel> groups)

AddRecipients(List<GroupID> groupIDs)

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)
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)

Builder Class - SMSBuilder()

Function Usage Description
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) A Message Identifier helps you keep track of each message (maximum 40 characters, alphanumeric). Use a unique MessageID for each request. If you leave this field blank, the API will generate a 36-character UUID (v4) for you and include it in the response body.
SetReference() SetReference(string reference) Human readable message description (free format field, maximum 80 characters)
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(Recipient recipient)

AddRecipient(ContactModel contact)

AddRecipient(ContactID contactID)

Function to add a single message recipient
[Required]
AddRecipients()

AddRecipients(List<string> recipients)

AddRecipients(List<Recipient> recipients)

AddRecipients(GroupModel group)

AddRecipients(GroupID groupID)

AddRecipients(List<ContactModel> contacts)

AddRecipients(List<ContactID> contactIDs)

AddRecipients(List<GroupModel> groups)

AddRecipients(List<GroupID> groupIDs)

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 SMSModel() object and return
[Required]
BuildAsync() BuildAsync() Builds the SMSModel() object asynchronous and return

Sending Faxes - Send Fax via .NET

 

Send Fax (Basic):


using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Messaging.Fax.SendMessage(
    destinations: new List<string>()
    {
        "+6491111111",                      // Recipient 1
        "+6491111112"                       // Recipient 2
    },
    file: "D:\\File1.pdf",                  // Attach File
    sendMode: Enums.SendModeType.Test       // TEST Mode - Remove this to send live traffic
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Success - " + response.MessageID);
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Send Fax (Simple):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);         // Initializer

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Messaging.Fax.SendMessage(
    groupIDs: new List<GroupID>()               // List of Addressbook Group IDs
    {
        groupID
    },
    contactIDs: new List<ContactID>()           // List of Addressbook Contact IDs
    {
        contactID
    },
    destination: "+6491111111",                 // Destination (Fax number);
    file: "D:\\File1.pdf",                      // File location
    sendMode: Enums.SendModeType.Test           // TEST Mode - Remove this to send live traffic
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Success - " + response.MessageID);
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Send Fax (Builder):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Messaging.Fax;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var message = new FaxBuilder()
                .AddAttachment("D:\\File1.pdf")         // Attachment location
                .AddRecipients(groupID)                 // Add Recipients by GroupID using TNZ Addressbook 
                .AddRecipient(contactID)                // Add Recipient by ContactID using TNZ Addressbook 
                .AddRecipient("+6491111111")            // Recipient
                .SetSendMode(Enums.SendModeType.Test)   // TEST/Live mode
                .Build();                               // Build Email() object

var response = client.Messaging.Fax.SendMessage(message);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Success - " + response.MessageID);
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}

return response;
            

Copy code

Send Fax (Advanced):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Messaging.Common.Components;
using TNZAPI.NET.Api.Messaging.Common.Components.List;
using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Api.Messaging.Fax.Dto;
using TNZAPI.NET.Core;
using TNZAPI.NET.Helpers;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

#region Declarations

var reference = "Test Fax - Advanced version";

var webhookCallbackURL = "https://example.com/webhook";
var webhookCallbackFormat = Enums.WebhookCallbackType.XML;
var errorEmailNotify = "notify@example.com";

var recipient1 = "+6491111111";
var recipient2 = "+6492222222";
var recipient3 = "+6493333333";
var recipient4 = "+6494444444";

var file1 = "D:\\file1.pdf";
var file2 = "D:\\file2.pdf";
var file3 = "D:\\file3.pdf";
var file4 = "D:\\file4.pdf";

var resolution = "High";
var csid = "TEST FAX";

var retryAttempts = 3;
var retryPeriod = 1;

var recipients = new RecipientList();

#endregion Declarations

#region Add Recipients

//
// Add Recipient Method 1 - AddRecipient(string recipient);
//

recipients.Add(recipient1);

//
// Add Recipient Method 2 - AddRecipient(new Recipient())
//

var 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

recipients.Add(recipient);

//
// Add Recipient Method 3 - AddRecipients(new List<string>()); using simple destination
//

recipients.Add(new List<string>() { recipient3 });

//
// Add Recipient Method 4 - AddRecipients(new List<Recipient>()) using Recipient objects
//

recipients.Add(
    new List<Recipient>()
    {
        new Recipient(
            recipient4,             // Recipient
            "Test Company",         // Company Name
            "Test Recipient 3",     // Attention
            "Custom1",              // Custom1
            "Custom2",              // Custom2
            "Custom3",              // Custom3
            "Custom4",              // Custom4
            "Custom5"               // Custom5
        )
    }
);

#endregion Add Recipients

#region Add Recipients using TNZ Addressbook

//
// Add Recipient Method 5 - Add Recipients using GroupID
//

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

recipients.Add(groupID);

//
// Add Recipient Method 6 - Add Recipients using list of GroupIDs
//

var groupIDs = new List<GroupID>()
{
    new GroupID("HHHHHHHH-BBBB-BBBB-CCCC-DDDDDDDDDDDD"),
    new GroupID("IIIIIIII-BBBB-BBBB-CCCC-DDDDDDDDDDDD")
};

recipients.Add(groupIDs);

//
// Add Recipient Method 7 - Add Recipient using ContactID 
//

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

recipients.Add(contactID);

//
// Add Recipient Method 8 - Add Recipients using list of ContactIDs
//

var contactIDs = new List<ContactID>()
{
    new ContactID("DDDDDDDD-BBBB-BBBB-CCCC-DDDDDDDDDDDD"),
    new ContactID("EEEEEEEE-BBBB-BBBB-CCCC-DDDDDDDDDDDD")
};

recipients.Add(contactIDs);

#endregion

#region Add Attachments

var attachments = new AttachmentList();

//
// Add Attachment Method 1 - AddAttachment(file_location);
//
attachments.Add(file1);

//
// Add Attachment Method 2 - AddAttachment(new Attachment());
//

var attachment = new Attachment();
attachment.FileName = FileHandlers.GetFileName(file2);
attachment.FileContent = FileHandlers.GetFileContents(file2);

attachments.Add(attachment);

//
// Add Attachment Method 3 - using simple file locations
//

attachments.Add(new Attachment(file3));

//
// Add Attachment Method 4 - using Attachment objects
//

attachments.Add(
    new Attachment(
        FileHandlers.GetFileName(file4),
        FileHandlers.GetFileContents(file4)
    )
);

#endregion Add Attachments

var response = client.Messaging.Fax.SendMessage(
    new FaxModel()
    {
        WebhookCallbackURL = webhookCallbackURL,            // Webhook Callback URL
        WebhookCallbackFormat = webhookCallbackFormat,      // Webhook Callback Format (XML/JSON)

        ErrorEmailNotify = errorEmailNotify,                // Error Email Notify (Receive email when it errored)

        MessageID = new MessageID(""),                      // MessageID - Leave blank to auto-generate
        Reference = reference,                              // Reference
        SubAccount = "",                                    // SubAccount
        Department = "",                                    // Department
        ChargeCode = "",                                    // ChargeCode
        Resolution = resolution,                            // Resolution - High/Low
        CSID = csid,                                        // CSID

        WatermarkFolder = "",                               // WaterMarkFolder
        WatermarkFirstPage = "",                            // WaterMarkFirstPage
        WatermarkAllPages = "",                             // WaterMarkAllPages

        RetryAttempts = retryAttempts,                      // RetryAttempts - no of retries
        RetryPeriod = retryPeriod,                          // RetryPeriod - no of minutes between retries

        Recipients = recipients.ToList(),                   // Recipient list
        Attachments = attachments.ToList(),                 // Attachment list

        SendTime = DateTime.Now,                            // SendTime
        Timezone = "New Zealand",                           // Timezone for SendTime

        SendMode = Enums.SendModeType.Test
    });

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Success - " + response.MessageID);
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

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

Optional parameters

Parameter Example Value Description
MessageID ID12345 A Message Identifier helps you keep track of each message (maximum 40 characters, alphanumeric). Use a unique MessageID for each request. If you leave this field blank, the API will generate a 36-character UUID (v4) for you and include it in the response body.
Reference Test1 Human readable message description (free format field, maximum 80 characters)
WebhookCallbackURL https://www.example.com/webhook Overrides your Sender's default Webhook URL. Requires a default webhook to be configured. A full path including https:// is required.
WebhookCallbackFormat JSON Overrides your Sender's default Webhook format ('JSON' or 'XML')
SendTime 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)
File D:/File1.pdf 'File' property that will convert string field to Attachment object.
Destination +6495005000 'Destination' property that will convert string field to Recipient object.
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

client.Messaging.Fax.SendMessage() Parameters

Option Structure Description
SendMessage(FaxModel)
MessageApiResult SendMessage(
    FaxModel entity
)                     
Function to send fax message based using FaxModel object.

Usage:
client.Messaging.Fax.SendMessage(
  new FaxModel(){...}
);


Returns MessageApiResult.
SendMessage(parameters)
MessageApiResult SendMessage(
    string messageID = null,
    string reference = null,
    DateTime? sendTime = null,
    string timezone = null,
    string subaccount = null,
    string department = null,
    string chargeCode = null,
    string resolution = null,
    string csid = null,
    string watermarkFolder = null,
    string watermarkFirstpage = null,
    string watermarkAllPages = null,
    int? retryAttempts = null,
    int? retryPeriod = null,
    GroupModel group = null,
    ICollection<GroupModel> groups = null,
    GroupID groupID = null,
    ICollection<GroupID> groupIDs = null,
    ContactModel contact = null,
    ICollection<ContactModel> contacts = null,
    ContactID contactID = null,
    ICollection<ContactID> contactIDs = null,
    string destination = null,
    ICollection<string> destinations = null,
    Recipient recipient = null,
    ICollection<Recipient> recipients = null,
    string file = null,
    ICollection<string> files = null,
    Attachment attachment = null,
    ICollection<Attachment> attachments = null,
    string webhookCallbackURL = null,
    WebhookCallbackType?
        webhookCallbackFormat = null,
    SendModeType? sendMode = null
)             
Function to send fax message using optional parameters.

Usage:
client.Messaging.Fax.SendMessage(
  destination:[fax number],
  file: [document to send],
);


Returns MessageApiResult.
SendMessageAsync(FaxModel)
Task<MessageApiResult> SendMessageAsync(
    FaxModel entity
)                     
Function to send fax message using FaxModel object.

Usage:
await client.Messaging.Fax.SendMessageAsync(
  new FaxModel(){...}
);


Returns Task<MessageApiResult>.
SendMessageAsync(parameters)
Task<MessageApiResult> SendMessageAsync(
    string messageID = null,
    string reference = null,
    DateTime? sendTime = null,
    string timezone = null,
    string subaccount = null,
    string department = null,
    string chargeCode = null,
    string resolution = null,
    string csid = null,
    string watermarkFolder = null,
    string watermarkFirstpage = null,
    string watermarkAllPages = null,
    int? retryAttempts = null,
    int? retryPeriod = null,
    GroupModel group = null,
    ICollection<GroupModel> groups = null,
    GroupID groupID = null,
    ICollection<GroupID> groupIDs = null,
    ContactModel contact = null,
    ICollection<ContactModel> contacts = null,
    ContactID contactID = null,
    ICollection<ContactID> contactIDs = null,
    string destination = null,
    ICollection<string> destinations = null,
    Recipient recipient = null,
    ICollection<Recipient> recipients = null,
    string file = null,
    ICollection<string> files = null,
    Attachment attachment = null,
    ICollection<Attachment> attachments = null,
    string webhookCallbackURL = null,
    WebhookCallbackType?
        webhookCallbackFormat = null,
    SendModeType? sendMode = null
)             
Function to send Fax message using optional parameters.

Usage:
await client.Messaging.Fax.SendMessageAsync(
  destination:[fax number],
  file: [document to send],
);


Returns Task<MessageApiResult>.

Useful Functions

Function Usage Description
AddRecipient()

AddRecipient(string recipient)

AddRecipient(Recipient recipient)

AddRecipient(ContactModel contact)

AddRecipient(ContactID contactID)

Function to add a single message recipient
AddRecipients()

AddRecipients(List<string> recipients)

AddRecipients(List<Recipient> recipients)

AddRecipients(GroupModel group)

AddRecipients(GroupID groupID)

AddRecipients(List<ContactModel> contacts)

AddRecipients(List<ContactID> contactIDs)

AddRecipients(List<GroupModel> groups)

AddRecipients(List<GroupID> groupIDs)

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)
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)

Builder Class - FaxBuilder()

Function Usage Description
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) A Message Identifier helps you keep track of each message (maximum 40 characters, alphanumeric). Use a unique MessageID for each request. If you leave this field blank, the API will generate a 36-character UUID (v4) for you and include it in the response body.
SetReference() SetReference(string reference) Human readable message description (free format field, maximum 80 characters)
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(Recipient recipient)

AddRecipient(ContactModel contact)

AddRecipient(ContactID contactID)

Function to add a single message recipient
[Required]
AddRecipients()

AddRecipients(List<string> recipients)

AddRecipients(List<Recipient> recipients)

AddRecipients(GroupModel group)

AddRecipients(GroupID groupID)

AddRecipients(List<ContactModel> contacts)

AddRecipients(List<ContactID> contactIDs)

AddRecipients(List<GroupModel> groups)

AddRecipients(List<GroupID> groupIDs)

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 FaxModel() object and return
[Required]
BuildAsync() BuildAsync() Builds the FaxModel() object asynchronous and return

Sending Voice (Voicemail) - Send VoiceCast via .NET

 

Send Voice:


using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Messaging.Voice.SendMessage(
    destinations: new List<string>()
    {
        "+64211111111",                     // Recipient
        "+64222222222"                      // Recipient
    },
    messageToPeople: "D:\\File1.wav",       // WAV format, 16-bit, 8000hz
    sendMode: Enums.SendModeType.Test       // TEST Mode - Remove this to send live traffic
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Success - " + response.MessageID);
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Send Voice:


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var recipient = "+64211111111";

var file = "D:\\File1.wav";

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Messaging.Voice.SendMessage(
    groupIDs: new List<GroupID>()           // List of Addressbook Group IDs
    {
        groupID
    },
    contactIDs: new List<ContactID>()       // List of Addressbook Contact IDs
    {
        contactID
    },
    destination: recipient,                 // Recipient
    messageToPeople: file,                  // WAV format, 16-bit, 8000hz
    sendMode: Enums.SendModeType.Test       // TEST Mode - Remove this to send live traffic
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Success - " + response.MessageID);
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}
}            

Copy code

Send Voice:


using TNZAPI.NET.Api.Messaging.Voice;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var message = new VoiceBuilder()
                .SetMessageToPeople("D:\\File1.wav")    // Message to People file name - WAV format, 16-bit, 8000hz
                .AddRecipients(groupID)                 // Add Recipients by GroupID using TNZ Addressbook 
                .AddRecipient(contactID)                // Add Recipient by ContactID using TNZ Addressbook 
                .AddRecipient("+64211111111")           // Recipient
                .SetSendMode(Enums.SendModeType.Test)   // TEST/Live mode
                .Build();                               // Build TTS() object

var response = client.Messaging.Voice.SendMessage(message);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Success - " + response.MessageID);
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Send Voice (Advanced):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Messaging.Common.Components;
using TNZAPI.NET.Api.Messaging.Common.Components.List;
using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Api.Messaging.Voice.Dto;
using TNZAPI.NET.Core;
using static TNZAPI.NET.Core.Enums;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var reference = "Test Voice - Advanced version";

var webhookCallbackURL = "https://example.com/webhook";
var webhookCallbackFormat = Enums.WebhookCallbackType.XML;
var errorEmailNotify = "notify@example.com";

var callerId = "+6499999999";
var billingAccount = "TEST BILLING ACCOUNT";
var reportTo = "report@example.com";

var recipient1 = "+64211111111";
var recipient2 = "+64212222222";
var recipient3 = "+64213333333";
var recipient4 = "+64214444444";

var messageToPeople = "D:\\File1.wav";                // WAV format, 16-bit, 8000hz
var messageToAnswerphones = "D:\\File2.wav";          // WAV format, 16-bit, 8000hz
var callRouteMessageToPeople = "D:\\File3.wav";       // WAV format, 16-bit, 8000hz
var callRouteMessageToOperators = "D:\\File4.wav";    // WAV format, 16-bit, 8000hz
var callRouteMessageOnWrongKey = "D:\\File5.wav";     // WAV format, 16-bit, 8000hz

var numberOfOperators = 1;
var retryAttempts = 2;
var retryPeriod = 5;

var keypad1Route = "+6491111111";
var keypad2Route = "+6492222222";
var keypad3Route = "+6493333333";
var keypad4Route = "+6494444444";

var keypad9PlaySection = KeypadPlaySection.Main;

#region Add Keypads

var keypads = new KeypadList();

//
// Add Keypad Method 1 - VoiceMessage.AddKeypad(int key, string keypad1_route);
//
keypads.Add(1, keypad1Route);

//
// Add Keypad Method 2 - AddKeypad(new Keypad());
//
keypads.Add(new Keypad(2, keypad2Route));

//
// Add Keypad Method 3 - AddKeypad(new List<IKeypad>())
//
var keypad_list = new List<Keypad>();

keypad_list.Add(new Keypad(3, keypad3Route));

//
// Add Keypad Method 4 - AddKeypad(new List()) using Keypad objects
//
var keypad4 = new Keypad();
keypad4.Tone = 4;
keypad4.RouteNumber = keypad4Route;

keypad_list.Add(keypad4);

//
// Add Keypad Method 5 - Add Play (Wave Data)
//
var keypad5 = new Keypad();
keypad5.Tone = 5;
keypad5.PlayFile = "D:\\File1.wav";

keypad_list.Add(keypad5);

keypads.Add(keypad_list);

//
// Add Keypad Method 9 - Add Keypad 9 to play MessageToPeople (Main) section
//

keypads.Add(
   tone: 9,
   playSection: keypad9PlaySection
);

#endregion Add Keypads

#region Add Recipients

var recipients = new RecipientList();

//
// Add Recipient Method 1 - AddRecipient(string recipient);
//

recipients.Add(recipient1);

//
// Add Recipient Method 2 - AddRecipient(new Recipient())
//

var 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

recipients.Add(recipient);

//
// Add Recipient Method 3 - AddRecipients(new List<string>()); using simple destination
//

recipients.Add(new List<string>() { recipient3 });

//
// Add Recipient Method 4 - AddRecipients(new List<Recipient>()) using Recipient objects
//

recipients.Add(
   new List<Recipient>()
   {
       new Recipient(
           recipient4,             // Recipient
           "Test Company",         // Company Name
           "Test Recipient 3",     // Attention
           "Custom1",              // Custom1
           "Custom2",              // Custom2
           "Custom3",              // Custom3
           "Custom4",              // Custom4
           "Custom5"               // Custom5
       )
   }
);

#endregion Add Recipients

#region Add Recipients using TNZ Addressbook

//
// Add Recipient Method 5 - Add Recipients using GroupID
//

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

recipients.Add(groupID);

//
// Add Recipient Method 6 - Add Recipients using list of GroupIDs
//

var groupIDs = new List<GroupID>()
{
   new GroupID("HHHHHHHH-BBBB-BBBB-CCCC-DDDDDDDDDDDD"),
   new GroupID("IIIIIIII-BBBB-BBBB-CCCC-DDDDDDDDDDDD")
};

recipients.Add(groupIDs);

//
// Add Recipient Method 7 - Add Recipient using ContactID 
//

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

recipients.Add(contactID);

//
// Add Recipient Method 8 - Add Recipients using list of ContactIDs
//

var contactIDs = new List<ContactID>()
{
   new ContactID("DDDDDDDD-BBBB-BBBB-CCCC-DDDDDDDDDDDD"),
   new ContactID("EEEEEEEE-BBBB-BBBB-CCCC-DDDDDDDDDDDD")
};

recipients.Add(contactIDs);

#endregion

#region Attach Voicefiles

var voiceFiles = new Dictionary<MessageDataType, string>()
{
   { MessageDataType.MessageToPeople, messageToPeople },
   { MessageDataType.MessageToAnswerPhones, messageToAnswerphones },
   { MessageDataType.CallRouteMessageToPeople, callRouteMessageToPeople },
   { MessageDataType.CallRouteMessageToOperators, callRouteMessageToOperators },
   { MessageDataType.CallRouteMessageOnWrongKey, callRouteMessageOnWrongKey }
};

#endregion

var response = client.Messaging.Voice.SendMessage(
   new VoiceModel()
   {
       WebhookCallbackURL = webhookCallbackURL,            // Webhook Callback URL
       WebhookCallbackFormat = webhookCallbackFormat,      // Webhook Callback Format (XML/JSON)

       ErrorEmailNotify = errorEmailNotify,                // Error Email Notify (Receive email when it errored)

       MessageID = new MessageID(""),                      // MessageID - Leave blank to auto-generate
       Reference = reference,                              // Reference
       CallerID = callerId,                                // Caller Id
       SubAccount = billingAccount,                        // Billing Account
       ReportTo = reportTo,                                // Report To

       NumberOfOperators = numberOfOperators,              // Number of Operators
       RetryAttempts = retryAttempts,                      // Retry Attempts
       RetryPeriod = retryPeriod,                          // Retry Period

       MessageData = voiceFiles,                           // List of voice files
       Keypads = keypads.ToList(),                         // Keypads (1..9)
       KeypadOptionRequired = true,                        // Requires the callee presses a keypad option
       Recipients = recipients.ToList(),                   // Recipients

       SendTime = DateTime.Now,                            // SendTime
       Timezone = "New Zealand",                           // Timezone for SendTime

       SendMode = Enums.SendModeType.Test                  // TEST Mode - Remove this to send live traffic
   });

if (response.Result == Enums.ResultCode.Success)
{
   Console.WriteLine("Success - " + response.MessageID);
}
else
{
   Console.WriteLine("Error occurred while processing.");

   foreach (var error in response.ErrorMessage)
   {
       Console.WriteLine($"- Error={error}");
   }
}            

Copy code

Required parameters

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)

Optional parameters

Parameter Example Value Description
MessageID ID12345 A Message Identifier helps you keep track of each message (maximum 40 characters, alphanumeric). Use a unique MessageID for each request. If you leave this field blank, the API will generate a 36-character UUID (v4) for you and include it in the response body.
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 Human readable message description (free format field, maximum 80 characters)
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.
Destination +6495005000 'Destination' property that will convert string field to Recipient object.
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

client.Messaging.Voice.SendMessage() Parameters

Option Structure Description
SendMessage(VoiceModel)
MessageApiResult SendMessage(
    VoiceModel entity
)                     
Function to send voice message based using VoiceModel object.

Usage:
client.Messaging.Voice.SendMessage(
  new VoiceModel(){...}
);


Returns MessageApiResult.
SendMessage(parameters)
MessageApiResult SendMessage(
    string messageID = null,
    string reference = null,
    DateTime? sendTime = null,
    string timezone = null,
    string subaccount = null,
    string department = null,
    string chargeCode = null,
    string messageToPeople = null,
    string messageToAnswerPhones = null,
    string callRouteMessageToPeople = null,
    string callRouteMessageToOperators = null,
    string callRouteMessageOnWrongKey = null,
    int? numberOfOperators = null,
    string callerID = null,
    string options = null,
    ICollection<Keypad> keypads = null,
    string destination = null,
    GroupModel group = null,
    ICollection<GroupModel> groups = null,
    GroupID groupID = null,
    ICollection<GroupID> groupIDs = null,
    ContactModel contact = null,
    ICollection<ContactModel> contacts = null,
    ContactID contactID = null,
    ICollection<ContactID> contactIDs = null,
    ICollection<string> destinations = null,
    Recipient recipient = null,
    ICollection<Recipient> recipients = null,
    string webhookCallbackURL = null,
    WebhookCallbackType?
        webhookCallbackFormat = null,
    SendModeType? sendMode = null
)             
Function to send voice message using optional parameters.

Usage:
client.Messaging.Voice.SendMessage(
  destination:[phone number],
  messageToPeople: [voice file to send],
);


Returns MessageApiResult.
SendMessageAsync(VoiceModel)
Task<MessageApiResult> SendMessageAsync(
    VoiceModel entity
)                     
Function to send voice message using VoiceModel object.

Usage:
await client.Messaging.Voice.SendMessageAsync(
  new VoiceModel(){...}
);


Returns Task<MessageApiResult>.
SendMessageAsync(parameters)
Task<MessageApiResult> SendMessageAsync(
    string messageID = null,
    string reference = null,
    DateTime? sendTime = null,
    string timezone = null,
    string subaccount = null,
    string department = null,
    string chargeCode = null,
    string messageToPeople = null,
    string messageToAnswerPhones = null,
    string callRouteMessageToPeople = null,
    string callRouteMessageToOperators = null,
    string callRouteMessageOnWrongKey = null,
    int? numberOfOperators = null,
    string callerID = null,
    string options = null,
    ICollection<Keypad> keypads = null,
    GroupModel group = null,
    ICollection<GroupModel> groups = null,
    GroupID groupID = null,
    ICollection<GroupID> groupIDs = null,
    ContactModel contact = null,
    ICollection<ContactModel> contacts = null,
    ContactID contactID = null,
    ICollection<ContactID> contactIDs = null,
    string destination = null,
    ICollection<string> destinations = null,
    Recipient recipient = null,
    ICollection<Recipient> recipients = null,
    string webhookCallbackURL = null,
    WebhookCallbackType?
        webhookCallbackFormat = null,
    SendModeType? sendMode = null
)             
Function to send voice message using optional parameters.

Usage:
await client.Messaging.Voice.SendMessageAsync(
  destination:[phone number],
  file: [voice file to send],
);


Returns Task<MessageApiResult>.

Useful Functions

Function Usage Description
AddRecipient()

AddRecipient(string recipient)

AddRecipient(Recipient recipient)

AddRecipient(ContactModel contact)

AddRecipient(ContactID contactID)

Function to add a single message recipient
AddRecipients()

AddRecipients(List<string> recipients)

AddRecipients(List<Recipient> recipients)

AddRecipients(GroupModel group)

AddRecipients(GroupID groupID)

AddRecipients(List<ContactModel> contacts)

AddRecipients(List<ContactID> contactIDs)

AddRecipients(List<GroupModel> groups)

AddRecipients(List<GroupID> groupIDs)

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)
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)

Builder Class - VoiceBuilder()

Function Usage Description
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) A Message Identifier helps you keep track of each message (maximum 40 characters, alphanumeric). Use a unique MessageID for each request. If you leave this field blank, the API will generate a 36-character UUID (v4) for you and include it in the response body.
SetReference() SetReference(string reference) Human readable message description (free format field, maximum 80 characters)
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(Recipient recipient)

AddRecipient(ContactModel contact)

AddRecipient(ContactID contactID)

Function to add a single message recipient
[Required]
AddRecipients()

AddRecipients(List<string> recipients)

AddRecipients(List<Recipient> recipients)

AddRecipients(GroupModel group)

AddRecipients(GroupID groupID)

AddRecipients(List<ContactModel> contacts)

AddRecipients(List<ContactID> contactIDs)

AddRecipients(List<GroupModel> groups)

AddRecipients(List<GroupID> groupIDs)

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 VoiceModel() object and return
[Required]
BuildAsync() BuildAsync() Builds the VoiceModel() object asynchronous and return

Sending Voice Text To Speech - Send TTS via .NET

 

Send TextToSpeech (Basic):


using TNZAPI.NET.Core;
using static TNZAPI.NET.Core.Enums;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Messaging.TTS.SendMessage(
    messageToPeople: "Hello, this is a call from test. This is relevant information.", // Message to people
    destinations: new List<string>
    {
        "+64211111111",                     // Recipient
        "+64222222222",                     // Recipient
    },
    ttsVoiceType: TTSVoiceType.EnglishNZFemale1, // TTS Engine
    sendMode: Enums.SendModeType.Test       // TEST Mode - Remove this to send live traffic
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Success - " + response.MessageID);
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Send TextToSpeech (Simple):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var recipient = "+64211111111";                // Recipient

var messageToPeople = "Hello, this is a call from test. This is relevant information.";

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Messaging.TTS.SendMessage(
    groupIDs: new List<GroupID>()           // List of Addressbook Group IDs
    {
        groupID
    },
    contactIDs: new List<ContactID>()       // List of Addressbook Contact IDs
    {
        contactID
    },
    destination: recipient,                 // Recipient
    messageToPeople: messageToPeople,       // Message to people
    sendMode: Enums.SendModeType.Test       // TEST Mode - Remove this to send live traffic
    );

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Success - " + response.MessageID);
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Send TextToSpeech (Builder):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Messaging.TTS;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var message = new TTSBuilder()
                .SetMessageToPeople("Hello, this is a call from test. This is relevant information.")   // Message to People
                .AddRecipients(groupID)                 // Add Recipients by GroupID using TNZ Addressbook 
                .AddRecipient(contactID)                // Add Recipient by ContactID using TNZ Addressbook 
                .AddRecipient("+64211111111")           // Recipient
                .SetSendMode(Enums.SendModeType.Test)   // TEST/Live mode
                .Build();                               // Build TTS() object

var response = client.Messaging.TTS.SendMessage(message);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Success - " + response.MessageID);
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Send TextToSpeech (Advanced):


using TNZAPI.NET.Api.Messaging.Common.Components;
using TNZAPI.NET.Api.Messaging.Common.Components.List;
using TNZAPI.NET.Api.Messaging.TTS.Dto;
using TNZAPI.NET.Core;
using static TNZAPI.NET.Core.Enums;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

#region Declarations

var reference = "Test TTS - Advanced version";

var webhookCallbackURL = "https://example.com/webhook";
var webhookCallbackFormat = Enums.WebhookCallbackType.XML;
var errorEmailNotify = "notify@example.com";

var callerId = "+6499999999";
var billingAccount = "TEST BILLING ACCOUNT";
var reportTo = "report@example.com";

var recipient1 = "+64211111111";
var recipient2 = "+64212222222";
var recipient3 = "+64213333333";
var recipient4 = "+64214444444";

var messageToPeople = "Hello, this is a call from Department01. This is relevant information. Press one to be connected to our call centre.";
var messageToAnswerphones = "Hello, sorry we missed you. This is a call from Department 01. Please contact us on 0800 123123.";
var callRouteMessageToPeople = "Connecting you now.";
var callRouteMessageToOperators = "Incoming Text To Speech call.";
var callRouteMessageOnWrongKey = "Sorry, you have pressed an invalid key. Please try again.";

var numberOfOperators = 1;
var retryAttempts = 3;
var retryPeriod = 1;

var ttsVoice = TTSVoiceType.Female1;

var keypad1Route = "+6491111111";
var keypad2Route = "+6492222222";
var keypad3Play = "Hello, you have pressed 3.";
var keypad4Route = "+6493333333";
var keypad5Route = "+6494444444";
var keypad6Play = "Hello, you have pressed 5.";
var keypad7Route = "+6497777777";
var keypad7Play = "Hello, you have pressed 6.";
var keypad9PlaySection = KeypadPlaySection.Main;

#endregion

#region Add Keypads

var keypads = new KeypadList();

//
// Add Keypad Method 1 - VoiceMessage.AddKeypad(int key, string keypad1_route);
//
keypads.Add(1, keypad1Route);

//
// Add Keypad Method 2 - AddKeypad(new Keypad());
//
keypads.Add(new Keypad(2, keypad2Route));

//
// Add Keypad Method 3 - AddKeypad with Play data
//
keypads.Add(3, Keypad.KeypadType.Play, keypad3Play);

//
// Add Keypad Method 4 - AddKeypad(new List<IKeypad>())
//
keypads.Add(
    new List<Keypad>
    {
        new Keypad(4, keypad4Route)
    });

//
// Add Keypad Method 5 - AddKeypad(new List<Keypad>()) using Keypad objects
//
Keypad keypad5 = new Keypad();
keypad5.Tone = 5;
keypad5.RouteNumber = keypad5Route;

keypads.Add(keypad5);

//
// Add Keypad Method 6 - AddKeypad(new List()) with Play using Keypad objects
//
Keypad keypad6 = new Keypad();
keypad6.Tone = 6;
keypad6.Play = keypad6Play;

keypads.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 = keypad7Play;
keypad7.RouteNumber = keypad7Route;

keypads.Add(keypad7);

//
// Add Keypad Method 9 - Add Keypad 9 to play MessageToPeople (Main) section
//

keypads.Add(
    tone:9, 
    playSection: keypad9PlaySection
);

#endregion Add Keypads

#region Add Recipients

var recipients = new RecipientList();

//
// Add Recipient Method 1 - AddRecipient(string recipient);
//

recipients.Add(recipient1);

//
// Add Recipient Method 2 - AddRecipient(new Recipient())
//

var 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

recipients.Add(recipient);

//
// Add Recipient Method 3 - AddRecipients(new List<string>()); using simple destination
//

recipients.Add(new List<string>() { recipient3 });

//
// Add Recipient Method 4 - AddRecipients(new List<Recipient>()) using Recipient objects
//

recipients.Add(
    new List<Recipient>()
    {
        new Recipient(
            recipient4,             // Recipient
            "Test Company",         // Company Name
            "Test Recipient 3",     // Attention
            "Custom1",              // Custom1
            "Custom2",              // Custom2
            "Custom3",              // Custom3
            "Custom4",              // Custom4
            "Custom5"               // Custom5
        )
    }
);

#endregion Add Recipients

#region Add Recipients using TNZ Addressbook

//
// Add Recipient Method 5 - Add Recipients using GroupID
//

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

recipients.Add(groupID);

//
// Add Recipient Method 6 - Add Recipients using list of GroupIDs
//

var groupIDs = new List<GroupID>()
{
    new GroupID("HHHHHHHH-BBBB-BBBB-CCCC-DDDDDDDDDDDD"),
    new GroupID("IIIIIIII-BBBB-BBBB-CCCC-DDDDDDDDDDDD")
};

recipients.Add(groupIDs);

//
// Add Recipient Method 7 - Add Recipient using ContactID 
//

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

recipients.Add(contactID);

//
// Add Recipient Method 8 - Add Recipients using list of ContactIDs
//

var contactIDs = new List<ContactID>()
{
    new ContactID("DDDDDDDD-BBBB-BBBB-CCCC-DDDDDDDDDDDD"),
    new ContactID("EEEEEEEE-BBBB-BBBB-CCCC-DDDDDDDDDDDD")
};

recipients.Add(contactIDs);

#endregion

var response = client.Messaging.TTS.SendMessage(
    new TTSModel()
    {
        WebhookCallbackURL = webhookCallbackURL,            // Webhook Callback URL
        WebhookCallbackFormat = webhookCallbackFormat,      // Webhook Callback Format (XML/JSON)

        ErrorEmailNotify = errorEmailNotify,                // Error Email Notify (Receive email when it errored)

        MessageID = new MessageID(""),                      // MessageID - Leave blank to auto-generate
        Reference = reference,                              // Reference
        SubAccount = billingAccount,                        // Billing Account
        Department = "",                                    // Department
        ChargeCode = "",                                    // ChargeCode
        CallerID = callerId,                                // Caller Id
        ReportTo = reportTo,                                // Report To

        NumberOfOperators = numberOfOperators,              // No. of operators - No. of calls at a time
        RetryAttempts = retryAttempts,                      // Retry Attempts - number of retries
        RetryPeriod = retryPeriod,                          // Retry Period - number of minutes between retries

        TTSVoice = ttsVoice,                                // TTS Voice Engine
        MessageToPeople = messageToPeople,                  // Message to People
        MessageToAnswerPhones = messageToAnswerphones,      // Message to Answer Phones
        CallRouteMessageToPeople = callRouteMessageToPeople,// Call Route Message to People (when call is routed)
        CallRouteMessageToOperators = callRouteMessageToOperators,  // Call Route Message to AnswerPhones (when call is routed)
        CallRouteMessageOnWrongKey = callRouteMessageOnWrongKey,    // Call Route Message on Wrong Key (when wrong key is entered)

        Keypads = keypads.ToList(),                         // Keypads (1..9)
        KeypadOptionRequired = true,                        // Requires the callee presses a keypad option
        Recipients = recipients.ToList(),                   // Recipients

        SendTime = DateTime.Now,                            // SendTime
        Timezone = "New Zealand",                           // Timezone for SendTime

        SendMode = Enums.SendModeType.Test                  // TEST Mode - Remove this to send live traffic
    });

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Success - " + response.MessageID);
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

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)

Optional parameters

Parameter Example Value Description
MessageID ID12345 A Message Identifier helps you keep track of each message (maximum 40 characters, alphanumeric). Use a unique MessageID for each request. If you leave this field blank, the API will generate a 36-character UUID (v4) for you and include it in the response body.
Reference Test1 Human readable message description (free format field, maximum 80 characters)
WebhookCallbackURL https://www.example.com/webhook Overrides your Sender's default Webhook URL. Requires a default webhook to be configured. A full path including https:// is required.
WebhookCallbackFormat JSON Overrides your Sender's default Webhook format ('JSON' or 'XML')
SendTime 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.
Destination +6495005000 'Destination' property that will convert string field to Recipient object.
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

client.Messaging.TTS.SendMessage() Parameters

Option Structure Description
SendMessage(TTSModel)
MessageApiResult SendMessage(
    TTSModel entity
)                     
Function to send Text-To-Speech message based using TTSModel object.

Usage:
client.Messaging.TTS.SendMessage(
  new TTSModel(){...}
);


Returns MessageApiResult.
SendMessage(parameters)
MessageApiResult SendMessage(
    string messageID = null,
    string reference = null,
    DateTime? sendTime = null,
    string timezone = null,
    string subaccount = null,
    string department = null,
    string chargeCode = null,
    string messageToPeople = null,
    string messageToAnswerphones = null,
    string callRouteMessageToPeople = null,
    string callRouteMessageToOperators = null,
    string callRouteMessageOnWrongKey = null,
    int? numberOfOperators = null,
    string callerID = null,
    TTSVoiceType? ttsVoiceType = null,
    string options = null,
    ICollection<Keypad> keypads = null,
    GroupModel group = null,
    ICollection<GroupModel> groups = null,
    GroupID groupID = null,
    ICollection<GroupID> groupIDs = null,
    ContactModel contact = null,
    ICollection<ContactModel> contacts = null,
    ContactID contactID = null,
    ICollection<ContactID> contactIDs = null,
    string destination = null,
    ICollection<string> destinations = null,
    Recipient recipient = null,
    ICollection<Recipient> recipients = null,
    string webhookCallbackURL = null,
    WebhookCallbackType?
        webhookCallbackFormat = null,
    SendModeType? sendMode = null
)             
Function to send Text-To-Speech message using optional parameters.

Usage:
client.Messaging.TTS.SendMessage(
  destination:[phone number],
  messageToPeople: [message to send],
);


Returns MessageApiResult.
SendMessageAsync(TTSModel)
Task<MessageApiResult> SendMessageAsync(
    TTSModel entity
)                     
Function to send Text-To-Speech message using TTSModel object.

Usage:
await client.Messaging.TTS.SendMessageAsync(
  new TTSModel(){...}
);


Returns Task<MessageApiResult>.
SendMessageAsync(parameters)
Task<MessageApiResult> SendMessageAsync(
    string messageID = null,
    string reference = null,
    DateTime? sendTime = null,
    string timezone = null,
    string subaccount = null,
    string department = null,
    string chargeCode = null,
    string messageToPeople = null,
    string messageToAnswerphones = null,
    string callRouteMessageToPeople = null,
    string callRouteMessageToOperators = null,
    string callRouteMessageOnWrongKey = null,
    int? numberOfOperators = null,
    string callerID = null,
    TTSVoiceType? ttsVoiceType = null,
    string options = null,
    ICollection<Keypad> keypads = null,
    GroupModel group = null,
    ICollection<GroupModel> groups = null,
    GroupID groupID = null,
    ICollection<GroupID> groupIDs = null,
    ContactModel contact = null,
    ICollection<ContactModel> contacts = null,
    ContactID contactID = null,
    ICollection<ContactID> contactIDs = null,
    string destination = null,
    ICollection<string> destinations = null,
    Recipient recipient = null,
    ICollection<Recipient> recipients = null,
    string webhookCallbackURL = null,
    WebhookCallbackType?
        webhookCallbackFormat = null,
    SendModeType? sendMode = null
)             
Function to send Text-To-Speech message using optional parameters.

Usage:
await client.Messaging.TTS.SendMessageAsync(
  destination:[phone number],
  file: [message to send],
);


Returns Task<MessageApiResult>.

Useful Functions

Function Usage Description
AddRecipient()

AddRecipient(string recipient)

AddRecipient(Recipient recipient)

AddRecipient(ContactModel contact)

AddRecipient(ContactID contactID)

Function to add a single message recipient
AddRecipients()

AddRecipients(List<string> recipients)

AddRecipients(List<Recipient> recipients)

AddRecipients(GroupModel group)

AddRecipients(GroupID groupID)

AddRecipients(List<ContactModel> contacts)

AddRecipients(List<ContactID> contactIDs)

AddRecipients(List<GroupModel> groups)

AddRecipients(List<GroupID> groupIDs)

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)

Builder Class - TTSBuilder()

Function Usage Description
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) A Message Identifier helps you keep track of each message (maximum 40 characters, alphanumeric). Use a unique MessageID for each request. If you leave this field blank, the API will generate a 36-character UUID (v4) for you and include it in the response body.
SetReference() SetReference(string reference) Human readable message description (free format field, maximum 80 characters)
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(Recipient recipient)

AddRecipient(ContactModel contact)

AddRecipient(ContactID contactID)

Function to add a single message recipient
[Required]
AddRecipients()

AddRecipients(List<string> recipients)

AddRecipients(List<Recipient> recipients)

AddRecipients(GroupModel group)

AddRecipients(GroupID groupID)

AddRecipients(List<ContactModel> contacts)

AddRecipients(List<ContactID> contactIDs)

AddRecipients(List<GroupModel> groups)

AddRecipients(List<GroupID> groupIDs)

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 TTSModel() object and return
[Required]
BuildAsync() BuildAsync() Builds the TTSModel() object asynchronous and return

Sending messages in test mode

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
EmilModel.SendMode = Enums.SendModeType.Test;

// For SMS
SMSModel.SendMode = Enums.SendModeType.Test;

// For Fax
FaxModel.SendMode = Enums.SendModeType.Test;

// For Voice
VoiceModel.SendMode = Enums.SendModeType.Test;

// For TTS
TTSModel.SendMode = Enums.SendModeType.Test;
                                              

Edit Messages - Edit a submitted message

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


Retry Sending - Resubmit a failed message

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

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


 

Set Resubmit:


using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Actions.Resubmit.Submit(new MessageID("ID123456")); // Message ID

if (response.Result == Enums.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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Set Resubmit:


using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Actions.Resubmit.Submit(new MessageID("ID123456")); // Message ID

if (response.Result == Enums.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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Set Resubmit:


using TNZAPI.NET.Api.Actions.Reschedule;
using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var options = new ResubmitBuilder(new MessageID("ID123456"))    // MessageID
                .SetSendTime(new DateTime().AddMinutes(5))      // Optional: Set SendTime
                .SetTimezone("New Zealand")                     // Optional: Set Timezone
                .Build();

var response = client.Actions.Resubmit.Submit(options);

if (response.Result == Enums.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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Set Resubmit:


using TNZAPI.NET.Api.Actions.Resubmit.Dto;
using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Actions.Resubmit.Submit(new ResubmitRequestOptions()
{
    MessageID = new MessageID("ID123456"),      // MessageID
    SendTime = new DateTime().AddMinutes(5),    // Optional: Set SendTime
    Timezone = "New Zealand"                    // Optional: Set Timezone
});

if (response.Result == Enums.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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

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

Optional parameters

Parameter Example Value Description
SendTime DateTime.Now Scheduled Date/Time to resend message
Timezone New Zealand Sets the Timezone for SendTime. Leave blank to use system user default timezone.

client.Actions.Resubmit.Submit() Parameters

Option Structure Description
Submit(
  ResubmitRequestOptions
)
ResubmitApiResult Submit(
    ResubmitRequestOptions options
)                     
Retry failed message using ResubmitRequestOptions object.

Usage:
client.Actions.Resubmit.Submit(
  new ResubmitRequestOptions(){...}
);


Returns ResubmitApiResult.
Submit(MessageID)
ResubmitApiResult Submit(
    string messageID,
)             
Retry failed message using message id.

Usage:
client.Actions.Resubmit.Submit(
  [Message ID]
);


Returns ResubmitApiResult.
Submit(parameters)
ResubmitApiResult Submit(
    string messageID,
    DateTime sendTime, 
    string timezone = null
)             
Schedule to retry failed message on the specific date/time.

Usage:
client.Actions.Resubmit.Submit(
  [Message ID],
  [DateTime]
);


Returns ResubmitApiResult.
SubmitAsync(
  ResubmitRequestOptions
)
Task<ResubmitApiResult> SubmitAsync(
    ResubmitRequestOptions options
)                     
Retry failed message using ResubmitRequestOptions object.

Usage:
await client.Actions.Resubmit.SubmitAsync(
  new ResubmitRequestOptions(){...}
);


Returns Task<ResubmitApiResult>.
SubmitAsync(MessageID)
Task<ResubmitApiResult> SubmitAsync(
    string messageID,
)             
Retry failed message using message id.

Usage:
await client.Actions.Resubmit.SubmitAsync(
  [Message ID]
);


Returns Task<ResubmitApiResult>.
SubmitAsync(parameters)
Task<ResubmitApiResult> SubmitAsync(
    string messageID,
    DateTime sendTime, 
    string timezone = null
)             
Schedule to retry failed message on the specific date/time.

Usage:
await client.Actions.Resubmit.SubmitAsync(
  [Message ID],
  [DateTime]
);


Returns Task<ResubmitApiResult>.

ResubmitApiResult object parameters

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 List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

Builder Class - ResubmitBuilder()

Function Usage Description
SetMessageID() SetMessageID(string messageId) MessageID the Action should apply to
[Required]
SetSendTime() SetSendTime(DateTime sendTime) Delay sending until the specified date/time
SetTimezone() SetTimezone(string timezone) Sets the timezone for SendTime
Build() Build() Builds the ResubmitRequestOptions() object and return
[Required]
BuildAsync() BuildAsync() Builds the ResubmitRequestOptions() object asynchronous and return



Reschedule Sending - Adjust the Delayed Sending Date/Time

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

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


 

Set Reschedule:


using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Actions.Reschedule.Submit(
    messageID: new MessageID("ID123456"),               // MessageID
    sendTime: DateTime.Parse("2023-12-31T12:00:00")     // Set send time
);

if (response.Result == Enums.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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Set Reschedule:


using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Actions.Reschedule.Submit(
    messageID: new MessageID("ID123456"),               // MessageID
    sendTime: DateTime.Parse("2023-12-31T12:00:00")     // Set send time
);

if (response.Result == Enums.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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Set Reschedule:


using TNZAPI.NET.Api.Actions.Reschedule;
using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var options = new RescheduleBuilder(new MessageID("ID123456"))              // MessageID
                    .SetSendTime(DateTime.Parse("2024-12-31T12:00:00"))     // Set send time
                    .SetTimezone("New Zealand")                             // Timezone (optional)
                    .Build();

var response = client.Actions.Reschedule.Submit(options);

if (response.Result == Enums.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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Set Reschedule:


using TNZAPI.NET.Api.Actions.Reschedule.Dto;
using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Actions.Reschedule.Submit(
    new RescheduleRequestOptions()
    {
        MessageID = new MessageID("ID123456"),                             // MessageID
        SendTime = DateTime.Parse("2024-12-31T12:00:00"),   // Set send time
        Timezone = "New Zealand"                            // Timezone (optional)
    });

if (response.Result == Enums.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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

RescheduleRequest Required parameters

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-12T14:05:00 Reschedule sending for the specified date/time (dd/mm/yyyy HH:mm in your Account/Sender's default timezone setting)

Optional parameters

Parameter Example Value Description
Timezone New Zealand Sets the Timezone for SendTime. Leave blank to use system user default timezone.

client.Actions.Reschedule.Submit() Parameters

Option Structure Description
Submit(
  RescheduleRequestOptions
)
RescheduleApiResult Submit(
    RescheduleRequestOptions options
)                     
Reschedule pending message using RescheduleRequestOptions object.

Usage:
client.Actions.Reschedule.Submit(
  new RescheduleRequestOptions(){...}
);


Returns RescheduleApiResult.
Submit(parameters)
RescheduleApiResult Submit(
    string messageID,
    DateTime sendTime, 
    string timezone = null
)             
Reschedule pending message on the specific date/time.

Usage:
client.Actions.Reschedule.Submit(
  [Message ID],
  [DateTime]
);


Returns RescheduleApiResult.
SubmitAsync(
  RescheduleRequestOptions
)
Task<RescheduleApiResult> SubmitAsync(
    RescheduleRequestOptions options
)                     
Reschedule pending message using RescheduleRequestOptions object.

Usage:
await client.Actions.Reschedule.SubmitAsync(
  new RescheduleRequestOptions(){...}
);


Returns Task<RescheduleApiResult>.
SubmitAsync(parameters)
Task<RescheduleApiResult> SubmitAsync(
    string messageID,
    DateTime sendTime, 
    string timezone = null
)             
Reschedule pending message on the specific date/time.

Usage:
await client.Actions.Reschedule.SubmitAsync(
  [Message ID],
  [DateTime]
);


Returns Task<RescheduleApiResult>.

RescheduleApiResult object parameters

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)

Builder Class - RescheduleBuilder()

Function Usage Description
SetMessageID() SetMessageID(string message_id) MessageID the Action should apply to
[Required]
SetSendTime() SetSendTime(DateTime send_time) Reschedule specified date/time[Required]
SetTimezone() SetTimezone(string timezone) Timezone for scheduled date/time. Leave blank to use system user default.
Build() Build() Builds the RescheduleRequestOptions() object and return
[Required]
BuildAsync() BuildAsync() Builds the RescheduleRequestOptions() object asynchronous and return



Abort Sending - Cancel/Delete a Message from the Queue

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

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


 

Set Abort:


using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Actions.Abort.Submit(new MessageID("ID123456")); // MessageID

if (response.Result == Enums.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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Set Abort:


using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Actions.Abort.Submit(new MessageID("ID123456")); // MessageID

if (response.Result == Enums.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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Set Abort:


using TNZAPI.NET.Api.Actions.Abort;
using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var options = new AbortBuilder()
                    .SetMessageID(new MessageID("ID123456"))
                    .Build();

var response = client.Actions.Abort.Submit(options);

if (response.Result == Enums.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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Set Abort:


using TNZAPI.NET.Api.Actions.Abort.Dto;
using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Actions.Abort.Submit(
    new AbortRequestOptions()
    {
        MessageID = new MessageID("ID123456")      // MessageID
    });

if (response.Result == Enums.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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

AbortRequest Required parameters

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

client.Actions.Abort.Submit() Parameters

Option Structure Description
Submit(
  AbortRequestOptions
)
AbortApiResult Submit(
    AbortRequestOptions options
)                     
Cancel pending/sending message using AbortRequestOptions object.

Usage:
client.Actions.Abort.Submit(
  new AbortRequestOptions(){...}
);


Returns AbortApiResult.
Submit(MessageID)
AbortApiResult Submit(
    string messageID,
)             
Cancel pending/sending message using message id.

Usage:
client.Actions.Abort.Submit(
  [Message ID]
);


Returns AbortApiResult.
SubmitAsync(
  AbortRequestOptions
)
Task<AbortApiResult> SubmitAsync(
    AbortRequestOptions options
)                     
Cancel pending/sending message using AbortRequestOptions object.

Usage:
await client.Actions.Abort.SubmitAsync(
  new AbortRequestOptions(){...}
);


Returns Task<AbortApiResult>.
SubmitAsync(MessageID)
Task<AbortApiResult> SubmitAsync(
    string messageID,
)             
Cancel pending/sending message using message id.

Usage:
await client.Actions.Abort.SubmitAsync(
  [Message ID]
);


Returns Task<AbortApiResult>.

AbortApiResult object parameters

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)

Builder Class - AbortRequestBuilder()

Function Usage Description
SetMessageID() SetMessageID(string message_id) MessageID the Action should apply to
[Required]
Build() Build() Builds the AbortRequestOptions() object and return
[Required]
BuildAsync() BuildAsync() Builds the AbortRequestOptions() object asynchronous and return



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

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

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


 

Change NumberOfOperators:


using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Actions.Pacing.Submit(
    messageID: new MessageID("ID123456"),   // MessageID
    numberOfOperators: 1                    // No. of operators
);

if (response.Result == Enums.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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Change NumberOfOperators:


using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Actions.Pacing.Submit(
    messageID: new MessageID("ID123456"),   // MessageID
    numberOfOperators: 1                    // No. of operators
);

if (response.Result == Enums.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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Change NumberOfOperators:


using TNZAPI.NET.Api.Actions.Pacing;
using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var options = new PacingBuilder(new MessageID("ID123456"))  // MessageID
                    .SetNumberOfOperators(1)                // No. of operators
                    .Build();

var response = client.Actions.Pacing.Submit(options);

if (response.Result == Enums.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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Change NumberOfOperators:


using TNZAPI.NET.Api.Actions.Pacing.Dto;
using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Actions.Pacing.Submit(
    new PacingRequestOptions()
    {
        MessageID = new MessageID("ID123456"),     // MessageID
        NumberOfOperators = 1,      // No. of operators
    });

if (response.Result == Enums.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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

PacingRequest Required parameters

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

client.Actions.Pacing.Submit() Parameters

Option Structure Description
Submit(
  PacingRequestOptions
)
PacingApiResult Submit(
    PacingRequestOptions options
)                     
Update pacing value using PacingRequestOptions object.

Usage:
client.Actions.Pacing.Submit(
  new PacingRequestOptions(){...}
);


Returns PacingApiResult.
Submit(
  MessageID,
  NumberOfOperators

)
PacingApiResult Submit(
    string messageID,
    int numberOfOperators
)             
Update pacing value using message id.

Usage:
client.Actions.Pacing.Submit(
  [Message ID],
  [Number of Operators]
);


Returns PacingApiResult.
SubmitAsync(
  PacingRequestOptions
)
Task<PacingApiResult> SubmitAsync(
    PacingRequestOptions options
)                     
Update pacing value using PacingRequestOptions object.

Usage:
await client.Actions.Pacing.SubmitAsync(
  new PacingRequestOptions(){...}
);


Returns Task<PacingApiResult>.
SubmitAsync(
  MessageID,
  NumberOfOperators

)
Task<PacingApiResult> SubmitAsync(
    string messageID,
    int numberOfOperators
)             
Update pacing value using message id.

Usage:
await client.Actions.Pacing.SubmitAsync(
  [Message ID],
  [Number of Operators]
);


Returns Task<PacingApiResult>.

PacingApiResult object parameters

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)

Builder Class - PacingBuilder()

Function Usage Description
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 PacingRequestOptions() object and return
[Required]
BuildAsync() BuildAsync() Builds the PacingRequestOptions() object asynchronous and return

Status Reporting - Reporting and event tracking

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

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



Web Dashboard - Tracking message statuses via the online dashboard

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



SMTP Email - Receive message statuses via email

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

Whitelabelling of SMTP Email reports is available.

The email address to receive SMS Reply reports can be specified on the original message submission using the SMSEmailReply parameter.



Webhook - Message statuses delivered via a webhook

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

Webhooks are delivered as an HTTP POST in either XML or JSON format (your preference).
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


GET Status Poll - Track message statuses using a GET poll

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

 

Get Status:


using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var messageID = new MessageID("ID123456");

var response = client.Reports.Status.Poll(messageID);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Status of MessageID '{response.MessageID}':");
    Console.WriteLine($" => Status: '{response.Status}'");
    Console.WriteLine($" => JobNum: '{response.JobNum}'");
    Console.WriteLine($" => Account: '{response.Account}'");
    Console.WriteLine($" => SubAccount: '{response.SubAccount}'");
    Console.WriteLine($" => Department: '{response.Department}'");
    Console.WriteLine($" => Reference: '{response.Reference}'");
    Console.WriteLine($" => Created: '{response.Created}'");
    Console.WriteLine($" => CreatedUTC: '{response.CreatedUTC}'");
    Console.WriteLine($" => Delayed: '{response.Delayed}'");
    Console.WriteLine($" => DelayedUTC: '{response.DelayedUTC}'");
    Console.WriteLine($" => Count: {response.Count}");
    Console.WriteLine($" => Complete: {response.Complete}");
    Console.WriteLine($" => Success: {response.Success}");
    Console.WriteLine($" => Failed: {response.Failed}");
    Console.WriteLine($" => Price: {response.Price}");
    Console.WriteLine($" => TotalRecords (Recipients): {response.TotalRecords}");
    Console.WriteLine($" => PageCount (Recipients): {response.PageCount}");
    Console.WriteLine($" => RecordsPerPage (Recipients): {response.RecordsPerPage}");
    Console.WriteLine($" => Page (Recipients): {response.Page}");

    foreach (var message in response.Recipients)
    {
        Console.WriteLine($"======================================");
        Console.WriteLine($" => Message Delivered");
        Console.WriteLine($"    -> Type: '{message.Type}'");
        Console.WriteLine($"    -> DestSeq: '{message.DestSeq}'");
        Console.WriteLine($"    -> Destination: '{message.Destination}'");
        Console.WriteLine($"    -> Status: '{message.Status}'");
        Console.WriteLine($"    -> Result: '{message.Result}'");
        Console.WriteLine($"    -> SentTime: '{message.SentTime}'");
        Console.WriteLine($"    -> SentTimeUTC: '{message.SentTimeUTC}'");
        Console.WriteLine($"    -> Attention: '{message.Attention}'");
        Console.WriteLine($"    -> Company: '{message.Company}'");
        Console.WriteLine($"    -> Custom1: '{message.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{message.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{message.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{message.Custom4}'");
        Console.WriteLine($"    -> Custom5: '{message.Custom5}'");
        Console.WriteLine($"    -> Custom6: '{message.Custom6}'");
        Console.WriteLine($"    -> Custom7: '{message.Custom7}'");
        Console.WriteLine($"    -> Custom8: '{message.Custom8}'");
        Console.WriteLine($"    -> Custom9: '{message.Custom9}'");
        Console.WriteLine($"    -> RemoteID: '{message.RemoteID}'");
        Console.WriteLine($"    -> Price: {message.Price}");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Get Status:


using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var messageID = new MessageID("ID123456");

var response = client.Reports.Status.Poll(messageID);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Status of MessageID '{response.MessageID}':");
    Console.WriteLine($" => Status: '{response.Status}'");
    Console.WriteLine($" => JobNum: '{response.JobNum}'");
    Console.WriteLine($" => Account: '{response.Account}'");
    Console.WriteLine($" => SubAccount: '{response.SubAccount}'");
    Console.WriteLine($" => Department: '{response.Department}'");
    Console.WriteLine($" => Reference: '{response.Reference}'");
    Console.WriteLine($" => Created: '{response.Created}'");
    Console.WriteLine($" => CreatedUTC: '{response.CreatedUTC}'");
    Console.WriteLine($" => Delayed: '{response.Delayed}'");
    Console.WriteLine($" => DelayedUTC: '{response.DelayedUTC}'");
    Console.WriteLine($" => Count: {response.Count}");
    Console.WriteLine($" => Complete: {response.Complete}");
    Console.WriteLine($" => Success: {response.Success}");
    Console.WriteLine($" => Failed: {response.Failed}");
    Console.WriteLine($" => TotalRecords (Recipients): {response.TotalRecords}");
    Console.WriteLine($" => PageCount (Recipients): {response.PageCount}");
    Console.WriteLine($" => RecordsPerPage (Recipients): {response.RecordsPerPage}");
    Console.WriteLine($" => Page (Recipients): {response.Page}");

    foreach (var message in response.Recipients)
    {
        Console.WriteLine($"======================================");
        Console.WriteLine($" => Message Delivered");
        Console.WriteLine($"    -> Type: '{message.Type}'");
        Console.WriteLine($"    -> DestSeq: '{message.DestSeq}'");
        Console.WriteLine($"    -> Destination: '{message.Destination}'");
        Console.WriteLine($"    -> Status: '{message.Status}'");
        Console.WriteLine($"    -> Result: '{message.Result}'");
        Console.WriteLine($"    -> SentDate: '{message.SentDate}'");
        Console.WriteLine($"    -> Attention: '{message.Attention}'");
        Console.WriteLine($"    -> Company: '{message.Company}'");
        Console.WriteLine($"    -> Custom1: '{message.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{message.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{message.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{message.Custom4}'");
        Console.WriteLine($"    -> Custom5: '{message.Custom5}'");
        Console.WriteLine($"    -> Custom6: '{message.Custom6}'");
        Console.WriteLine($"    -> Custom7: '{message.Custom7}'");
        Console.WriteLine($"    -> Custom8: '{message.Custom8}'");
        Console.WriteLine($"    -> Custom9: '{message.Custom9}'");
        Console.WriteLine($"    -> RemoteID: '{message.RemoteID}'");
        Console.WriteLine($"    -> Price: '{message.Price}'");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Get Status:


using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Api.Reports.SMSReply;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var options = new StatusBuilder(new MessageID("ID123456"))
                .SetRecordsPerPage(50)
                .SetPage(1)
                .Build();

var response = client.Reports.Status.Poll(options);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Status of MessageID '{response.MessageID}':");
    Console.WriteLine($" => Status: '{response.Status}'");
    Console.WriteLine($" => JobNum: '{response.JobNum}'");
    Console.WriteLine($" => Account: '{response.Account}'");
    Console.WriteLine($" => SubAccount: '{response.SubAccount}'");
    Console.WriteLine($" => Department: '{response.Department}'");
    Console.WriteLine($" => Reference: '{response.Reference}'");
    Console.WriteLine($" => Created: '{response.Created}'");
    Console.WriteLine($" => CreatedUTC: '{response.CreatedUTC}'");
    Console.WriteLine($" => Delayed: '{response.Delayed}'");
    Console.WriteLine($" => DelayedUTC: '{response.DelayedUTC}'");
    Console.WriteLine($" => Count: {response.Count}");
    Console.WriteLine($" => Complete: {response.Complete}");
    Console.WriteLine($" => Success: {response.Success}");
    Console.WriteLine($" => Failed: {response.Failed}");
    Console.WriteLine($" => TotalRecords (Recipients): {response.TotalRecords}");
    Console.WriteLine($" => PageCount (Recipients): {response.PageCount}");
    Console.WriteLine($" => RecordsPerPage (Recipients): {response.RecordsPerPage}");
    Console.WriteLine($" => Page (Recipients): {response.Page}");

    foreach (var message in response.Recipients)
    {
        Console.WriteLine($"======================================");
        Console.WriteLine($" => Message Delivered");
        Console.WriteLine($"    -> Type: '{message.Type}'");
        Console.WriteLine($"    -> DestSeq: '{message.DestSeq}'");
        Console.WriteLine($"    -> Destination: '{message.Destination}'");
        Console.WriteLine($"    -> Status: '{message.Status}'");
        Console.WriteLine($"    -> Result: '{message.Result}'");
        Console.WriteLine($"    -> SentDate: '{message.SentDate}'");
        Console.WriteLine($"    -> Attention: '{message.Attention}'");
        Console.WriteLine($"    -> Company: '{message.Company}'");
        Console.WriteLine($"    -> Custom1: '{message.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{message.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{message.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{message.Custom4}'");
        Console.WriteLine($"    -> Custom5: '{message.Custom5}'");
        Console.WriteLine($"    -> Custom6: '{message.Custom6}'");
        Console.WriteLine($"    -> Custom7: '{message.Custom7}'");
        Console.WriteLine($"    -> Custom8: '{message.Custom8}'");
        Console.WriteLine($"    -> Custom9: '{message.Custom9}'");
        Console.WriteLine($"    -> RemoteID: '{message.RemoteID}'");
        Console.WriteLine($"    -> Price: '{message.Price}'");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Get Status:


using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Api.Reports.Status.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var options = new StatusRequestOptions()
{
    MessageID = new MessageID("ID123456"),
    RecordsPerPage = 50,
    Page = 1
};

var response = client.Reports.Status.Poll(options);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Status of MessageID '{response.MessageID}':");
    Console.WriteLine($" => Status: '{response.Status}'");
    Console.WriteLine($" => JobNum: '{response.JobNum}'");
    Console.WriteLine($" => Account: '{response.Account}'");
    Console.WriteLine($" => SubAccount: '{response.SubAccount}'");
    Console.WriteLine($" => Department: '{response.Department}'");
    Console.WriteLine($" => Reference: '{response.Reference}'");
    Console.WriteLine($" => Created: '{response.Created}'");
    Console.WriteLine($" => CreatedUTC: '{response.CreatedUTC}'");
    Console.WriteLine($" => Delayed: '{response.Delayed}'");
    Console.WriteLine($" => DelayedUTC: '{response.DelayedUTC}'");
    Console.WriteLine($" => Count: {response.Count}");
    Console.WriteLine($" => Complete: {response.Complete}");
    Console.WriteLine($" => Success: {response.Success}");
    Console.WriteLine($" => Failed: {response.Failed}");
    Console.WriteLine($" => Price: {response.Price}");
    Console.WriteLine($" => TotalRecords (Recipients): {response.TotalRecords}");
    Console.WriteLine($" => PageCount (Recipients): {response.PageCount}");
    Console.WriteLine($" => RecordsPerPage (Recipients): {response.RecordsPerPage}");
    Console.WriteLine($" => Page (Recipients): {response.Page}");

    foreach (var message in response.Recipients)
    {
        Console.WriteLine($"======================================");
        Console.WriteLine($" => Message Delivered");
        Console.WriteLine($"    -> Type: '{message.Type}'");
        Console.WriteLine($"    -> DestSeq: '{message.DestSeq}'");
        Console.WriteLine($"    -> Destination: '{message.Destination}'");
        Console.WriteLine($"    -> Status: '{message.Status}'");
        Console.WriteLine($"    -> Result: '{message.Result}'");
        Console.WriteLine($"    -> SentTime: '{message.SentTime}'");
        Console.WriteLine($"    -> SentTimeUTC: '{message.SentTimeUTC}'");
        Console.WriteLine($"    -> Attention: '{message.Attention}'");
        Console.WriteLine($"    -> Company: '{message.Company}'");
        Console.WriteLine($"    -> Custom1: '{message.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{message.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{message.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{message.Custom4}'");
        Console.WriteLine($"    -> Custom5: '{message.Custom5}'");
        Console.WriteLine($"    -> Custom6: '{message.Custom6}'");
        Console.WriteLine($"    -> Custom7: '{message.Custom7}'");
        Console.WriteLine($"    -> Custom8: '{message.Custom8}'");
        Console.WriteLine($"    -> Custom9: '{message.Custom9}'");
        Console.WriteLine($"    -> RemoteID: '{message.RemoteID}'");
        Console.WriteLine($"    -> Price: '{message.Price}'");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

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

client.Reports.Status.Poll() Parameters

Option Structure Description
Poll(
  StatusRequestOptions
)
StatusApiResult Poll(
    StatusRequestOptions options
)                     
Get message status using StatusRequestOptions object.

Usage:
client.Reports.Status.Poll(
  new StatusRequestOptions(){...}
);


Returns StatusApiResult.
Poll(MessageID)
StatusApiResult Poll(
    string messageID,
)             
Get message status using message id.

Usage:
client.Reports.Status.Poll(
  [Message ID]
);


Returns StatusApiResult.
PollAsync(
  StatusRequestOptions
)
Task<StatusApiResult> PollAsync(
    StatusRequestOptions options
)                     
Get message status using StatusRequestOptions object.

Usage:
await client.Reports.Status.PollAsync(
  new StatusRequestOptions(){...}
);


Returns Task<StatusApiResult>.
PollAsync(MessageID)
Task<StatusApiResult> PollAsync(
    string messageID,
)             
Get message status using message id.

Usage:
await client.Reports.Status.PollAsync(
  [Message ID]
);


Returns Task<StatusApiResult>.

StatusApiResult properties

Parameter Type Example Value Description
Result ResultCode ResultCode.Success Result of your API call (not the result of the message)
Status StatusCode StatusCode.Transmit Current Status of your message
MessageID string AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD A Message Identifier helps you keep track of each message (maximum 40 characters, alphanumeric). Use a unique MessageID for each request. If you leave this field blank, the API will generate a 36-character UUID (v4) for you and include it in the response body.
JobNum string 10AB20CE Eight digit alphanumeric tracking number (our internal Job Number)
Account string 100001 Your account number
SubAccount string Test SubAccount SubAccount associated with the message
Department string Test Department Department associated with the message
Reference string Test1 Human readable message description (free format field, maximum 80 characters).
Created DateTime 2023-12-31T12:00:00 Message creation date using your local timezone.
CreatedUTC DateTime 2023-12-31T00:00:00 Message creation date in UTC.
Delayed DateTime 2023-12-31T12:00:00 Message scheduled date using your local timezone.
DelayedUTC DateTime 2023-12-31T00:00:00 Message scheduled date in UTC.
Timezone string New Zealand Timezone for Created & Delayed
Count int 5 Total Destinations specified in the message
Complete int 5 Total Destinations where message transmission has completed
Success int 4 Total Destinations where message result is Success
Failed int 1 Total Destinations where message result is Failed
Price double 0.1 Price for the message
TotalRecords int 3 Total number of destinations
RecordsPerPage int 100 Return x number of records per request (optional)
PageCount int 1 Maximum number of pages
Page int 1 Current location of the result set (optional)
Recipients List<MessageRecipient> Recipient List of message recipients/destinations in detail
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

MessageRecipient properties

Parameter Type Example Value Description
Type MessageType MessageType.SMS Message Type - Email / SMS / Fax / Voice
DestSeq string 00000001 Unique identifier for the recipient in our system
Destination string +642100010002 Message recipient
Status ResultCode ResultCode.Success Current Status of this recipient
Result string Sent OK Current Status
SentDate DateTime 2023-12-31T12:00:00 Delivery date/time
Attention string Person Attention Indicates the attention or focus associated with the recipient.
Company string TNZ Group LTD. Specifies the company or organization associated with the recipient.
Custom1...4 string Custom value Represents custom fields or additional information associated with the recipient.
Price double 0.1 Represents transmission price for this recipient.

Builder Class - StatusRequestBuilder()

Function Usage Description
SetMessageID() SetMessageID(string message_id) MessageID the Action should apply to
[Required]
SetRecordsPerPage() SetRecordsPerPage(int recordsPerPage) Set Number of records per page
SetPage() SetPage(int page) Set current location of the result set
Build() Build() Builds the StatusRequest() object and return IStatusRequest
[Required]
BuildAsync() BuildAsync() Builds the StatusRequest() object asynchronous and return Task<IStatusRequest>

Receive Messages - Track messages received

Currently, tracking SMS Received is supported.

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



Web Dashboard - Tracking messages received via the online dashboard

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



SMTP Email - Track messages received via email

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.



Webhook - Messages received data delivered via a webhook

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

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

Webhooks are delivered as an HTTP POST in either XML or JSON format (your preference).
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


GET SMS Received Poll - Track SMS Received using a GET poll

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

 

Get SMS Received:


using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Reports.SMSReceived.List(
    timePeriod: 1440,       // No. of minutes
    recordsPerPage: 100,    // x numbers of records to return per request
    page: 1                 // current location
);

if (response.Result == Enums.ResultCode.Success)
{
    foreach (var received in response.Messages)
    {
        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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}          

Copy code

Get SMS Received:


using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Reports.SMSReceived.List(
    dateFrom: DateTime.Parse("2023-08-01T00:00:00"),    // Return results from the date/time
    dateTo: DateTime.Parse("2023-08-01T23:59:59"),      // Return results from the date/time
    page: 1                                             // current location
);

if (response.Result == Enums.ResultCode.Success)
{
    foreach (var received in response.Messages)
    {
        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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}          

Copy code

Get SMS Received:


using TNZAPI.NET.Api.Reports.SMSReceived;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var options = new SMSReceivedBuilder()
            .SetDateFrom("2023-08-01T00:00:00")             // Return results from the date/time
            .SetDateTo("2023-08-01T23:59:59")               // Return results to the date/time
            .SetRecordsPerPage(10)                          // x numbers of records to return per request
            .SetPage(1)                                     // current location
            .Build();

var response = client.Reports.SMSReceived.List(options);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Inbound SMS Messages:");

    foreach (var received in response.Messages)
    {
        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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}
          

Copy code

Get SMS Received:


using TNZAPI.NET.Api.Reports.SMSReceived.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var options = new SMSReceivedRequestOptions()
{
    DateFrom = DateTime.Parse("2023-08-01T00:00:00"),       // Return results from the date/time
    DateTo = DateTime.Parse("2023-08-01T23:59:59"),         // Return results to the date/time
    RecordsPerPage = 10,                                    // x numbers of records to return per request
    Page = 1                                                // current location
};

var response = client.Reports.SMSReceived.List(options);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine("Inbound SMS Messages:");

    foreach (var received in response.Messages)
    {
        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("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}          

Copy code

Required parameters

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)

client.Reports.SMSReceived.List() Parameters

Option Structure Description
List(
  SMSReceivedRequestOptions
)
SMSReceivedApiResult List(
    SMSReceivedRequestOptions options
)                     
Get received sms messages using SMSReceivedRequestOptions object.

Usage:
client.Reports.SMSReceived.List(
  new SMSReceivedRequestOptions(){...}
);


Returns SMSReceivedApiResult.
List(parameters)
SMSReceivedApiResult List(
    int? timePeriod = null,
    DateTime? dateFrom = null,
    DateTime? dateTo = null,
    int? recordsPerPage = null,
    int? page = null
)             
Get received sms messages using optional parameters.

Usage:
client.Reports.SMSReceived.List(
  dateFrom:DateTime.Parse("2023-12-01T00:00:00"),
  dateTo:DateTime.Parse("2023-12-01T23:59:59"),
  page:1
);


Returns SMSReceivedApiResult.
ListAsync(
  SMSReceivedRequestOptions
)
Task<SMSReceivedApiResult> ListAsync(
    SMSReceivedRequestOptions options
)                     
Get received sms messages using SMSReceivedRequestOptions object.

Usage:
await client.Reports.SMSReceived.ListAsync(
  new SMSReceivedRequestOptions(){...}
);


Returns Task<SMSReceivedApiResult>.
ListAsync(parameters)
Task<SMSReceivedApiResult> ListAsync(
    int? timePeriod = null,
    DateTime? dateFrom = null,
    DateTime? dateTo = null,
    int? recordsPerPage = null,
    int? page = null
)             
Get received sms messages using optional parameters.

Usage:
await client.Reports.SMSReceived.ListAsync(
  dateFrom:DateTime.Parse("2023-12-01T00:00:00"),
  dateTo:DateTime.Parse("2023-12-01T23:59:59"),
  page:1
);


Returns Task<SMSReceivedApiResult>.

Builder Class - SMSReceivedBuilder()

Function Usage Description
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 SMSReceivedRequestOptions() object and return
[Required]
BuildAsync() BuildAsync() Builds the SMSReceivedRequestOptions() object asynchronous and return

SMSReceivedApiResult object properties

Property 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)
TotalRecords int 3 Total number of received messages
RecordsPerPage int 100 Return x number of records per request (optional)
PageCount int 1 Maximum number of pages
Page int 1 Current location of the result set (optional)
Messages List<SMSMessageReceived> SMSMessageReceived List of SMS messages received
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

SMSMessageReceived properties

Property Type Example Value Description
ID int 123456 Unique identifier for this message
MessageID string ID123456 Original (message sent) message id corresponds to the recieved message
JobNum string ABCD1234 Original (message sent) job number corresponds to the recieved message
SubAccount string SubAccount01 Used for reporting, billing and Web Dashboard segmentation.
Department string Department01 Used for reporting, billing and Web Dashboard segmentation.
Date DateTime 2023-12-01T14:02:03 Date/Time SMS was received (yyyy-mm-dd HH:mm:ss)
DateUTC DateTime 2023-12-01T02:02:03 Date/Time SMS was received (yyyy-mm-dd HH:mm:ss) in UTC
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
Timezone string New Zealand Timezone used for Date


GET SMS Reply Poll - Track SMS replies using a GET poll

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

 

Get SMS Reply:


using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var messageID = new MessageID("ID123456");

var response = client.Reports.SMSReply.Poll(messageID);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Status of MessageID '{response.MessageID}':");
    Console.WriteLine($" => Status: '{response.Status}'");
    Console.WriteLine($" => JobNum: '{response.JobNum}'");
    Console.WriteLine($" => Account: '{response.Account}'");
    Console.WriteLine($" => SubAccount: '{response.SubAccount}'");
    Console.WriteLine($" => Department: '{response.Department}'");
    Console.WriteLine($" => Reference: '{response.Reference}'");
    Console.WriteLine($" => Created: '{response.Created}'");
    Console.WriteLine($" => CreatedUTC: '{response.CreatedUTC}'");
    Console.WriteLine($" => Delayed: '{response.Delayed}'");
    Console.WriteLine($" => DelayedUTC: '{response.DelayedUTC}'");
    Console.WriteLine($" => Count: {response.Count}");
    Console.WriteLine($" => Complete: {response.Complete}");
    Console.WriteLine($" => Success: {response.Success}");
    Console.WriteLine($" => Failed: {response.Failed}");
    Console.WriteLine($" => TotalRecords (Recipients): {response.TotalRecords}");
    Console.WriteLine($" => PageCount (Recipients): {response.PageCount}");
    Console.WriteLine($" => RecordsPerPage (Recipients): {response.RecordsPerPage}");
    Console.WriteLine($" => Page (Recipients): {response.Page}");

    foreach (var message in response.Recipients)
    {
        Console.WriteLine($"======================================");
        Console.WriteLine($" => Message Delivered");
        Console.WriteLine($"    -> Type: '{message.Type}'");
        Console.WriteLine($"    -> DestSeq: '{message.DestSeq}'");
        Console.WriteLine($"    -> Destination: '{message.Destination}'");
        Console.WriteLine($"    -> MessageText: '{message.MessageText}'");
        Console.WriteLine($"    -> Status: '{message.Status}'");
        Console.WriteLine($"    -> Result: '{message.Result}'");
        Console.WriteLine($"    -> SentDate: '{message.SentDate}'");
        Console.WriteLine($"    -> Attention: '{message.Attention}'");
        Console.WriteLine($"    -> Company: '{message.Company}'");
        Console.WriteLine($"    -> Custom1: '{message.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{message.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{message.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{message.Custom4}'");
        Console.WriteLine($"    -> Custom5: '{message.Custom5}'");
        Console.WriteLine($"    -> Custom6: '{message.Custom6}'");
        Console.WriteLine($"    -> Custom7: '{message.Custom7}'");
        Console.WriteLine($"    -> Custom8: '{message.Custom8}'");
        Console.WriteLine($"    -> Custom9: '{message.Custom9}'");
        Console.WriteLine($"    -> RemoteID: '{message.RemoteID}'");
        Console.WriteLine($"    -> Price: '{message.Price}'");

        foreach (var reply in message.SMSReplies)
        {
            Console.WriteLine($"======================================");
            Console.WriteLine($" => SMS Reply");
            Console.WriteLine($"    -> Date: '{reply.Date}'");
            Console.WriteLine($"    -> DateUTC: '{reply.DateUTC}'");
            Console.WriteLine($"    -> From: '{reply.From}'");
            Console.WriteLine($"    -> MessageText: '{reply.MessageText}'");
        }
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}          

Copy code

Get SMS Reply:


using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var messageID = new MessageID("ID123456");

var response = client.Reports.SMSReply.Poll(messageID);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Status of MessageID '{response.MessageID}':");
    Console.WriteLine($" => Status: '{response.Status}'");
    Console.WriteLine($" => JobNum: '{response.JobNum}'");
    Console.WriteLine($" => Account: '{response.Account}'");
    Console.WriteLine($" => SubAccount: '{response.SubAccount}'");
    Console.WriteLine($" => Department: '{response.Department}'");
    Console.WriteLine($" => Reference: '{response.Reference}'");
    Console.WriteLine($" => Created: '{response.Created}'");
    Console.WriteLine($" => CreatedUTC: '{response.CreatedUTC}'");
    Console.WriteLine($" => Delayed: '{response.Delayed}'");
    Console.WriteLine($" => DelayedUTC: '{response.DelayedUTC}'");
    Console.WriteLine($" => Count: {response.Count}");
    Console.WriteLine($" => Complete: {response.Complete}");
    Console.WriteLine($" => Success: {response.Success}");
    Console.WriteLine($" => Failed: {response.Failed}");
    Console.WriteLine($" => TotalRecords (Recipients): {response.TotalRecords}");
    Console.WriteLine($" => PageCount (Recipients): {response.PageCount}");
    Console.WriteLine($" => RecordsPerPage (Recipients): {response.RecordsPerPage}");
    Console.WriteLine($" => Page (Recipients): {response.Page}");

    foreach (var message in response.Recipients)
    {
        Console.WriteLine($"======================================");
        Console.WriteLine($" => Message Delivered");
        Console.WriteLine($"    -> Type: '{message.Type}'");
        Console.WriteLine($"    -> DestSeq: '{message.DestSeq}'");
        Console.WriteLine($"    -> Destination: '{message.Destination}'");
        Console.WriteLine($"    -> MessageText: '{message.MessageText}'");
        Console.WriteLine($"    -> Status: '{message.Status}'");
        Console.WriteLine($"    -> Result: '{message.Result}'");
        Console.WriteLine($"    -> SentDate: '{message.SentDate}'");
        Console.WriteLine($"    -> Attention: '{message.Attention}'");
        Console.WriteLine($"    -> Company: '{message.Company}'");
        Console.WriteLine($"    -> Custom1: '{message.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{message.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{message.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{message.Custom4}'");
        Console.WriteLine($"    -> Custom5: '{message.Custom5}'");
        Console.WriteLine($"    -> Custom6: '{message.Custom6}'");
        Console.WriteLine($"    -> Custom7: '{message.Custom7}'");
        Console.WriteLine($"    -> Custom8: '{message.Custom8}'");
        Console.WriteLine($"    -> Custom9: '{message.Custom9}'");
        Console.WriteLine($"    -> RemoteID: '{message.RemoteID}'");
        Console.WriteLine($"    -> Price: '{message.Price}'");

        foreach (var reply in message.SMSReplies)
        {
            Console.WriteLine($"======================================");
            Console.WriteLine($" => SMS Reply");
            Console.WriteLine($"    -> Date: '{reply.Date}'");
            Console.WriteLine($"    -> DateUTC: '{reply.DateUTC}'");
            Console.WriteLine($"    -> From: '{reply.From}'");
            Console.WriteLine($"    -> MessageText: '{reply.MessageText}'");
        }
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}          

Copy code

Get SMS Reply:


using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Api.Reports.SMSReply;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var options = new SMSReplyBuilder(new MessageID("ID123456"))
                .SetRecordsPerPage(50)
                .SetPage(1)
                .Build();

var response = client.Reports.SMSReply.Poll(options);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Status of MessageID '{response.MessageID}':");
    Console.WriteLine($" => Status: '{response.Status}'");
    Console.WriteLine($" => JobNum: '{response.JobNum}'");
    Console.WriteLine($" => Account: '{response.Account}'");
    Console.WriteLine($" => SubAccount: '{response.SubAccount}'");
    Console.WriteLine($" => Department: '{response.Department}'");
    Console.WriteLine($" => Reference: '{response.Reference}'");
    Console.WriteLine($" => Created: '{response.Created}'");
    Console.WriteLine($" => CreatedUTC: '{response.CreatedUTC}'");
    Console.WriteLine($" => Delayed: '{response.Delayed}'");
    Console.WriteLine($" => DelayedUTC: '{response.DelayedUTC}'");
    Console.WriteLine($" => Count: {response.Count}");
    Console.WriteLine($" => Complete: {response.Complete}");
    Console.WriteLine($" => Success: {response.Success}");
    Console.WriteLine($" => Failed: {response.Failed}");
    Console.WriteLine($" => TotalRecords (Recipients): {response.TotalRecords}");
    Console.WriteLine($" => PageCount (Recipients): {response.PageCount}");
    Console.WriteLine($" => RecordsPerPage (Recipients): {response.RecordsPerPage}");
    Console.WriteLine($" => Page (Recipients): {response.Page}");

    foreach (var message in response.Recipients)
    {
        Console.WriteLine($"======================================");
        Console.WriteLine($" => Message Delivered");
        Console.WriteLine($"    -> Type: '{message.Type}'");
        Console.WriteLine($"    -> DestSeq: '{message.DestSeq}'");
        Console.WriteLine($"    -> Destination: '{message.Destination}'");
        Console.WriteLine($"    -> MessageText: '{message.MessageText}'");
        Console.WriteLine($"    -> Status: '{message.Status}'");
        Console.WriteLine($"    -> Result: '{message.Result}'");
        Console.WriteLine($"    -> SentDate: '{message.SentDate}'");
        Console.WriteLine($"    -> Attention: '{message.Attention}'");
        Console.WriteLine($"    -> Company: '{message.Company}'");
        Console.WriteLine($"    -> Custom1: '{message.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{message.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{message.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{message.Custom4}'");
        Console.WriteLine($"    -> Custom5: '{message.Custom5}'");
        Console.WriteLine($"    -> Custom6: '{message.Custom6}'");
        Console.WriteLine($"    -> Custom7: '{message.Custom7}'");
        Console.WriteLine($"    -> Custom8: '{message.Custom8}'");
        Console.WriteLine($"    -> Custom9: '{message.Custom9}'");
        Console.WriteLine($"    -> RemoteID: '{message.RemoteID}'");
        Console.WriteLine($"    -> Price: '{message.Price}'");

        foreach (var reply in message.SMSReplies)
        {
            Console.WriteLine($"======================================");
            Console.WriteLine($" => SMS Reply");
            Console.WriteLine($"    -> Date: '{reply.Date}'");
            Console.WriteLine($"    -> DateUTC: '{reply.DateUTC}'");
            Console.WriteLine($"    -> From: '{reply.From}'");
            Console.WriteLine($"    -> MessageText: '{reply.MessageText}'");
        }
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}          

Copy code

Get SMS Reply:


using TNZAPI.NET.Api.Messaging.Common.Dto;
using TNZAPI.NET.Api.Reports.SMSReply.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var options = new SMSReplyRequestOptions()
{
    MessageID = new MessageID("ID123456"),
    RecordsPerPage = 50,
    Page = 1
};

var response = client.Reports.SMSReply.Poll(options);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Status of MessageID '{response.MessageID}':");
    Console.WriteLine($" => Status: '{response.Status}'");
    Console.WriteLine($" => JobNum: '{response.JobNum}'");
    Console.WriteLine($" => Account: '{response.Account}'");
    Console.WriteLine($" => SubAccount: '{response.SubAccount}'");
    Console.WriteLine($" => Department: '{response.Department}'");
    Console.WriteLine($" => Reference: '{response.Reference}'");
    Console.WriteLine($" => Created: '{response.Created}'");
    Console.WriteLine($" => CreatedUTC: '{response.CreatedUTC}'");
    Console.WriteLine($" => Delayed: '{response.Delayed}'");
    Console.WriteLine($" => DelayedUTC: '{response.DelayedUTC}'");
    Console.WriteLine($" => Count: {response.Count}");
    Console.WriteLine($" => Complete: {response.Complete}");
    Console.WriteLine($" => Success: {response.Success}");
    Console.WriteLine($" => Failed: {response.Failed}");
    Console.WriteLine($" => TotalRecords (Recipients): {response.TotalRecords}");
    Console.WriteLine($" => PageCount (Recipients): {response.PageCount}");
    Console.WriteLine($" => RecordsPerPage (Recipients): {response.RecordsPerPage}");
    Console.WriteLine($" => Page (Recipients): {response.Page}");

    foreach (var message in response.Recipients)
    {
        Console.WriteLine($"======================================");
        Console.WriteLine($" => Message Delivered");
        Console.WriteLine($"    -> Type: '{message.Type}'");
        Console.WriteLine($"    -> DestSeq: '{message.DestSeq}'");
        Console.WriteLine($"    -> Destination: '{message.Destination}'");
        Console.WriteLine($"    -> MessageText: '{message.MessageText}'");
        Console.WriteLine($"    -> Status: '{message.Status}'");
        Console.WriteLine($"    -> Result: '{message.Result}'");
        Console.WriteLine($"    -> SentDate: '{message.SentDate}'");
        Console.WriteLine($"    -> Attention: '{message.Attention}'");
        Console.WriteLine($"    -> Company: '{message.Company}'");
        Console.WriteLine($"    -> Custom1: '{message.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{message.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{message.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{message.Custom4}'");
        Console.WriteLine($"    -> Custom5: '{message.Custom5}'");
        Console.WriteLine($"    -> Custom6: '{message.Custom6}'");
        Console.WriteLine($"    -> Custom7: '{message.Custom7}'");
        Console.WriteLine($"    -> Custom8: '{message.Custom8}'");
        Console.WriteLine($"    -> Custom9: '{message.Custom9}'");
        Console.WriteLine($"    -> RemoteID: '{message.RemoteID}'");
        Console.WriteLine($"    -> Price: '{message.Price}'");

        foreach (var reply in message.SMSReplies)
        {
            Console.WriteLine($"======================================");
            Console.WriteLine($" => SMS Reply");
            Console.WriteLine($"    -> Date: '{reply.Date}'");
            Console.WriteLine($"    -> DateUTC: '{reply.DateUTC}'");
            Console.WriteLine($"    -> From: '{reply.From}'");
            Console.WriteLine($"    -> MessageText: '{reply.MessageText}'");
        }
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}          

Copy code

Required parameters

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

client.Reports.SMSReply.Poll() Parameters

Option Structure Description
List(
  SMSReplyRequestOptions
)
SMSReplyApiResult List(
    SMSReplyRequestOptions options
)                     
Get sms message detail and replies using SMSReplyRequestOptions object.

Usage:
client.Reports.SMSReply.Poll(
  new SMSReplyRequestOptions(){...}
);


Returns SMSReplyApiResult.
List(MessageID)
SMSReplyApiResult List(
    string messageID
)             
Get sms message detail and replies using MessageID.

Usage:
client.Reports.SMSReply.Poll(
  [message id]
);


Returns SMSReplyApiResult.
ListAsync(
  SMSReplyRequestOptions
)
Task<SMSReplyApiResult> ListAsync(
    SMSReplyRequestOptions options
)                     
Get sms message detail and replies SMSReplyRequestOptions object.

Usage:
await client.Reports.SMSReply.PollAsync(
  new SMSReplyRequestOptions(){...}
);


Returns Task<SMSReplyApiResult>.
ListAsync(MessageID)
Task<SMSReplyApiResult> ListAsync(
    string messageID
)             
Get sms message detail and replies MessageID.

Usage:
await client.Reports.SMSReply.PollAsync(
  [message id]
);


Returns Task<SMSReplyApiResult>.

Builder Class - SMSReplyBuilder()

Function Usage Description
SetMessageID() SetMessageID(string messageID) Return results from the message id
[Required]
SetRecordsPerPage() SetRecordsPerPage(int recordsPerPage) Set Number of records per page
SetPage() SetPage(int page) Set current location of the result set
Build() Build() Builds the SMSReplyRequestOptions() object and return
[Required]
BuildAsync() BuildAsync() Builds the SMSReplyRequestOptions() object asynchronous and return

SMSReplyApiResult properties

Property Type Example Value Description
Result ResultCode ResultCode.Success Result of your API call (not the result of the message)
Status StatusCode StatusCode.Completed 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
Reference string Your reference Your supplied reference of the message
Created DateTime 2023-12-01T12:00:00 Message creation date (your local time)
CreatedUTC DateTime 2023-12-01T00:00:00 Message creation date (UTC)
Delayed DateTime 2023-12-01T12:00:00 Message scheduled date (your local time)
DelayedUTC DateTime 2023-12-01T00:00:00 Message scheduled date (UTC)
Timezone string New Zealand Timezone for your local time
Count int 5 Total Destinations specified in the message
Complete int 5 Total Destinations where message transmission has completed
Success int 4 Total Destinations where message result is Success
Failed int 1 Total Destinations where message result is Failed
Price double 0.1 Price for the message
TotalRecords int 3 Total number of destinations
RecordsPerPage int 100 Return x number of records per request (optional)
PageCount int 1 Maximum number of pages
Page int 1 Current location of the result set (optional)
Recipients List<MessageRecipient> MessageRecipient Object List of recipients for the job
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

MessageRecipient object properties

Property Type Example Value Description
Type MessageType MessageType.SMS Message Type - Email / SMS / Fax / Voice
DestSeq string 00000001 Unique identifier for the recipient in our system
Destination string +642100010002 Message recipient
Status ResultCode ResultCode.Success Current Status of this recipient
Result string Sent OK Current Status
SentDate DateTime 2023-12-31T12:00:00 Delivery date/time
Attention string Person Attention Indicates the attention or focus associated with the recipient.
Company string TNZ Group LTD. Specifies the company or organization associated with the recipient.
Custom1...4 string Custom value Represents custom fields or additional information associated with the recipient.
Price double 0.1 Represents transmission price for this recipient.
SMSReplies List<SMSReply> SMSReply objects SMS Replies received on corresponding MessageRecipient

SMSReply object parameters

Parameter Type Example Value Description
Date DateTime 2023-12-01T14:02:03 Date/Time SMS was received (yyyy-mm-ddTHH:mm:ss) in your local time
DateUTC DateTime 2023-12-01T02:02:03 Date/Time SMS was received (yyyy-mm-dd HH:mm:ss)in UTC
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

List Contact - List Contact via .NET

 

List Contact (Basic):


using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.ContactList.List(
    recordsPerPage: 10,
    page: 1
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact list details");
    Console.WriteLine($"    -> Total Records: {response.TotalRecords}");
    Console.WriteLine($"    -> Records Per Page: {response.RecordsPerPage}");
    Console.WriteLine($"    -> Page Count: {response.PageCount}");
    Console.WriteLine($"    -> Page: {response.Page}");

    foreach (var contact in response.Contacts)
    {
        Console.WriteLine($"Contact details for ContactID={contact.ContactID}");
        Console.WriteLine($"    -> Owner: '{contact.Owner}'");
        Console.WriteLine($"    -> Created: '{contact.Created}'");
        Console.WriteLine($"    -> Updated: '{contact.Updated}'");
        Console.WriteLine($"    -> Attention: '{contact.Attention}'");
        Console.WriteLine($"    -> Company: '{contact.Company}'");
        Console.WriteLine($"    -> RecipDepartment: '{contact.CompanyDepartment}'");
        Console.WriteLine($"    -> FirstName: '{contact.FirstName}'");
        Console.WriteLine($"    -> LastName: '{contact.LastName}'");
        Console.WriteLine($"    -> Position: '{contact.Position}'");
        Console.WriteLine($"    -> StreetAddress: '{contact.StreetAddress}'");
        Console.WriteLine($"    -> Suburb: '{contact.Suburb}'");
        Console.WriteLine($"    -> City: '{contact.City}'");
        Console.WriteLine($"    -> State: '{contact.State}'");
        Console.WriteLine($"    -> Country: '{contact.Country}'");
        Console.WriteLine($"    -> Postcode: '{contact.Postcode}'");
        Console.WriteLine($"    -> MainPhone: '{contact.MainPhone}'");
        Console.WriteLine($"    -> AltPhone1: '{contact.AltPhone1}'");
        Console.WriteLine($"    -> AltPhone2: '{contact.AltPhone2}'");
        Console.WriteLine($"    -> DirectPhone: '{contact.DirectPhone}'");
        Console.WriteLine($"    -> MobilePhone: '{contact.MobilePhone}'");
        Console.WriteLine($"    -> FaxNumber: '{contact.FaxNumber}'");
        Console.WriteLine($"    -> EmailAddress: '{contact.EmailAddress}'");
        Console.WriteLine($"    -> WebAddress: '{contact.WebAddress}'");
        Console.WriteLine($"    -> Custom1: '{contact.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{contact.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{contact.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{contact.Custom4}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

List Contact (Simple):


using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.ContactList.List(
    recordsPerPage: 10,
    page: 1
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact list details");
    Console.WriteLine($"    -> Total Records: {response.TotalRecords}");
    Console.WriteLine($"    -> Records Per Page: {response.RecordsPerPage}");
    Console.WriteLine($"    -> Page Count: {response.PageCount}");
    Console.WriteLine($"    -> Page: {response.Page}");

    foreach (var contact in response.Contacts)
    {
        Console.WriteLine($"Contact details for ContactID={contact.ContactID}");
        Console.WriteLine($"    -> Owner: '{contact.Owner}'");
        Console.WriteLine($"    -> Created: '{contact.Created}'");
        Console.WriteLine($"    -> Updated: '{contact.Updated}'");
        Console.WriteLine($"    -> Attention: '{contact.Attention}'");
        Console.WriteLine($"    -> Company: '{contact.Company}'");
        Console.WriteLine($"    -> RecipDepartment: '{contact.CompanyDepartment}'");
        Console.WriteLine($"    -> FirstName: '{contact.FirstName}'");
        Console.WriteLine($"    -> LastName: '{contact.LastName}'");
        Console.WriteLine($"    -> Position: '{contact.Position}'");
        Console.WriteLine($"    -> StreetAddress: '{contact.StreetAddress}'");
        Console.WriteLine($"    -> Suburb: '{contact.Suburb}'");
        Console.WriteLine($"    -> City: '{contact.City}'");
        Console.WriteLine($"    -> State: '{contact.State}'");
        Console.WriteLine($"    -> Country: '{contact.Country}'");
        Console.WriteLine($"    -> Postcode: '{contact.Postcode}'");
        Console.WriteLine($"    -> MainPhone: '{contact.MainPhone}'");
        Console.WriteLine($"    -> AltPhone1: '{contact.AltPhone1}'");
        Console.WriteLine($"    -> AltPhone2: '{contact.AltPhone2}'");
        Console.WriteLine($"    -> DirectPhone: '{contact.DirectPhone}'");
        Console.WriteLine($"    -> MobilePhone: '{contact.MobilePhone}'");
        Console.WriteLine($"    -> FaxNumber: '{contact.FaxNumber}'");
        Console.WriteLine($"    -> EmailAddress: '{contact.EmailAddress}'");
        Console.WriteLine($"    -> WebAddress: '{contact.WebAddress}'");
        Console.WriteLine($"    -> Custom1: '{contact.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{contact.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{contact.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{contact.Custom4}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

List Contact (Builder):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;
using TNZAPI.NET.Core.Builders;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var options = new ListRequestOptionBuilder<ContactListRequestOptions>()
                    .SetRecordsPerPage(10)
                    .SetPage(1)
                    .Build();

var response = client.Addressbook.ContactList.List(options);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact list details");
    Console.WriteLine($"    -> Total Records: {response.TotalRecords}");
    Console.WriteLine($"    -> Records Per Page: {response.RecordsPerPage}");
    Console.WriteLine($"    -> Page Count: {response.PageCount}");
    Console.WriteLine($"    -> Page: {response.Page}");

    foreach (var contact in response.Contacts)
    {
        Console.WriteLine($"Contact details for ContactID={contact.ContactID}");
        Console.WriteLine($"    -> Owner: '{contact.Owner}'");
        Console.WriteLine($"    -> Created: '{contact.Created}'");
        Console.WriteLine($"    -> Updated: '{contact.Updated}'");
        Console.WriteLine($"    -> Attention: '{contact.Attention}'");
        Console.WriteLine($"    -> Company: '{contact.Company}'");
        Console.WriteLine($"    -> RecipDepartment: '{contact.CompanyDepartment}'");
        Console.WriteLine($"    -> FirstName: '{contact.FirstName}'");
        Console.WriteLine($"    -> LastName: '{contact.LastName}'");
        Console.WriteLine($"    -> Position: '{contact.Position}'");
        Console.WriteLine($"    -> StreetAddress: '{contact.StreetAddress}'");
        Console.WriteLine($"    -> Suburb: '{contact.Suburb}'");
        Console.WriteLine($"    -> City: '{contact.City}'");
        Console.WriteLine($"    -> State: '{contact.State}'");
        Console.WriteLine($"    -> Country: '{contact.Country}'");
        Console.WriteLine($"    -> Postcode: '{contact.Postcode}'");
        Console.WriteLine($"    -> MainPhone: '{contact.MainPhone}'");
        Console.WriteLine($"    -> AltPhone1: '{contact.AltPhone1}'");
        Console.WriteLine($"    -> AltPhone2: '{contact.AltPhone2}'");
        Console.WriteLine($"    -> DirectPhone: '{contact.DirectPhone}'");
        Console.WriteLine($"    -> MobilePhone: '{contact.MobilePhone}'");
        Console.WriteLine($"    -> FaxNumber: '{contact.FaxNumber}'");
        Console.WriteLine($"    -> EmailAddress: '{contact.EmailAddress}'");
        Console.WriteLine($"    -> WebAddress: '{contact.WebAddress}'");
        Console.WriteLine($"    -> Custom1: '{contact.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{contact.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{contact.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{contact.Custom4}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

List Contact (Advanced):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.ContactList.List(
    new ContactListRequestOptions()
    {
        RecordsPerPage = 10,
        Page = 1
    }
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact list details");
    Console.WriteLine($"    -> Total Records: {response.TotalRecords}");
    Console.WriteLine($"    -> Records Per Page: {response.RecordsPerPage}");
    Console.WriteLine($"    -> Page Count: {response.PageCount}");
    Console.WriteLine($"    -> Page: {response.Page}");

    foreach (var contact in response.Contacts)
    {
        Console.WriteLine($"Contact details for ContactID={contact.ContactID}");
        Console.WriteLine($"    -> Owner: '{contact.Owner}'");
        Console.WriteLine($"    -> Created: '{contact.Created}'");
        Console.WriteLine($"    -> Updated: '{contact.Updated}'");
        Console.WriteLine($"    -> Attention: '{contact.Attention}'");
        Console.WriteLine($"    -> Company: '{contact.Company}'");
        Console.WriteLine($"    -> RecipDepartment: '{contact.CompanyDepartment}'");
        Console.WriteLine($"    -> FirstName: '{contact.FirstName}'");
        Console.WriteLine($"    -> LastName: '{contact.LastName}'");
        Console.WriteLine($"    -> Position: '{contact.Position}'");
        Console.WriteLine($"    -> StreetAddress: '{contact.StreetAddress}'");
        Console.WriteLine($"    -> Suburb: '{contact.Suburb}'");
        Console.WriteLine($"    -> City: '{contact.City}'");
        Console.WriteLine($"    -> State: '{contact.State}'");
        Console.WriteLine($"    -> Country: '{contact.Country}'");
        Console.WriteLine($"    -> Postcode: '{contact.Postcode}'");
        Console.WriteLine($"    -> MainPhone: '{contact.MainPhone}'");
        Console.WriteLine($"    -> AltPhone1: '{contact.AltPhone1}'");
        Console.WriteLine($"    -> AltPhone2: '{contact.AltPhone2}'");
        Console.WriteLine($"    -> DirectPhone: '{contact.DirectPhone}'");
        Console.WriteLine($"    -> MobilePhone: '{contact.MobilePhone}'");
        Console.WriteLine($"    -> FaxNumber: '{contact.FaxNumber}'");
        Console.WriteLine($"    -> EmailAddress: '{contact.EmailAddress}'");
        Console.WriteLine($"    -> WebAddress: '{contact.WebAddress}'");
        Console.WriteLine($"    -> Custom1: '{contact.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{contact.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{contact.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{contact.Custom4}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

Parameter Example Value Description
AuthToken eyJhbGciOiJI...adQssw5c Auth Token value set up in Create a new API Auth token

Optional parameters

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

client.Addressbook.ContactList.List() Parameters

Option Structure Description
List(
  ListRequestOptions
)
ContactListApiResult List(
    IListRequestOptions options
)                     
Get contact list using ListRequestOptions object.

Usage:
client.Addressbook.ContactList.List(
  new ListRequestOptions(){...}
);


Returns ContactListApiResult.
List(parameters)
ContactListApiResult List(
    int? recordsPerPage = null, 
    int? page = null
)             
Get contact list using optional parameters.

Usage:
client.Addressbook.ContactList.List(
  page:[Page number]
);


Returns ContactListApiResult.
ListAsync(
  ListRequestOptions
)
Task<ContactListApiResult> ListAsync(
    IListRequestOptions options
)                     
Get contact list using ListRequestOptions object.

Usage:
await client.Addressbook.ContactList.ListAsync(
  new ListRequestOptions(){...}
);


Returns Task<ContactListApiResult>.
ListAsync(parameters)
Task<ContactListApiResult> ListAsync(
    int? recordsPerPage = null, 
    int? page = null
)             
Get contact list using optional parameters.

Usage:
await client.Addressbook.ContactList.ListAsync(
  page:[Page number]
);


Returns Task<ContactListApiResult>.

IListRequestOptions properties

Property Type Example Value Description
RecordsPerPage int 100 Number of records per API request to be returned.
Page int 1 Current location of data set.

Builder Class - ListRequestOptionBuilder<T>()

Function Usage Description
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 ListRequestOption<T>() object and return T
[Required]
BuildAsync() BuildAsync() Builds the ListRequestOption<T>() object asynchronous and return Task<T>

ContactListApiResult object properties

Property Type Example Value Description
Result ResultCode ResultCode.Success Result of your API call (not the result of the message)
TotalRecords int 3 Total number of contacts
RecordsPerPage int 100 Return x number of records per request (optional)
PageCount int 1 Maximum number of pages
Page int 1 Current location of the result set (optional)
Contacts List<ContactModel> ContactModel List of contacts
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

Get Contact Detail - Get Contact Detail via .NET

 

Get Contact Detail (Basic):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.Contact.Read(new ContactID("AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD"));

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Get Contact Detail (Simple):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.Contact.Read(new ContactID("AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD"));

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Get Contact Detail (Builder):


using TNZAPI.NET.Api.Addressbook.Contact;
using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var contact = new ContactBuilder(new ContactID("AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD"))
                .Build();

var response = client.Addressbook.Contact.Read(contact);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Get Contact Detail (Advanced):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.Contact.Read(
    new ContactModel()
    {
        ContactID = new ContactID("AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD")
    }
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

Parameter Example Value Description
AuthToken eyJhbGciOiJI...adQssw5c Auth Token value set up in Create a new API Auth token
ContactModel ContactModel object Specifies the ContactModel object with ID required of the contact to retrieve. (required)
ContactID AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD Specifies the unique identifier of the contact to retrieve.

client.Addressbook.Contact.Read() Parameters

Option Structure Description
Read(
  ContactModel
)
ContactApiResult Read(
    ContactModel contact
)                     
Get contact detail using ContactModel object.

Usage:
client.Addressbook.Contact.Read(
  new ContactModel(){...}
);


Returns ContactApiResult.
ReadById(ContactID)
ContactApiResult ReadById(
    string contactID
)             
Get contact detail using contact id.

Usage:
client.Addressbook.Contact.ReadById(
  [ContactID]
);


Returns ContactApiResult.
ReadAsync(
  ContactModel
)
Task<ContactApiResult> ReadAsync(
    ContactModel contact
)                     
Get contact detail ContactModel object.

Usage:
await client.Addressbook.Contact.ReadAsync(
  new ContactModel(){...}
);


Returns Task<ContactApiResult>.
ReadByIdAsync(ContactID)
Task<ContactApiResult> ReadByIdAsync(
    string contactID
)             
Get contact detail using contact id.

Usage:
await client.Addressbook.Contact.ReadByIdAsync(
  [ContactID]
);


Returns Task<ContactApiResult>.

ContactApiResult object properties

Property Type Example Value Description
Result ResultCode ResultCode.Success Result of your API call (not the result of the message)
Contact ContactModel ContactModel object Contact detail
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

ContactModel object properties

Property Type Example Value Description
ID string AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD Unique identifier for the contact
Owner string COM\EXAMPLE\TEST Your UserKey
Created DateTime 2023-12-01T12:00:00 Creation date for this contact in your local date/time
CreatedUTC DateTime 2023-12-01T00:00:00 Creation date for this contact in UTC date/time
Updated DateTime 2023-12-01T12:00:00 Last updated date for this contact in your local date/time
UpdatedUTC DateTime 2023-12-01T00:00:00 Last updated date for this contact in UTC date/time
Timezone string New Zealand Timezone associated with Created/Updated date/time
Attention string Person Attention Indicates the attention or focus associated with the contact.
Title string Ms Represents the title or honorific of the contact (e.g., Mr, Mrs, Ms).
Company string TNZ Group LTD. Specifies the company or organization associated with the contact.
CompanyDepartment string Sales Dept. Indicates the department or division within the company associated with the contact.
FirstName string Person first name Represents the first name of the contact.
LastName string Person last name Represents the last name of the contact.
Position string Sales Represent Specifies the job position or role of the contact.
StreetAddress string Sales Represent Represents the street address or location of the contact.
Suburb string My Suburb Specifies the suburb or district associated with the contact's address.
City string Auckland Indicates the city or locality associated with the contact's address.
State string AKL Represents the state or province associated with the contact's address.
Country string New Zealand Specifies the country associated with the contact's address.
Postcode string 1234 Represents the postal code or ZIP code associated with the contact's address.
MainPhone string 092223333 Specifies the main phone number of the contact. This property typically used for Voice & Text-To-Speech messages.
AltPhone1 string 093334444 Represents an alternate phone number for the contact. This property typically used for Voice & Text-To-Speech messages.
AltPhone2 string 094445555 Represents a second alternate phone number for the contact. This property typically used for Voice & Text-To-Speech messages.
DirectPhone string 094445555 Indicates the direct phone number of the contact.
MobilePhone string 0211144489 Represents the mobile phone number of the contact. This property typically used for SMS messages.
FaxNumber string 093334444 Specifies the fax number associated with the contact.
EmailAddress string person1@example.com Represents the email address of the contact.
WebAddress string https://www.tnz.co.nz Specifies the website address or URL associated with the contact.
Custom1...4 string Custom Value Represents custom fields or additional information associated with the contact.
ViewBy ViewEditByOptions ViewEditByOptions.Account Specifies the visibility of the contact. Values can be "Account", "SubAccount", "Department" or "No" visibility option.
EditBy ViewEditByOptions ViewEditByOptions.Account Specifies the permission level required to edit the contact. Values can be "Account", "SubAccount", "Department" or "No" permission option.

Create Contact - Create Contact via .NET

 

Create Contact (Basic):


using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.Contact.Create(
    attention: "Test Person",
    firstName: "Test",
    lastName: "Person",
    mobilePhone: "+6421000001"
    );

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Create Contact (Simple):


using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.Contact.Create(
    attention: "Test Person",
    firstName: "Test",
    lastName: "Person",
    mainPhone: "+6495005001",
    mobilePhone: "+6421000001",
    emailAddress: "recipient.one@example.com",
    faxNumber: "+6495005002",
    viewBy: Enums.ViewEditByOptions.Account,
    editBy: Enums.ViewEditByOptions.Account
    );

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Create Contact (Builder):


using TNZAPI.NET.Api.Addressbook.Contact;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var contact = new ContactBuilder()
                .SetAttention("Test Person")
                .SetFirstName("Test")
                .SetLastName("Person")
                .SetMainPhone("+6495005001")
                .SetMobilePhone("+6421000001")
                .SetEmailAddress("recipient.one@example.com")
                .SetFaxNumber("+6495005002")
                .SetViewBy(Enums.ViewEditByOptions.Account)
                .SetEditBy(Enums.ViewEditByOptions.Account)
                .Build();

var response = client.Addressbook.Contact.Create(contact);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Create Contact (Advanced):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.Contact.Create(
    new ContactModel()
    {
        Attention = "Person Attention",
        Title = "Mr",
        Company = "TNZ Group LTD.",
        CompanyDepartment = "",
        FirstName = "Person first name",
        LastName = "Person last name",
        Position = "",
        StreetAddress = "123 ABC st.",
        Suburb = "My Suburb",
        City = "Auckland",
        State = "",
        Country = "New Zealand",
        Postcode = "1234",
        MainPhone = "092223333",
        AltPhone1 = "",
        AltPhone2 = "",
        DirectPhone = "",
        MobilePhone = "0211144489",
        FaxNumber = "093334444",
        EmailAddress = "person1@example.com",
        WebAddress = "",
        Custom1 = "",
        Custom2 = "",
        Custom3 = "",
        Custom4 = "",
        ViewBy = Enums.ViewEditByOptions.Account,
        EditBy = Enums.ViewEditByOptions.No
    }
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

Parameter Example Value Description
AuthToken eyJhbGciOiJI...adQssw5c Auth Token value set up in Create a new API Auth token
ContactModel ContactModel object Specifies ContactModel object to create

client.Addressbook.Contact.Create() Parameters

Option Structure Description
Create(
  ContactModel
)
ContactApiResult Create(
    ContactModel entity
)                     
Creates contact using ContactModel object.

Usage:
client.Addressbook.Contact.Create(
  new ContactModel(){...}
);


Returns ContactApiResult.
Create(parameters)
ContactApiResult Create(
    string attention = null,
    string title = null,
    string company = null,
    string companyDepartment = null,
    string firstName = null,
    string lastName = null,
    string position = null,
    string streetAddress = null,
    string suburb = null,
    string city = null,
    string state = null,
    string country = null,
    string postcode = null,
    string mainPhone = null,
    string altPhone1 = null,
    string altPhone2 = null,
    string directPhone = null,
    string mobilePhone = null,
    string faxNumber = null,
    string emailAddress = null,
    string webAddress = null,
    string custom1 = null,
    string custom2 = null,
    string custom3 = null,
    string custom4 = null,
    Enums.ViewEditByOptions? viewBy = null,
    Enums.ViewEditByOptions? editBy = null
)             
Creates contact using optional parameters.

Usage:
client.Addressbook.Contact.Create(
  attention: "Test Person",
  firstName: "Test",
  lastName: "Person",
  mobilePhone: "+6421000001"
);


Returns ContactApiResult.
CreateAsync(
  ContactModel
)
Task<ContactApiResult> CreateAsync(
    ContactModel entity
)                     
Creates contact using ContactModel object.

Usage:
await client.Addressbook.Contact.CreateAsync(
  new ContactModel(){...}
);


Returns Task<ContactApiResult>.
CreateAsync(parameters)
Task<ContactApiResult> CreateAsync(
    string attention = null,
    string title = null,
    string company = null,
    string companyDepartment = null,
    string firstName = null,
    string lastName = null,
    string position = null,
    string streetAddress = null,
    string suburb = null,
    string city = null,
    string state = null,
    string country = null,
    string postcode = null,
    string mainPhone = null,
    string altPhone1 = null,
    string altPhone2 = null,
    string directPhone = null,
    string mobilePhone = null,
    string faxNumber = null,
    string emailAddress = null,
    string webAddress = null,
    string custom1 = null,
    string custom2 = null,
    string custom3 = null,
    string custom4 = null,
    Enums.ViewEditByOptions? viewBy = null,
    Enums.ViewEditByOptions? editBy = null
)             
Creates contact using optional parameters.

Usage:
await client.Addressbook.Contact.CreateAsync(
  attention: "Test Person",
  firstName: "Test",
  lastName: "Person",
  mobilePhone: "+6421000001"
);


Returns Task<ContactApiResult>.

Builder Class - ContactBuilder()

Method Usage Description
SetAttention() SetAttention(string attention) Sets the attention or focus associated with the contact.
SetTitle() SetTitle(string title) Sets the title or honorific of the contact (e.g., Mr, Mrs, Ms).
SetCompany() SetCompany(string company) Sets the company or organization associated with the contact.
SetCompanyDepartment() SetCompanyDepartment(string department) Sets the department or division within the company associated with the contact.
SetFirstName() SetFirstName(string firstName) Sets the first name of the contact.
SetLastName() SetLastName(string lastName) Sets the last name of the contact.
SetPosition() SetPosition(string position) Sets the job position or role of the contact.
SetStreetAddress() SetStreetAddress(string streetAddress) Sets the street address or location of the contact.
SetSuburb() SetSuburb(string suburb) Sets the suburb or district associated with the contact's address.
SetCity() SetCity(string city) Sets the city or locality associated with the contact's address.
SetState() SetState(string state) Sets the state or province associated with the contact's address.
SetCountry() SetCountry(string country) Sets the country associated with the contact's address.
SetPostCode() SetPostCode(string postCode) Sets the postal code or ZIP code associated with the contact's address.
SetMainPhone() SetMainPhone(string mainPhone) Sets the main phone number of the contact.
SetAltPhone1() SetAltPhone1(string altPhone1) Sets the alternate phone number 1 for the contact.
SetAltPhone2() SetAltPhone2(string altPhone2) Sets the alternate phone number 2 for the contact.
SetDirectPhone() SetDirectPhone(string ddiNumber) Sets the direct phone number of the contact.
SetMobilePhone() SetMobilePhone(string mobilePhone) Sets the mobile phone number of the contact.
SetFaxNumber() SetFaxNumber(string faxNumber) Sets the fax number associated with the contact.
SetEmailAddress() SetEmailAddress(string emailAddress) Sets the email address of the contact.
SetWebAddress() SetWebAddress(string webAddress) Sets the website address or URL associated with the contact.
SetCustom1() SetCustom1(string custom1) Sets the custom field 1 or additional information associated with the contact.
SetCustom2() SetCustom2(string custom2) Sets the custom field 2 or additional information associated with the contact.
SetCustom3() SetCustom3(string custom3) Sets the custom field 3 or additional information associated with the contact.
SetCustom4() SetCustom4(string custom4) Sets the custom field 4 or additional information associated with the contact.
SetViewBy() SetViewBy(Enums.ViewEditByOptions viewBy) Sets the visibility of the contact.
SetEditBy() SetEditBy(Enums.ViewEditByOptions editBy) Sets the permission level required to edit the contact.
Set<T>() Set<T>(Expression<Func<T, object>> propertyExpression, object value) Sets a property of the contact using an expression.
Build() Build() Builds the ContactModel object based on the configured properties.
BuildAsync() BuildAsync() Asynchronously builds the ContactModel object based on the configured properties.

ContactApiResult object properties

Property Type Example Value Description
Result ResultCode ResultCode.Success Result of your API call (not the result of the message)
Contact ContactModel ContactModel object Contact detail
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

Update Contact - Update Contact via .NET

 

Update Contact (Basic):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Addressbook.Contact.Update(
          contactID: contactID,           // Contact ID (required)
          attention: "Test Person"
      );

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Update Contact (Simple):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Addressbook.Contact.Update(
          contactID: contactID,      // ContactID (required)
          attention: "Test Person",
          firstName: "Test",
          lastName: "Person",
          mainPhone: "+6495005001",
          mobilePhone: "+6421000001",
          emailAddress: "recipient.one@example.com",
          faxNumber: "+6495005002",
          viewBy: Enums.ViewEditByOptions.Account,
          editBy: Enums.ViewEditByOptions.Account
          );

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Update Contact (Builder):


using TNZAPI.NET.Api.Addressbook.Contact;
using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var contact = new ContactBuilder(new ContactID("AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD"))    // Initiate builder with ContactID
                .SetAttention("Test Person")
                .SetFirstName("Test")
                .SetLastName("Person")
                .SetMainPhone("+6495005001")
                .SetMobilePhone("+6421000001")
                .SetEmailAddress("recipient.one@example.com")
                .SetFaxNumber("+6495005002")
                .SetViewBy(Enums.ViewEditByOptions.Account)
                .SetEditBy(Enums.ViewEditByOptions.Account)
                .Build();

var response = client.Addressbook.Contact.Update(contact);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Update Contact (Advanced):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.Contact.Update(
    new ContactModel()
    {
        ContactID = new ContactID("AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD"),        // ContactID (Required)
        Attention = "Person Attention",
        Title = "Mr",
        Company = "TNZ Group LTD.",
        CompanyDepartment = "",
        FirstName = "Person first name",
        LastName = "Person last name",
        Position = "",
        StreetAddress = "123 ABC st.",
        Suburb = "My Suburb",
        City = "Auckland",
        State = "",
        Country = "New Zealand",
        Postcode = "1234",
        MainPhone = "092223333",
        AltPhone1 = "",
        AltPhone2 = "",
        DirectPhone = "",
        MobilePhone = "0211144489",
        FaxNumber = "093334444",
        EmailAddress = "person1@example.com",
        WebAddress = "",
        Custom1 = "",
        Custom2 = "",
        Custom3 = "",
        Custom4 = "",
        ViewBy = Enums.ViewEditByOptions.Account,
        EditBy = Enums.ViewEditByOptions.No
    }
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

Parameter Example Value Description
AuthToken eyJhbGciOiJI...adQssw5c Auth Token value set up in Create a new API Auth token
ContactModel ContactModel object Specifies ContactModel object to update - ContactModel.ID required

client.Addressbook.Contact.Update() Parameters

Option Structure Description
Update(
  ContactModel
)
ContactApiResult Update(
    ContactModel entity
)                     
Update contact using ContactModel object.

Usage:
client.Addressbook.Contact.Update(
  new ContactModel(){...}
);


Returns ContactApiResult.
Update(parameters)
ContactApiResult Update(
    string contactID = null,
    string attention = null,
    string title = null,
    string company = null,
    string companyDepartment = null,
    string firstName = null,
    string lastName = null,
    string position = null,
    string streetAddress = null,
    string suburb = null,
    string city = null,
    string state = null,
    string country = null,
    string postcode = null,
    string mainPhone = null,
    string altPhone1 = null,
    string altPhone2 = null,
    string directPhone = null,
    string mobilePhone = null,
    string faxNumber = null,
    string emailAddress = null,
    string webAddress = null,
    string custom1 = null,
    string custom2 = null,
    string custom3 = null,
    string custom4 = null,
    Enums.ViewEditByOptions? viewBy = null,
    Enums.ViewEditByOptions? editBy = null
)             
Update contact using optional parameters.

Usage:
client.Addressbook.Contact.Update(
  contactID: "AAAA...DDD", // required
  attention: "Test Person",
  firstName: "Test",
  lastName: "Person",
  mobilePhone: "+6421000001"
);


Returns ContactApiResult.
UpdateAsync(
  ContactModel
)
Task<ContactApiResult> UpdateAsync(
    ContactModel entity
)                     
Update contact using ContactModel object.

Usage:
await client.Addressbook.Contact.UpdateAsync(
  new ContactModel(){...}
);


Returns Task<ContactApiResult>.
UpdateAsync(parameters)
Task<ContactApiResult> UpdateAsync(
    string contactID = null,
    string attention = null,
    string title = null,
    string company = null,
    string companyDepartment = null,
    string firstName = null,
    string lastName = null,
    string position = null,
    string streetAddress = null,
    string suburb = null,
    string city = null,
    string state = null,
    string country = null,
    string postcode = null,
    string mainPhone = null,
    string altPhone1 = null,
    string altPhone2 = null,
    string directPhone = null,
    string mobilePhone = null,
    string faxNumber = null,
    string emailAddress = null,
    string webAddress = null,
    string custom1 = null,
    string custom2 = null,
    string custom3 = null,
    string custom4 = null,
    Enums.ViewEditByOptions? viewBy = null,
    Enums.ViewEditByOptions? editBy = null
)             
Update contact using optional parameters.

Usage:
await client.Addressbook.Contact.UpdateAsync(
  contactID: "AAAA...DDD", //required
  attention: "Test Person",
  firstName: "Test",
  lastName: "Person",
  mobilePhone: "+6421000001"
);


Returns Task<ContactApiResult>.

Builder Class - ContactBuilder()

Method Usage Description
SetAttention() SetAttention(string attention) Sets the attention or focus associated with the contact.
SetTitle() SetTitle(string title) Sets the title or honorific of the contact (e.g., Mr, Mrs, Ms).
SetCompany() SetCompany(string company) Sets the company or organization associated with the contact.
SetCompanyDepartment() SetCompanyDepartment(string department) Sets the department or division within the company associated with the contact.
SetFirstName() SetFirstName(string firstName) Sets the first name of the contact.
SetLastName() SetLastName(string lastName) Sets the last name of the contact.
SetPosition() SetPosition(string position) Sets the job position or role of the contact.
SetStreetAddress() SetStreetAddress(string streetAddress) Sets the street address or location of the contact.
SetSuburb() SetSuburb(string suburb) Sets the suburb or district associated with the contact's address.
SetCity() SetCity(string city) Sets the city or locality associated with the contact's address.
SetState() SetState(string state) Sets the state or province associated with the contact's address.
SetCountry() SetCountry(string country) Sets the country associated with the contact's address.
SetPostCode() SetPostCode(string postCode) Sets the postal code or ZIP code associated with the contact's address.
SetMainPhone() SetMainPhone(string mainPhone) Sets the main phone number of the contact.
SetAltPhone1() SetAltPhone1(string altPhone1) Sets the alternate phone number 1 for the contact.
SetAltPhone2() SetAltPhone2(string altPhone2) Sets the alternate phone number 2 for the contact.
SetDirectPhone() SetDirectPhone(string ddiNumber) Sets the direct phone number of the contact.
SetMobilePhone() SetMobilePhone(string mobilePhone) Sets the mobile phone number of the contact.
SetFaxNumber() SetFaxNumber(string faxNumber) Sets the fax number associated with the contact.
SetEmailAddress() SetEmailAddress(string emailAddress) Sets the email address of the contact.
SetWebAddress() SetWebAddress(string webAddress) Sets the website address or URL associated with the contact.
SetCustom1() SetCustom1(string custom1) Sets the custom field 1 or additional information associated with the contact.
SetCustom2() SetCustom2(string custom2) Sets the custom field 2 or additional information associated with the contact.
SetCustom3() SetCustom3(string custom3) Sets the custom field 3 or additional information associated with the contact.
SetCustom4() SetCustom4(string custom4) Sets the custom field 4 or additional information associated with the contact.
SetViewBy() SetViewBy(Enums.ViewEditByOptions viewBy) Sets the visibility of the contact.
SetEditBy() SetEditBy(Enums.ViewEditByOptions editBy) Sets the permission level required to edit the contact.
Set<T>() Set<T>(Expression<Func<T, object>> propertyExpression, object value) Sets a property of the contact using an expression.
Build() Build() Builds the ContactModel object based on the configured properties.
BuildAsync() BuildAsync() Asynchronously builds the ContactModel object based on the configured properties.

ContactApiResult object properties

Property Type Example Value Description
Result ResultCode ResultCode.Success Result of your API call (not the result of the message)
Contact ContactModel ContactModel object Contact detail
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

Delete Contact - Delete Contact via .NET

 

Delete Contact (Basic):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.Contact.Delete(new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD"));

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Delete Contact (Simple):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.Contact.Delete(new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD"));

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Delete Contact (Builder):


using TNZAPI.NET.Api.Addressbook.Contact;
using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var contact = new ContactBuilder(new ContactID("AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD"))
                .Build();

var response = client.Addressbook.Contact.Delete(contact);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Delete Contact (Advanced):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.Contact.Delete(
    new ContactModel()
    {
        ContactID = new ContactID("AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD")
    }
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

Parameter Example Value Description
AuthToken eyJhbGciOiJI...adQssw5c Auth Token value set up in Create a new API Auth token
ContactModel ContactModel object Specifies ContactModel object to delete - ContactModel.ID required

client.Addressbook.Contact.Delete() Parameters

Option Structure Description
Delete(
  ContactModel
)
ContactApiResult Delete(
    ContactModel entity
)                     
Delete contact using ContactModel object.

Usage:
client.Addressbook.Contact.Delete(
  new ContactModel(){...}
);


Returns ContactApiResult.
DeleteById(ContactID)
ContactApiResult DeleteById(
    string contactID
)             
Delete contact using contact id.

Usage:
client.Addressbook.Contact.DeleteById(
  "AAAA...DDD" // required
);


Returns ContactApiResult.
DeleteAsync(
  ContactModel
)
Task<ContactApiResult> DeleteAsync(
    ContactModel entity
)                     
Delete contact using ContactModel object.

Usage:
await client.Addressbook.Contact.DeleteAsync(
  new ContactModel(){...}
);


Returns Task<ContactApiResult>.
DeleteByIdAsync(ContactID)
Task<ContactApiResult> DeleteByIdAsync(
    string contactID
)             
Delete contact using contact id.

Usage:
await client.Addressbook.Contact.DeleteByIdAsync(
  "AAAA...DDD" //required
);


Returns Task<ContactApiResult>.

ContactApiResult object properties

Property Type Example Value Description
Result ResultCode ResultCode.Success Result of your API call (not the result of the message)
Contact ContactModel ContactModel object Contact detail
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

List Contact Group - List Contact Group via .NET

 

List Contact Group (Basic):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var contactID = new ContactID("AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Addressbook.ContactGroupList.List(
    contactID,              // ContactID
    page: 1                 // Page number
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact list details");
    Console.WriteLine($"    -> Contact ID: {response.Contact.ContactID}");
    Console.WriteLine($"    -> Total Records: {response.TotalRecords}");
    Console.WriteLine($"    -> Records Per Page: {response.RecordsPerPage}");
    Console.WriteLine($"    -> Page Count: {response.PageCount}");
    Console.WriteLine($"    -> Page: {response.Page}");

    if (response.Groups is not null)
    {
        foreach (var group in response.Groups)
        {
            Console.WriteLine($"Group details for GroupCode={group.GroupCode}");
            Console.WriteLine($"    -> GroupCode: '{group.GroupCode}'");
            Console.WriteLine($"    -> GroupName: '{group.GroupName}'");
            Console.WriteLine($"    -> SubAccount: '{group.SubAccount}'");
            Console.WriteLine($"    -> Department: '{group.Department}'");
            Console.WriteLine($"    -> ViewEditBy: '{group.ViewEditBy}'");
            Console.WriteLine($"    -> Owner: '{group.Owner}'");
            Console.WriteLine($"-------------------------");
        }
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

List Contact Group (Simple):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var contactID = new ContactID("AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Addressbook.ContactGroupList.List(
    contactID,              // ContactID
    page: 1                 // Page number
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact list details");
    Console.WriteLine($"    -> Contact ID: {response.Contact.ContactID}");
    Console.WriteLine($"    -> Total Records: {response.TotalRecords}");
    Console.WriteLine($"    -> Records Per Page: {response.RecordsPerPage}");
    Console.WriteLine($"    -> Page Count: {response.PageCount}");
    Console.WriteLine($"    -> Page: {response.Page}");

    if (response.Groups is not null)
    {
        foreach (var group in response.Groups)
        {
            Console.WriteLine($"Group details for GroupCode={group.GroupCode}");
            Console.WriteLine($"    -> GroupCode: '{group.GroupCode}'");
            Console.WriteLine($"    -> GroupName: '{group.GroupName}'");
            Console.WriteLine($"    -> SubAccount: '{group.SubAccount}'");
            Console.WriteLine($"    -> Department: '{group.Department}'");
            Console.WriteLine($"    -> ViewEditBy: '{group.ViewEditBy}'");
            Console.WriteLine($"    -> Owner: '{group.Owner}'");
            Console.WriteLine($"-------------------------");
        }
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

List Contact Group (Builder):


using TNZAPI.NET.Api.Addressbook.Contact;
using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;
using TNZAPI.NET.Core.Builders;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var contact = new ContactBuilder(new ContactID("AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD"))
                .Build();

var listOptions = new ListRequestOptionBuilder()
                    .SetRecordsPerPage(100)
                    .SetPage(1)
                    .Build();

var response = client.Addressbook.ContactGroupList.List(
    contact,            // Contact
    listOptions         // ListRequestOptions
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact list details");
    Console.WriteLine($"    -> Contact ID: {response.Contact.ContactID}");
    Console.WriteLine($"    -> Total Records: {response.TotalRecords}");
    Console.WriteLine($"    -> Records Per Page: {response.RecordsPerPage}");
    Console.WriteLine($"    -> Page Count: {response.PageCount}");
    Console.WriteLine($"    -> Page: {response.Page}");

    if (response.Groups is not null)
    {
        foreach (var group in response.Groups)
        {
            Console.WriteLine($"Group details for GroupCode={group.GroupCode}");
            Console.WriteLine($"    -> GroupCode: '{group.GroupCode}'");
            Console.WriteLine($"    -> GroupName: '{group.GroupName}'");
            Console.WriteLine($"    -> SubAccount: '{group.SubAccount}'");
            Console.WriteLine($"    -> Department: '{group.Department}'");
            Console.WriteLine($"    -> ViewEditBy: '{group.ViewEditBy}'");
            Console.WriteLine($"    -> Owner: '{group.Owner}'");
            Console.WriteLine($"-------------------------");
        }
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

List Contact Group (Advanced):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Core;
using TNZAPI.NET.Core.Common;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.ContactGroupList.List(
    new ContactModel()              // ContactModel
    {
        ContactID = new ContactID("AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD")
    },
    new ListRequestOptions()
    {
        RecordsPerPage = 10,        // Record per page
        Page = 1                    // Page number
    }
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact list details");
    Console.WriteLine($"    -> Contact ID: {response.Contact.ContactID}");
    Console.WriteLine($"    -> Total Records: {response.TotalRecords}");
    Console.WriteLine($"    -> Records Per Page: {response.RecordsPerPage}");
    Console.WriteLine($"    -> Page Count: {response.PageCount}");
    Console.WriteLine($"    -> Page: {response.Page}");

    if (response.Groups is not null)
    {
        foreach (var group in response.Groups)
        {
            Console.WriteLine($"Group details for GroupCode={group.GroupCode}");
            Console.WriteLine($"    -> GroupCode: '{group.GroupCode}'");
            Console.WriteLine($"    -> GroupName: '{group.GroupName}'");
            Console.WriteLine($"    -> SubAccount: '{group.SubAccount}'");
            Console.WriteLine($"    -> Department: '{group.Department}'");
            Console.WriteLine($"    -> ViewEditBy: '{group.ViewEditBy}'");
            Console.WriteLine($"    -> Owner: '{group.Owner}'");
            Console.WriteLine($"-------------------------");
        }
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

Parameter Example Value Description
AuthToken eyJhbGciOiJI...adQssw5c Auth Token value set up in Create a new API Auth token
ContactModel ContactModel object Specifies the ContactModel object with ID of the contact to retrieve. (required)

client.Addressbook.ContactGroupList.List() Parameters

Option Structure Description
List(
  ContactModel
)
ContactGroupListApiResult List(
    ContactModel entity, 
    int? recordsPerPage = null, 
    int? page = null
)                     
Get contact detail using ContactModel object.

Usage:
client.Addressbook.ContactGroupList.List(
  new ContactModel(){...}, //required
  page: 1 //optional
);


Returns ContactGroupListApiResult.
List(
  ContactModel
  ListRequestOptions
)
ContactGroupListApiResult List(
    ContactModel entity, 
    IListRequestOptions options
)                     
Get contact detail using ContactModel & ListRequestOptions object.

Usage:
client.Addressbook.ContactGroupList.List(
  new ContactModel(){...}, //required
  new ListRequestOptions() {...}
);


Returns ContactGroupListApiResult.
ListById(ContactID)
ContactGroupListApiResult ListById(
    string ContactID, 
    int? recordsPerPage = null, 
    int? page = null
)             
Get contact detail using contact id.

Usage:
client.Addressbook.ContactGroupList.ListById(
  [ContactID], //required
  page: 1 //optional
);


Returns ContactGroupListApiResult.
ListById(
  ContactID
  ListRequestOptions
)
ContactGroupListApiResult ListById(
    string ContactID, 
    IListRequestOptions options
)                     
Get contact detail using ContactID & ListRequestOptions object.

Usage:
client.Addressbook.ContactGroupList.ListById(
  [ContactID], //required
  new ListRequestOptions() {...}
);


Returns ContactGroupListApiResult.
ListAsync(
  ContactModel
)
Task<ContactGroupListApiResult> ListAsync(
    ContactModel entity, 
    int? recordsPerPage = null, 
    int? page = null
)                     
Get contact detail using ContactModel object.

Usage:
await client.Addressbook.ContactGroupList.ListAsync(
  new ContactModel(){...}, //required
  page: 1 //optional
);


Returns Task<ContactGroupListApiResult>.
ListAsync(
  ContactModel
  ListRequestOptions
)
Task<ContactGroupListApiResult> ListAsync(
    ContactModel entity, 
    IListRequestOptions options
)                     
Get contact detail using ContactModel & ListRequestOptions object.

Usage:
await client.Addressbook.ContactGroupList.ListAsync(
  new ContactModel(){...}, //required
  new ListRequestOptions() {...}
);


Returns Task<ContactGroupListApiResult>.
ListByIdAsync(ContactID)
Task<ContactGroupListApiResult> ListByIdAsync(
    string ContactID, 
    int? recordsPerPage = null, 
    int? page = null
)             
Get contact detail using contact id.

Usage:
await client.Addressbook.ContactGroupList.ListByIdAsync(
  [ContactID], //required
  page: 1 //optional
);


Returns Task<ContactGroupListApiResult>.
ListByIdAsync(
  ContactID
  ListRequestOptions
)
Task<ContactGroupListApiResult> ListByIdAsync(
    string ContactID, 
    IListRequestOptions options
)                     
Get contact detail using ContactID & ListRequestOptions object.

Usage:
await client.Addressbook.ContactGroupList.ListByIdAsync(
  [ContactID], //required
  new ListRequestOptions() {...}
);


Returns Task<ContactGroupListApiResult>.

IListRequestOptions properties

Property Type Example Value Description
RecordsPerPage int 100 Number of records per API request to be returned.
Page int 1 Current location of data set.

ContactGroupListApiResult object properties

Property Type Example Value Description
Result ResultCode ResultCode.Success Result of your API call (not the result of the message)
TotalRecords int 3 Total number of groups associated with this contact
RecordsPerPage int 100 Return x number of records per request (optional)
PageCount int 1 Maximum number of pages
Page int 1 Current location of the result set (optional)
Contact ContactModel ContactModel object Contact detail
Groups List<GroupModel> GroupModel list List of groups associated with this contact
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

Create Contact Group - Create Contact Group via .NET

 

Create Contact Group (Basic):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");      // ContactID
var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");          // GroupID

var response = client.Addressbook.ContactGroup.Add(contactID, groupID);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");

    if (response.Group is not null)
    {
        Console.WriteLine($"Group details for GroupCode={response.Group.GroupID}");
        Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{response.Group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Create Contact Group (Simple):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.ContactGroup.Add(
    contactID: new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD"),       // ContactID
    groupID: new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD")            // GroupID
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");

    if (response.Group is not null)
    {
        Console.WriteLine($"Group details for GroupCode={response.Group.GroupID}");
        Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{response.Group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Create Contact Group (Builder):


using TNZAPI.NET.Api.Addressbook.Contact;
using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Addressbook.Group;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var contact = new ContactBuilder(new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD"))
                .Build();

var group = new GroupBuilder(new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD"))
                .Build();

var response = client.Addressbook.ContactGroup.Add(
    contact: contact,
    group: group
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");

    if (response.Group is not null)
    {
        Console.WriteLine($"Group details for GroupCode={response.Group.GroupID}");
        Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{response.Group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Create Contact Group (Advanced):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.ContactGroup.Add(
                contact: new ContactModel()                                                 // ContactModel
                {
                    ContactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD")       // ContactID
                },
                group: new GroupModel()                                                     // GroupModel
                {
                    GroupCode = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD")         // GroupID
                }
            );

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");

    if (response.Group is not null)
    {
        Console.WriteLine($"Group details for GroupCode={response.Group.GroupID}");
        Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{response.Group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

Parameter Example Value Description
AuthToken eyJhbGciOiJI...adQssw5c Auth Token value set up in Create a new API Auth token
ContactModel ContactModel object Specifies ContactModel object to create
GroupModel GroupModel object Specifies GroupModel object to create

client.Addressbook.ContactGroup.Add() Parameters

Option Structure Description
Add(
  ContactModel,
  GroupModel
)
ContactGroupApiResult Add(
    ContactModel contact,
    GroupModel group
)                     
Creates contact group using ContactModel & GroupModel objects.

Usage:
client.Addressbook.ContactGroup.Add(
  new ContactModel(){...},
  new GroupModel(){...}
);


Returns ContactGroupApiResult.
Add(
  ContactID,
  GroupCode
)
ContactGroupApiResult Add(
    string contactID,
    string groupCode
)             
Creates contact group using ids.

Usage:
client.Addressbook.ContactGroup.Add(
  [ContactID],
  [GroupCode]
);


Returns ContactGroupApiResult.
AddAsync(
  ContactModel,
  GroupModel
)
Task<ContactGroupApiResult> AddAsync(
    ContactModel contact,
    GroupModel group
)                     
Creates contact group using ContactModel & GroupModel objects.

Usage:
await client.Addressbook.ContactGroup.AddAsync(
  new ContactModel(){...},
  new GroupModel(){...}
);


Returns Task<ContactGroupApiResult>.
AddAsync(
  ContactID,
  GroupCode
)
Task<ContactGroupApiResult> AddAsync(
    string contactID,
    string groupCode
)             
Creates contact group using ids.

Usage:
await client.Addressbook.ContactGroup.AddAsync(
  [ContactID],
  [GroupCode]
);


Returns Task<ContactGroupApiResult>.

ContactGroupApiResult object properties

Property Type Example Value Description
Result ResultCode ResultCode.Success Result of your API call (not the result of the message)
Contact ContactModel ContactModel object Contact detail
Group GroupModel GroupModel object Group detail
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

Delete Contact Group - Delete Contact Group via .NET

 

Delete Contact Group (Basic):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");      // ContactID
var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");          // GroupID

var response = client.Addressbook.ContactGroup.Remove(
    contactID,
    groupID
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");

    if (response.Group is not null)
    {
        Console.WriteLine($"Group details for GroupCode={response.Group.GroupID}");
        Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{response.Group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Delete Contact Group (Simple):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.ContactGroup.Remove(
    contactID: new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD"),   // ContactID
    groupID: new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD")        // GroupID
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");

    if (response.Group is not null)
    {
        Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
        Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{response.Group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Delete Contact Group (Builder):


using TNZAPI.NET.Api.Addressbook.Contact;
using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Addressbook.Group;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var contact = new ContactBuilder(new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD"))
                .Build();

var group = new GroupBuilder(new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD"))
                .Build();

var response = client.Addressbook.ContactGroup.Remove(
    contact: contact,
    group: group
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");

    if (response.Group is not null)
    {
        Console.WriteLine($"Group details for GroupCode={response.Group.GroupCode}");
        Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{response.Group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Delete Contact Group (Advanced):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.ContactGroup.Remove(
    contact: new ContactModel()
    {
        ContactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD")
    },
    group: new GroupModel()
    {
        GroupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD")
    }
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
    Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
    Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
    Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
    Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
    Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
    Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
    Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
    Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
    Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
    Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
    Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
    Console.WriteLine($"    -> City: '{response.Contact.City}'");
    Console.WriteLine($"    -> State: '{response.Contact.State}'");
    Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
    Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
    Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
    Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
    Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
    Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
    Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
    Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
    Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
    Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
    Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
    Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
    Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
    Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
    Console.WriteLine($"-------------------------");

    if (response.Group is not null)
    {
        Console.WriteLine($"Group details for GroupCode={response.Group.GroupCode}");
        Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{response.Group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

Parameter Example Value Description
AuthToken eyJhbGciOiJI...adQssw5c Auth Token value set up in Create a new API Auth token
ContactModel ContactModel object Specifies ContactModel object to delete
GroupModel GroupModel object Specifies GroupModel object to delete

client.Addressbook.ContactGroup.Remove() Parameters

Option Structure Description
Remove(
  ContactModel,
  GroupModel
)
ContactGroupApiResult Remove(
    ContactModel contact,
    GroupModel group
)                     
Delete contact group using ContactModel & GroupModel objects.

Usage:
client.Addressbook.ContactGroup.Remove(
  new ContactModel(){...},
  new GroupModel(){...}
);


Returns ContactGroupApiResult.
Remove(
  ContactID,
  GroupCode
)
ContactGroupApiResult Remove(
    string contactID,
    string groupCode
)             
Delete contact group using ids.

Usage:
client.Addressbook.ContactGroup.Remove(
  [ContactID],
  [GroupCode]
);


Returns ContactGroupApiResult.
RemoveAsync(
  ContactModel,
  GroupModel
)
Task<ContactGroupApiResult> RemoveAsync(
    ContactModel contact,
    GroupModel group
)                     
Delete contact group using ContactModel & GroupModel objects.

Usage:
await client.Addressbook.ContactGroup.RemoveAsync(
  new ContactModel(){...},
  new GroupModel(){...}
);


Returns Task<ContactGroupApiResult>.
RemoveAsync(
  ContactID,
  GroupCode
)
Task<ContactGroupApiResult> RemoveAsync(
    string contactID,
    string groupCode
)             
Delete contact group using ids.

Usage:
await client.Addressbook.ContactGroup.RemoveAsync(
  [ContactID],
  [GroupCode]
);


Returns Task<ContactGroupApiResult>.

ContactGroupApiResult object properties

Property Type Example Value Description
Result ResultCode ResultCode.Success Result of your API call (not the result of the message)
Contact ContactModel ContactModel object Contact detail
Group GroupModel GroupModel object Group detail
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

List Group - List Group via .NET

 

List Group (Basic):


using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.GroupList.List(
    page: 1                 // Page number
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact list details");
    Console.WriteLine($"    -> Total Records: {response.TotalRecords}");
    Console.WriteLine($"    -> Records Per Page: {response.RecordsPerPage}");
    Console.WriteLine($"    -> Page Count: {response.PageCount}");
    Console.WriteLine($"    -> Page: {response.Page}");

    foreach (var group in response.Groups)
    {
        Console.WriteLine($"Group details for GroupID={group.GroupID}");
        Console.WriteLine($"    -> GroupCode: '{group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

List Group (Simple):


using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.GroupList.List(
    recordsPerPage: 10,     // Record per page
    page: 1                 // Page number
    );

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact list details");
    Console.WriteLine($"    -> Total Records: {response.TotalRecords}");
    Console.WriteLine($"    -> Records Per Page: {response.RecordsPerPage}");
    Console.WriteLine($"    -> Page Count: {response.PageCount}");
    Console.WriteLine($"    -> Page: {response.Page}");

    foreach (var group in response.Groups)
    {
        Console.WriteLine($"Group details for GroupID={group.GroupID}");
        Console.WriteLine($"    -> GroupCode: '{group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

List Group (Builder):


using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;
using TNZAPI.NET.Core.Builders;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var listOptions = new ListRequestOptionBuilder<GroupListRequestOptions>()
    .SetRecordsPerPage(100)         // Number of records for this request
    .SetPage(1)                     // Current location
    .Build();

var response = client.Addressbook.GroupList.List(listOptions);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact list details");
    Console.WriteLine($"    -> Total Records: {response.TotalRecords}");
    Console.WriteLine($"    -> Records Per Page: {response.RecordsPerPage}");
    Console.WriteLine($"    -> Page Count: {response.PageCount}");
    Console.WriteLine($"    -> Page: {response.Page}");

    foreach (var group in response.Groups)
    {
        Console.WriteLine($"Group details for GroupID={group.GroupID}");
        Console.WriteLine($"    -> GroupCode: '{group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

List Group (Advanced):


using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;
using TNZAPI.NET.Core.Builders;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.GroupList.List(
     new GroupListRequestOptions()
     {
         RecordsPerPage = 10,    // Record per page
         Page = 1                // Page number
     }
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Contact list details");
    Console.WriteLine($"    -> Total Records: {response.TotalRecords}");
    Console.WriteLine($"    -> Records Per Page: {response.RecordsPerPage}");
    Console.WriteLine($"    -> Page Count: {response.PageCount}");
    Console.WriteLine($"    -> Page: {response.Page}");

    foreach (var group in response.Groups)
    {
        Console.WriteLine($"Group details for GroupID={group.GroupID}");
        Console.WriteLine($"    -> GroupCode: '{group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

Parameter Example Value Description
AuthToken eyJhbGciOiJI...adQssw5c Auth Token value set up in Create a new API Auth token

Optional parameters

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

client.Addressbook.GroupList.List() Parameters

Option Structure Description
List(
  ListRequestOptions
)
GroupListApiResult List(
    IListRequestOptions options
)                     
Get group list using ListRequestOptions object.

Usage:
client.Addressbook.GroupList.List(
  new ListRequestOptions(){...}
);


Returns GroupListApiResult.
List(parameters)
GroupListApiResult List(
    int? recordsPerPage = null, 
    int? page = null
)             
Get group list using optional parameters.

Usage:
client.Addressbook.GroupList.List(
  page:[Page number]
);


Returns GroupListApiResult.
ListAsync(
  ListRequestOptions
)
Task<GroupListApiResult> ListAsync(
    IListRequestOptions options
)                     
Get group list using ListRequestOptions object.

Usage:
await client.Addressbook.GroupList.ListAsync(
  new ListRequestOptions(){...}
);


Returns Task<GroupListApiResult>.
ListAsync(parameters)
Task<GroupListApiResult> ListAsync(
    int? recordsPerPage = null, 
    int? page = null
)             
Get group list using optional parameters.

Usage:
await client.Addressbook.GroupList.ListAsync(
  page:[Page number]
);


Returns Task<GroupListApiResult>.

IListRequestOptions properties

Property Type Example Value Description
RecordsPerPage int 100 Number of records per API request to be returned.
Page int 1 Current location of data set.

Builder Class - ListRequestOptionBuilder<T>()

Function Usage Description
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 ListRequestOption<T>() object and return T
[Required]
BuildAsync() BuildAsync() Builds the ListRequestOption<T>() object asynchronous and return Task<T>

GroupListApiResult object properties

Property Type Example Value Description
Result ResultCode ResultCode.Success Result of your API call (not the result of the message)
TotalRecords int 3 Total number of records
RecordsPerPage int 100 Return x number of records per request (optional)
PageCount int 1 Maximum number of pages
Page int 1 Current location of the result set (optional)
Groups List<GroupModel> GroupModel List of group
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

Group Detail - Group Detail via .NET

 

Group Detail (Basic):


using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Addressbook.Group.Get(groupID);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
    Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
    Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
    Console.WriteLine($"    -> Department: '{response.Group.Department}'");
    Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
    Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Group Detail (Simple):


using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Addressbook.Group.Get(groupID);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
    Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
    Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
    Console.WriteLine($"    -> Department: '{response.Group.Department}'");
    Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
    Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Group Detail (Builder):


using TNZAPI.NET.Api.Addressbook.Group;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var group = new GroupBuilder(new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD"))
                .Build();

var response = client.Addressbook.Group.Get(group);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
    Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
    Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
    Console.WriteLine($"    -> Department: '{response.Group.Department}'");
    Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
    Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Group Detail (Advanced):


using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.Group.Get(
    new GroupModel()
    {
        GroupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD")
    }
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
    Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
    Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
    Console.WriteLine($"    -> Department: '{response.Group.Department}'");
    Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
    Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

Parameter Example Value Description
AuthToken eyJhbGciOiJI...adQssw5c Auth Token value set up in Create a new API Auth token
GroupModel GroupModel object Specifies the GroupModel object with GroupCode of the group to retrieve. (required)
GroupCode Test-Group Specifies the unique identifier of the group to retrieve.

client.Addressbook.Group.Read() Parameters

Option Structure Description
Read(
  GroupModel
)
GroupApiResult Read(
    GroupModel group
)                     
Get group detail using GroupModel object.

Usage:
client.Addressbook.Group.Read(
  new GroupModel(){...}
);


Returns GroupApiResult.
ReadByGroupCode(GroupCode)
GroupApiResult ReadByGroupCode(
    string groupCode
)             
Get group detail using group code.

Usage:
client.Addressbook.Group.ReadByGroupCode(
  [GroupCode]
);


Returns GroupApiResult.
ReadAsync(
  GroupModel
)
Task<GroupApiResult> ReadAsync(
    GroupModel group
)                     
Get group detail GroupModel object.

Usage:
await client.Addressbook.Group.ReadAsync(
  new GroupModel(){...}
);


Returns Task<GroupApiResult>.
ReadByGroupCodeAsync(GroupCode)
Task<GroupApiResult> ReadByGroupCodeAsync(
    string groupCode
)             
Get group detail using group code.

Usage:
await client.Addressbook.Group.ReadByGroupCodeAsync(
  [GroupCode]
);


Returns Task<GroupApiResult>.

GroupApiResult object properties

Property Type Example Value Description
Result ResultCode ResultCode.Success Result of your API call (not the result of the message)
Group GroupModel GroupModel object Group detail
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

GroupModel object properties

Property Type Example Value Description
GroupCode string Test-Group Unique identifier for the group
GroupName string Test Group Represents the name of the group.
SubAccount string SubAccount01 Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section.
Department string Department01 Used for reporting, billing and Web Dashboard segmentation. See the TNZ API Structure guide's Cost Tracking & Rebilling section.
ViewEditBy ViewEditByOptions ViewEditByOptions.Account Specifies the permission level required to view/edit the group. Values can be "Account", "SubAccount", "Department" or "No" permission option.
Owner string COM\EXAMPLE\TEST Your UserKey

Create Group - Create Group via .NET

 

Create Group (Basic):


using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.Group.Create(
    groupName: "Test Group"
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
    Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
    Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
    Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
    Console.WriteLine($"    -> Department: '{response.Group.Department}'");
    Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
    Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Create Group (Simple):


using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.Group.Create(
    groupCode: "Test-Group",
    groupName: "Test Group",
    subAccount: "Test SubAccount",
    department: "Test Department",
    viewEditBy: Enums.ViewEditByOptions.Account
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
    Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
    Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
    Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
    Console.WriteLine($"    -> Department: '{response.Group.Department}'");
    Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
    Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Create Group (Builder):


using TNZAPI.NET.Api.Addressbook.Group;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var group = new GroupBuilder("Test-Group")
                .SetGroupName("Test Group")
                .SetSubAccount("Test SubAccount")
                .SetDepartment("Test Department")
                .SetViewEditBy(Enums.ViewEditByOptions.Account)
                .Build();


var response = client.Addressbook.Group.Create(group);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
    Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
    Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
    Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
    Console.WriteLine($"    -> Department: '{response.Group.Department}'");
    Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
    Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Create Group (Advanced):


using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.Group.Create(new GroupModel()
{
    GroupCode = "Test-Group",
    GroupName = "Test Group",
    SubAccount = "Test SubAccount",
    Department = "Test Department",
    ViewEditBy = Enums.ViewEditByOptions.Account
});

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
    Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
    Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
    Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
    Console.WriteLine($"    -> Department: '{response.Group.Department}'");
    Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
    Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

Parameter Example Value Description
AuthToken eyJhbGciOiJI...adQssw5c Auth Token value set up in Create a new API Auth token
GroupModel GroupModel object Specifies GroupModel object to create

client.Addressbook.Group.Create() Parameters

Option Structure Description
Create(
  GroupModel
)
GroupApiResult Create(
    GroupModel entity
)                     
Creates group using GroupModel object.

Usage:
client.Addressbook.Group.Create(
  new GroupModel(){...}
);


Returns GroupApiResult.
Create(parameters)
GroupApiResult Create(
    string groupCode = null, 
    string groupName = null, 
    string subAccount = null, 
    string department = null,
    Enums.ViewEditByOptions? 
      viewEditBy = null
)             
Creates group using optional parameters.

Usage:
client.Addressbook.Group.Create(
  groupName: "Test Group",
  viewEditBy: Enums.ViewEditByOptions.Account
);


Returns GroupApiResult.
CreateAsync(
  GroupModel
)
Task<GroupApiResult> CreateAsync(
    GroupModel entity
)                     
Creates group using GroupModel object.

Usage:
await client.Addressbook.Group.CreateAsync(
  new GroupModel(){...}
);


Returns Task<GroupApiResult>.
CreateAsync(parameters)
Task<GroupApiResult> CreateAsync(
    string groupCode = null, 
    string groupName = null, 
    string subAccount = null, 
    string department = null,
    Enums.ViewEditByOptions?
      viewEditBy = null
)             
Creates group using optional parameters.

Usage:
await client.Addressbook.Group.CreateAsync(
  groupName: "Test Group",
  viewEditBy: Enums.ViewEditByOptions.Account
);


Returns Task<GroupApiResult>.

Builder Class - GroupBuilder()

Method Usage Description
SetGroupName() SetGroupName(string groupName) Sets the group name of the group.
SetSubAccount() SetSubAccount(string subAccount) Sets the subaccount of the group.
SetDepartment() SetDepartment(string subAccount) Sets the department of the group.
SetViewEditBy() SetViewEditBy(Enums.ViewEditByOptions viewEditBy) Sets the permission level required to view/edit the group.
Set<T>() Set<T>(Expression<Func<T, object>> propertyExpression, object value) Sets a property of the group using an expression.
Build() Build() Builds the ContactModel object based on the configured properties.
BuildAsync() BuildAsync() Asynchronously builds the ContactModel object based on the configured properties.

GroupApiResult object properties

Property Type Example Value Description
Result ResultCode ResultCode.Success Result of your API call (not the result of the message)
Group GroupModel GroupModel object Group detail
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

Update Group - Update Group via .NET

 

Update Group (Basic):


using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Addressbook.Group.Update(
    groupID: groupID,
    groupName: "Test Group"
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
    Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
    Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
    Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
    Console.WriteLine($"    -> Department: '{response.Group.Department}'");
    Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
    Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Update Group (Simple):


using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Addressbook.Group.Update(
    groupID: groupID,
    groupName: "Test Group",
    subAccount: "Test SubAccount",
    department: "Test Department",
    viewEditBy: Enums.ViewEditByOptions.Account
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
    Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
    Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
    Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
    Console.WriteLine($"    -> Department: '{response.Group.Department}'");
    Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
    Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Update Group (Builder):


using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Api.Addressbook.Group;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var group = new GroupBuilder(new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD"))
            .SetGroupName("Test Group")
            .SetSubAccount("Test SubAccount")
            .SetDepartment("Test Department")
            .SetViewEditBy(Enums.ViewEditByOptions.Account)
            .Build();

var response = client.Addressbook.Group.Update(group);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
    Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
    Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
    Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
    Console.WriteLine($"    -> Department: '{response.Group.Department}'");
    Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
    Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Update Group (Advanced):


using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Addressbook.Group.Update(
    new GroupModel()
    {
        GroupID = groupID,                                  // GroupID (required)
        GroupCode = "Test-Group",                           // Group Code (optional)
        GroupName = "Test Group",                           // Group Name
        SubAccount = "Test SubAccount",                     // SubAccount (optional)
        Department = "Test Department",                     // Department (optional)
        ViewEditBy = Enums.ViewEditByOptions.Account        // Permission (optional), leave blank to use system (your TNZ user record) default
    }
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
    Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
    Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
    Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
    Console.WriteLine($"    -> Department: '{response.Group.Department}'");
    Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
    Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

Parameter Example Value Description
AuthToken eyJhbGciOiJI...adQssw5c Auth Token value set up in Create a new API Auth token
GroupModel GroupModel object Specifies GroupModel object to update - GroupModel.GroupCode required

client.Addressbook.Group.Update() Parameters

Option Structure Description
Update(
  GroupModel
)
GroupApiResult Update(
    GroupModel entity
)                     
Creates group using GroupModel object.

Usage:
client.Addressbook.Group.Update(
  new GroupModel(){...}
);


Returns GroupApiResult.
Update(parameters)
GroupApiResult Update(
    string groupCode = null, 
    string groupName = null, 
    string subAccount = null, 
    string department = null,
    Enums.ViewEditByOptions? 
      viewEditBy = null
)             
Creates group using optional parameters.

Usage:
client.Addressbook.Group.Update(
  groupCode: "Test-Group", //required
  groupName: "Test Group",
  viewEditBy: Enums.ViewEditByOptions.Account
);


Returns GroupApiResult.
UpdateAsync(
  GroupModel
)
Task<GroupApiResult> UpdateAsync(
    GroupModel entity
)                     
Creates group using GroupModel object.

Usage:
await client.Addressbook.Group.UpdateAsync(
  new GroupModel(){...}
);


Returns Task<GroupApiResult>.
UpdateAsync(parameters)
Task<GroupApiResult> UpdateAsync(
    string groupCode = null, 
    string groupName = null, 
    string subAccount = null, 
    string department = null,
    Enums.ViewEditByOptions?
      viewEditBy = null
)             
Creates group using optional parameters.

Usage:
await client.Addressbook.Group.UpdateAsync(
  groupCode: "Test-Group", //required
  groupName: "Test Group",
  viewEditBy: Enums.ViewEditByOptions.Account
);


Returns Task<GroupApiResult>.

Builder Class - GroupBuilder()

Method Usage Description
SetGroupName() SetGroupName(string groupName) Sets the group name of the group.
SetSubAccount() SetSubAccount(string subAccount) Sets the subaccount of the group.
SetDepartment() SetDepartment(string subAccount) Sets the department of the group.
SetViewEditBy() SetViewEditBy(Enums.ViewEditByOptions viewEditBy) Sets the permission level required to view/edit the group.
Set<T>() Set<T>(Expression<Func<T, object>> propertyExpression, object value) Sets a property of the group using an expression.
Build() Build() Builds the ContactModel object based on the configured properties.
BuildAsync() BuildAsync() Asynchronously builds the ContactModel object based on the configured properties.

GroupApiResult object properties

Property Type Example Value Description
Result ResultCode ResultCode.Success Result of your API call (not the result of the message)
Group GroupModel GroupModel object Group detail
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

Delete Group - Delete Group via .NET

 

Delete Group (Basic):


using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Addressbook.Group.Delete(groupID);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
    Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
    Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
    Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
    Console.WriteLine($"    -> Department: '{response.Group.Department}'");
    Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
    Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Delete Group (Simple):


using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Addressbook.Group.Delete(groupID);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
    Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
    Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
    Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
    Console.WriteLine($"    -> Department: '{response.Group.Department}'");
    Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
    Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Delete Group (Builder):


using TNZAPI.NET.Api.Addressbook.Group;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var group = new GroupBuilder(new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD"))
                .Build();

var response = client.Addressbook.Group.Delete(group);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
    Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
    Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
    Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
    Console.WriteLine($"    -> Department: '{response.Group.Department}'");
    Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
    Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Delete Group (Advanced):


using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.Group.Delete(
    new GroupModel()
    {
        GroupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD")
    }
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
    Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
    Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
    Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
    Console.WriteLine($"    -> Department: '{response.Group.Department}'");
    Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
    Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
    Console.WriteLine($"-------------------------");
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

Parameter Example Value Description
AuthToken eyJhbGciOiJI...adQssw5c Auth Token value set up in Create a new API Auth token
GroupModel GroupModel object Specifies GroupModel object to delete - GroupModel.GroupCode required

client.Addressbook.Group.Delete() Parameters

Option Structure Description
Delete(
  GroupModel
)
GroupApiResult Delete(
    GroupModel entity
)                     
Delete group using GroupModel object.

Usage:
client.Addressbook.Group.Delete(
  new GroupModel(){...}
);


Returns GroupApiResult.
DeleteByGroupCode(GroupCode)
GroupApiResult DeleteByGroupCode(
    string groupCode
)             
Delete group using group code.

Usage:
client.Addressbook.Group.DeleteByGroupCode(
  "Test-Group" // required
);


Returns GroupApiResult.
DeleteAsync(
  GroupModel
)
Task<GroupApiResult> DeleteAsync(
    GroupModel entity
)                     
Delete group using GroupModel object.

Usage:
await client.Addressbook.Group.DeleteAsync(
  new GroupModel(){...}
);


Returns Task<GroupApiResult>.
DeleteByGroupCodeAsync(GroupCode)
Task<GroupApiResult> DeleteByGroupCodeAsync(
    string groupCode
)             
Delete group using group code.

Usage:
await client.Addressbook.Group.DeleteByGroupCodeAsync(
  "Test-Group" //required
);


Returns Task<GroupApiResult>.

GroupApiResult object properties

Property Type Example Value Description
Result ResultCode ResultCode.Success Result of your API call (not the result of the message)
Group GroupModel GroupModel object Group detail
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

List Group Contact - List Group Contact via .NET

 

List Group Contact (Basic):


using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Addressbook.GroupContactList.List(
    groupID,                // GroupID
    page: 1                 // Current location
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group Contact list details");
    Console.WriteLine($"    -> GroupID: {response.Group.GroupID}");
    Console.WriteLine($"    -> GroupCode: {response.Group.GroupCode}");
    Console.WriteLine($"    -> Total Records: {response.TotalRecords}");
    Console.WriteLine($"    -> Records Per Page: {response.RecordsPerPage}");
    Console.WriteLine($"    -> Page Count: {response.PageCount}");
    Console.WriteLine($"    -> Page: {response.Page}");

    foreach (var contact in response.Contacts)
    {
        Console.WriteLine($"Contact details for ContactID={contact.ContactID}");
        Console.WriteLine($"    -> Owner: '{contact.Owner}'");
        Console.WriteLine($"    -> Created: '{contact.Created}'");
        Console.WriteLine($"    -> Updated: '{contact.Updated}'");
        Console.WriteLine($"    -> Attention: '{contact.Attention}'");
        Console.WriteLine($"    -> Company: '{contact.Company}'");
        Console.WriteLine($"    -> RecipDepartment: '{contact.CompanyDepartment}'");
        Console.WriteLine($"    -> FirstName: '{contact.FirstName}'");
        Console.WriteLine($"    -> LastName: '{contact.LastName}'");
        Console.WriteLine($"    -> Position: '{contact.Position}'");
        Console.WriteLine($"    -> StreetAddress: '{contact.StreetAddress}'");
        Console.WriteLine($"    -> Suburb: '{contact.Suburb}'");
        Console.WriteLine($"    -> City: '{contact.City}'");
        Console.WriteLine($"    -> State: '{contact.State}'");
        Console.WriteLine($"    -> Country: '{contact.Country}'");
        Console.WriteLine($"    -> Postcode: '{contact.Postcode}'");
        Console.WriteLine($"    -> MainPhone: '{contact.MainPhone}'");
        Console.WriteLine($"    -> AltPhone1: '{contact.AltPhone1}'");
        Console.WriteLine($"    -> AltPhone2: '{contact.AltPhone2}'");
        Console.WriteLine($"    -> DirectPhone: '{contact.DirectPhone}'");
        Console.WriteLine($"    -> MobilePhone: '{contact.MobilePhone}'");
        Console.WriteLine($"    -> FaxNumber: '{contact.FaxNumber}'");
        Console.WriteLine($"    -> EmailAddress: '{contact.EmailAddress}'");
        Console.WriteLine($"    -> WebAddress: '{contact.WebAddress}'");
        Console.WriteLine($"    -> Custom1: '{contact.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{contact.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{contact.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{contact.Custom4}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}
            

Copy code

List Group Contact (Simple):


using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Addressbook.GroupContactList.List(
    groupID,              // Group
    recordsPerPage: 10,     // Number of records for this request
    page: 1                 // Current location
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group Contact list details");
    Console.WriteLine($"    -> GroupID: {response.Group.GroupID}");
    Console.WriteLine($"    -> GroupCode: {response.Group.GroupCode}");
    Console.WriteLine($"    -> Total Records: {response.TotalRecords}");
    Console.WriteLine($"    -> Records Per Page: {response.RecordsPerPage}");
    Console.WriteLine($"    -> Page Count: {response.PageCount}");
    Console.WriteLine($"    -> Page: {response.Page}");

    foreach (var contact in response.Contacts)
    {
        Console.WriteLine($"Contact details for ContactID={contact.ContactID}");
        Console.WriteLine($"    -> Owner: '{contact.Owner}'");
        Console.WriteLine($"    -> Created: '{contact.Created}'");
        Console.WriteLine($"    -> Updated: '{contact.Updated}'");
        Console.WriteLine($"    -> Attention: '{contact.Attention}'");
        Console.WriteLine($"    -> Company: '{contact.Company}'");
        Console.WriteLine($"    -> RecipDepartment: '{contact.CompanyDepartment}'");
        Console.WriteLine($"    -> FirstName: '{contact.FirstName}'");
        Console.WriteLine($"    -> LastName: '{contact.LastName}'");
        Console.WriteLine($"    -> Position: '{contact.Position}'");
        Console.WriteLine($"    -> StreetAddress: '{contact.StreetAddress}'");
        Console.WriteLine($"    -> Suburb: '{contact.Suburb}'");
        Console.WriteLine($"    -> City: '{contact.City}'");
        Console.WriteLine($"    -> State: '{contact.State}'");
        Console.WriteLine($"    -> Country: '{contact.Country}'");
        Console.WriteLine($"    -> Postcode: '{contact.Postcode}'");
        Console.WriteLine($"    -> MainPhone: '{contact.MainPhone}'");
        Console.WriteLine($"    -> AltPhone1: '{contact.AltPhone1}'");
        Console.WriteLine($"    -> AltPhone2: '{contact.AltPhone2}'");
        Console.WriteLine($"    -> DirectPhone: '{contact.DirectPhone}'");
        Console.WriteLine($"    -> MobilePhone: '{contact.MobilePhone}'");
        Console.WriteLine($"    -> FaxNumber: '{contact.FaxNumber}'");
        Console.WriteLine($"    -> EmailAddress: '{contact.EmailAddress}'");
        Console.WriteLine($"    -> WebAddress: '{contact.WebAddress}'");
        Console.WriteLine($"    -> Custom1: '{contact.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{contact.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{contact.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{contact.Custom4}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

List Group Contact (Builder):


using TNZAPI.NET.Api.Addressbook.Group;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;
using TNZAPI.NET.Core.Builders;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var group = new GroupBuilder(new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD"))
                .Build();

var listOptions = new ListRequestOptionBuilder()
    .SetRecordsPerPage(50)          // Number of records for this request
    .SetPage(1)                     // Current location
    .Build();

var response = client.Addressbook.GroupContactList.List(
    group,                      // Group
    listOptions                 // List options
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group Contact list details");
    Console.WriteLine($"    -> GroupID: {response.Group.GroupID}");
    Console.WriteLine($"    -> GroupCode: {response.Group.GroupCode}");
    Console.WriteLine($"    -> Total Records: {response.TotalRecords}");
    Console.WriteLine($"    -> Records Per Page: {response.RecordsPerPage}");
    Console.WriteLine($"    -> Page Count: {response.PageCount}");
    Console.WriteLine($"    -> Page: {response.Page}");

    foreach (var contact in response.Contacts)
    {
        Console.WriteLine($"Contact details for ContactID={contact.ContactID}");
        Console.WriteLine($"    -> Owner: '{contact.Owner}'");
        Console.WriteLine($"    -> Created: '{contact.Created}'");
        Console.WriteLine($"    -> Updated: '{contact.Updated}'");
        Console.WriteLine($"    -> Attention: '{contact.Attention}'");
        Console.WriteLine($"    -> Company: '{contact.Company}'");
        Console.WriteLine($"    -> RecipDepartment: '{contact.CompanyDepartment}'");
        Console.WriteLine($"    -> FirstName: '{contact.FirstName}'");
        Console.WriteLine($"    -> LastName: '{contact.LastName}'");
        Console.WriteLine($"    -> Position: '{contact.Position}'");
        Console.WriteLine($"    -> StreetAddress: '{contact.StreetAddress}'");
        Console.WriteLine($"    -> Suburb: '{contact.Suburb}'");
        Console.WriteLine($"    -> City: '{contact.City}'");
        Console.WriteLine($"    -> State: '{contact.State}'");
        Console.WriteLine($"    -> Country: '{contact.Country}'");
        Console.WriteLine($"    -> Postcode: '{contact.Postcode}'");
        Console.WriteLine($"    -> MainPhone: '{contact.MainPhone}'");
        Console.WriteLine($"    -> AltPhone1: '{contact.AltPhone1}'");
        Console.WriteLine($"    -> AltPhone2: '{contact.AltPhone2}'");
        Console.WriteLine($"    -> DirectPhone: '{contact.DirectPhone}'");
        Console.WriteLine($"    -> MobilePhone: '{contact.MobilePhone}'");
        Console.WriteLine($"    -> FaxNumber: '{contact.FaxNumber}'");
        Console.WriteLine($"    -> EmailAddress: '{contact.EmailAddress}'");
        Console.WriteLine($"    -> WebAddress: '{contact.WebAddress}'");
        Console.WriteLine($"    -> Custom1: '{contact.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{contact.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{contact.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{contact.Custom4}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

List Group Contact (Advanced):


using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;
using TNZAPI.NET.Core.Common;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.GroupContactList.List(
    new GroupModel()            // Group
    {
        GroupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD")
    },
    new ListRequestOptions()
    {
        RecordsPerPage = 50,    // Number of records for this request
        Page = 1                // Current location
    }
);

if (response.Result == Enums.ResultCode.Success)
{
    Console.WriteLine($"Group Contact list details");
    Console.WriteLine($"    -> GroupID: {response.Group.GroupID}");
    Console.WriteLine($"    -> GroupCode: {response.Group.GroupCode}");
    Console.WriteLine($"    -> Total Records: {response.TotalRecords}");
    Console.WriteLine($"    -> Records Per Page: {response.RecordsPerPage}");
    Console.WriteLine($"    -> Page Count: {response.PageCount}");
    Console.WriteLine($"    -> Page: {response.Page}");

    foreach (var contact in response.Contacts)
    {
        Console.WriteLine($"Contact details for ContactID={contact.ContactID}");
        Console.WriteLine($"    -> Owner: '{contact.Owner}'");
        Console.WriteLine($"    -> Created: '{contact.Created}'");
        Console.WriteLine($"    -> Updated: '{contact.Updated}'");
        Console.WriteLine($"    -> Attention: '{contact.Attention}'");
        Console.WriteLine($"    -> Company: '{contact.Company}'");
        Console.WriteLine($"    -> RecipDepartment: '{contact.CompanyDepartment}'");
        Console.WriteLine($"    -> FirstName: '{contact.FirstName}'");
        Console.WriteLine($"    -> LastName: '{contact.LastName}'");
        Console.WriteLine($"    -> Position: '{contact.Position}'");
        Console.WriteLine($"    -> StreetAddress: '{contact.StreetAddress}'");
        Console.WriteLine($"    -> Suburb: '{contact.Suburb}'");
        Console.WriteLine($"    -> City: '{contact.City}'");
        Console.WriteLine($"    -> State: '{contact.State}'");
        Console.WriteLine($"    -> Country: '{contact.Country}'");
        Console.WriteLine($"    -> Postcode: '{contact.Postcode}'");
        Console.WriteLine($"    -> MainPhone: '{contact.MainPhone}'");
        Console.WriteLine($"    -> AltPhone1: '{contact.AltPhone1}'");
        Console.WriteLine($"    -> AltPhone2: '{contact.AltPhone2}'");
        Console.WriteLine($"    -> DirectPhone: '{contact.DirectPhone}'");
        Console.WriteLine($"    -> MobilePhone: '{contact.MobilePhone}'");
        Console.WriteLine($"    -> FaxNumber: '{contact.FaxNumber}'");
        Console.WriteLine($"    -> EmailAddress: '{contact.EmailAddress}'");
        Console.WriteLine($"    -> WebAddress: '{contact.WebAddress}'");
        Console.WriteLine($"    -> Custom1: '{contact.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{contact.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{contact.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{contact.Custom4}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}
            

Copy code

Required parameters

Parameter Example Value Description
AuthToken eyJhbGciOiJI...adQssw5c Auth Token value set up in Create a new API Auth token
GroupModel GroupModel object Specifies GroupModel object with GroupCode of the group to retrieve. (required)

client.Addressbook.GroupContactList.List() Parameters

Option Structure Description
List(
  GroupModel
)
GroupContactListApiResult List(
    GroupModel entity, 
    int? recordsPerPage = null, 
    int? page = null
)                     
Get contact detail using GroupModel object.

Usage:
client.Addressbook.GroupContactList.List(
  new GroupModel(){...}, //required
  page: 1 //optional
);


Returns GroupContactListApiResult.
List(
  GroupModel
  ListRequestOptions
)
GroupContactListApiResult List(
    GroupModel entity, 
    IListRequestOptions options
)                     
Get contact detail using GroupModel & ListRequestOptions object.

Usage:
client.Addressbook.GroupContactList.List(
  new GroupModel(){...}, //required
  new ListRequestOptions() {...}
);


Returns GroupContactListApiResult.
ListById(GroupCode)
GroupContactListApiResult ListById(
    string GroupCode, 
    int? recordsPerPage = null, 
    int? page = null
)             
Get contact detail using contact id.

Usage:
client.Addressbook.GroupContactList.ListById(
  [GroupCode], //required
  page: 1 //optional
);


Returns GroupContactListApiResult.
ListById(
  GroupCode
  ListRequestOptions
)
GroupContactListApiResult ListById(
    string GroupCode, 
    IListRequestOptions options
)                     
Get contact detail using GroupCode & ListRequestOptions object.

Usage:
client.Addressbook.GroupContactList.ListById(
  [GroupCode], //required
  new ListRequestOptions() {...}
);


Returns GroupContactListApiResult.
ListAsync(
  GroupModel
)
Task<GroupContactListApiResult> ListAsync(
    GroupModel entity, 
    int? recordsPerPage = null, 
    int? page = null
)                     
Get contact detail using GroupModel object.

Usage:
await client.Addressbook.GroupContactList.ListAsync(
  new GroupModel(){...}, //required
  page: 1 //optional
);


Returns Task<GroupContactListApiResult>.
ListAsync(
  GroupModel
  ListRequestOptions
)
Task<GroupContactListApiResult> ListAsync(
    GroupModel entity, 
    IListRequestOptions options
)                     
Get contact detail using GroupModel & ListRequestOptions object.

Usage:
await client.Addressbook.GroupContactList.ListAsync(
  new GroupModel(){...}, //required
  new ListRequestOptions() {...}
);


Returns Task<GroupContactListApiResult>.
ListByIdAsync(GroupCode)
Task<GroupContactListApiResult> ListByIdAsync(
    string GroupCode, 
    int? recordsPerPage = null, 
    int? page = null
)             
Get contact detail using contact id.

Usage:
await client.Addressbook.GroupContactList.ListByIdAsync(
  [GroupCode], //required
  page: 1 //optional
);


Returns Task<GroupContactListApiResult>.
ListByIdAsync(
  GroupCode
  ListRequestOptions
)
Task<GroupContactListApiResult> ListByIdAsync(
    string GroupCode, 
    IListRequestOptions options
)                     
Get contact detail using GroupCode & ListRequestOptions object.

Usage:
await client.Addressbook.GroupContactList.ListByIdAsync(
  [GroupCode], //required
  new ListRequestOptions() {...}
);


Returns Task<GroupContactListApiResult>.

IListRequestOptions properties

Property Type Example Value Description
RecordsPerPage int 100 Number of records per API request to be returned.
Page int 1 Current location of data set.

GroupContactListApiResult object properties

Property Type Example Value Description
Result ResultCode ResultCode.Success Result of your API call (not the result of the message)
TotalRecords int 3 Total number of groups associated with this contact
RecordsPerPage int 100 Return x number of records per request (optional)
PageCount int 1 Maximum number of pages
Page int 1 Current location of the result set (optional)
Group GroupModel GroupModel object Group detail
Contacts List<ContactModel> ContactModel list List of contacts associated with this group
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

Create Group Contact - Create Group Contact via .NET

 

Create Group Contact (Basic):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Addressbook.GroupContact.Add(groupID, contactID);

if (response.Result == Enums.ResultCode.Success)
{
    if (response.Group is not null)
    {
        Console.WriteLine($"Group details for GroupCode={response.Group.GroupCode}");
        Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{response.Group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
    if (response.Contact is not null)
    {
        Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
        Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
        Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
        Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
        Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
        Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
        Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
        Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
        Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
        Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
        Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
        Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
        Console.WriteLine($"    -> City: '{response.Contact.City}'");
        Console.WriteLine($"    -> State: '{response.Contact.State}'");
        Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
        Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
        Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
        Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
        Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
        Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
        Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
        Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
        Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
        Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
        Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Create Group Contact (Simple):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Addressbook.GroupContact.Add(
    groupID: groupID,
    contactID: contactID
);

if (response.Result == Enums.ResultCode.Success)
{
    if (response.Group is not null)
    {
        Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
        Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{response.Group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
    if (response.Contact is not null)
    {
        Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
        Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
        Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
        Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
        Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
        Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
        Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
        Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
        Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
        Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
        Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
        Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
        Console.WriteLine($"    -> City: '{response.Contact.City}'");
        Console.WriteLine($"    -> State: '{response.Contact.State}'");
        Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
        Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
        Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
        Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
        Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
        Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
        Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
        Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
        Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
        Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
        Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Create Group Contact (Builder):


using TNZAPI.NET.Api.Addressbook.Contact;
using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Addressbook.Group;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var group = new GroupBuilder(new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD"))
                .Build();

var contact = new ContactBuilder(new ContactID("AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD"))
                .Build();

var response = client.Addressbook.GroupContact.Add(group, contact);

if (response.Result == Enums.ResultCode.Success)
{
    if (response.Group is not null)
    {
        Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
        Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{response.Group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
    if (response.Contact is not null)
    {
        Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
        Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
        Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
        Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
        Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
        Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
        Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
        Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
        Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
        Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
        Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
        Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
        Console.WriteLine($"    -> City: '{response.Contact.City}'");
        Console.WriteLine($"    -> State: '{response.Contact.State}'");
        Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
        Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
        Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
        Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
        Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
        Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
        Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
        Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
        Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
        Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
        Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Create Group Contact (Advanced):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.GroupContact.Add(
    new GroupModel()
    {
        GroupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD")         // GroupID
    },
    new ContactModel()
    {
        ContactID = new ContactID("AAAAAAAA-BBBB-BBBB-CCCC-DDDDDDDDDDDD")     // ContactID
    }
);

if (response.Result == Enums.ResultCode.Success)
{
    if (response.Group is not null)
    {
        Console.WriteLine($"Group details for GroupID={response.Group.GroupID}");
        Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{response.Group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
    if (response.Contact is not null)
    {
        Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
        Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
        Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
        Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
        Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
        Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
        Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
        Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
        Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
        Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
        Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
        Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
        Console.WriteLine($"    -> City: '{response.Contact.City}'");
        Console.WriteLine($"    -> State: '{response.Contact.State}'");
        Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
        Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
        Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
        Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
        Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
        Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
        Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
        Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
        Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
        Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
        Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

Parameter Example Value Description
AuthToken eyJhbGciOiJI...adQssw5c Auth Token value set up in Create a new API Auth token
GroupModel GroupModel object Specifies GroupModel object to create
ContactModel ContactModel object Specifies ContactModel object to create

client.Addressbook.GroupContact.Add() Parameters

Option Structure Description
Add(
  GroupModel,
  ContactModel
)
GroupContactApiResult Add(
    GroupModel group,
    ContactModel contact
)                     
Creates contact group using ContactModel & GroupModel objects.

Usage:
client.Addressbook.GroupContact.Add(
  new GroupModel(){...},
  new ContactModel(){...}
);


Returns GroupContactApiResult.
Add(
  GroupCode,
  ContactID
)
GroupContactApiResult Add(
    string groupCode,
    string contactID
)             
Creates contact group using ids.

Usage:
client.Addressbook.GroupContact.Add(
  [GroupCode],
  [ContactID]
);


Returns GroupContactApiResult.
AddAsync(
  GroupModel,
  ContactModel
)
Task<GroupContactApiResult> AddAsync(
    GroupModel group,
    ContactModel contact
)                     
Creates contact group using GroupModel & ContactModel objects.

Usage:
await client.Addressbook.GroupContact.AddAsync(
  new GroupModel(){...},
  new ContactModel(){...}
);


Returns Task<GroupContactApiResult>.
AddAsync(
  GroupCode,
  ContactID
)
Task<GroupContactApiResult> AddAsync(
    string groupCode,
    string contactID
)             
Creates contact group using ids.

Usage:
await client.Addressbook.GroupContact.AddAsync(
  [GroupCode],
  [ContactID]
);


Returns Task<GroupContactApiResult>.

GroupContactApiResult object properties

Property Type Example Value Description
Result ResultCode ResultCode.Success Result of your API call (not the result of the message)
Group GroupModel GroupModel object Group detail
Contact ContactModel ContactModel object Contact detail
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

Delete Group Contact - Delete Group Contact via .NET

 

Delete Group Contact (Basic):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var groupID = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var contactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD");

var response = client.Addressbook.GroupContact.Remove(groupID, contactID);

if (response.Result == Enums.ResultCode.Success)
{
    if (response.Group is not null)
    {
        Console.WriteLine($"Group details for GroupCode={response.Group.GroupCode}");
        Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{response.Group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
    if (response.Contact is not null)
    {
        Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
        Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
        Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
        Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
        Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
        Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
        Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
        Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
        Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
        Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
        Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
        Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
        Console.WriteLine($"    -> City: '{response.Contact.City}'");
        Console.WriteLine($"    -> State: '{response.Contact.State}'");
        Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
        Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
        Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
        Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
        Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
        Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
        Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
        Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
        Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
        Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
        Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Delete Group Contact (Simple):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.GroupContact.Remove(
    groupID: new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD"),       // GroupID
    contactID: new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD")    // ContactID
);

if (response.Result == Enums.ResultCode.Success)
{
    if (response.Group is not null)
    {
        Console.WriteLine($"Group details for GroupCode={response.Group.GroupCode}");
        Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{response.Group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
    if (response.Contact is not null)
    {
        Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
        Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
        Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
        Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
        Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
        Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
        Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
        Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
        Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
        Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
        Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
        Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
        Console.WriteLine($"    -> City: '{response.Contact.City}'");
        Console.WriteLine($"    -> State: '{response.Contact.State}'");
        Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
        Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
        Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
        Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
        Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
        Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
        Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
        Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
        Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
        Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
        Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Delete Group Contact (Builder):


using TNZAPI.NET.Api.Addressbook.Contact;
using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Addressbook.Group;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var group = new GroupBuilder(new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD"))
                .Build();

var contact = new ContactBuilder(new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD"))
                .Build();

var response = client.Addressbook.GroupContact.Remove(group, contact);

if (response.Result == Enums.ResultCode.Success)
{
    if (response.Group is not null)
    {
        Console.WriteLine($"Group details for GroupCode={response.Group.GroupCode}");
        Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{response.Group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
    if (response.Contact is not null)
    {
        Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
        Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
        Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
        Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
        Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
        Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
        Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
        Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
        Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
        Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
        Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
        Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
        Console.WriteLine($"    -> City: '{response.Contact.City}'");
        Console.WriteLine($"    -> State: '{response.Contact.State}'");
        Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
        Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
        Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
        Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
        Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
        Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
        Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
        Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
        Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
        Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
        Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Delete Group Contact (Advanced):


using TNZAPI.NET.Api.Addressbook.Contact.Dto;
using TNZAPI.NET.Api.Addressbook.Group.Dto;
using TNZAPI.NET.Core;

var apiUser = new TNZApiUser()
{
    AuthToken = "[Your Auth Token]"
};

var client = new TNZApiClient(apiUser);

var response = client.Addressbook.GroupContact.Remove(
    new GroupModel()
    {
        GroupCode = new GroupID("GGGGGGGG-BBBB-BBBB-CCCC-DDDDDDDDDDDD")         // Group Code
    },
    new ContactModel()
    {
        ContactID = new ContactID("CCCCCCCC-BBBB-BBBB-CCCC-DDDDDDDDDDDD")       // Contact ID
    }
);

if (response.Result == Enums.ResultCode.Success)
{
    if (response.Group is not null)
    {
        Console.WriteLine($"Group details for GroupCode={response.Group.GroupCode}");
        Console.WriteLine($"    -> GroupCode: '{response.Group.GroupCode}'");
        Console.WriteLine($"    -> GroupName: '{response.Group.GroupName}'");
        Console.WriteLine($"    -> SubAccount: '{response.Group.SubAccount}'");
        Console.WriteLine($"    -> Department: '{response.Group.Department}'");
        Console.WriteLine($"    -> ViewEditBy: '{response.Group.ViewEditBy}'");
        Console.WriteLine($"    -> Owner: '{response.Group.Owner}'");
        Console.WriteLine($"-------------------------");
    }
    if (response.Contact is not null)
    {
        Console.WriteLine($"Contact details for ContactID={response.Contact.ContactID}");
        Console.WriteLine($"    -> Owner: '{response.Contact.Owner}'");
        Console.WriteLine($"    -> Created: '{response.Contact.Created}'");
        Console.WriteLine($"    -> Updated: '{response.Contact.Updated}'");
        Console.WriteLine($"    -> Attention: '{response.Contact.Attention}'");
        Console.WriteLine($"    -> Company: '{response.Contact.Company}'");
        Console.WriteLine($"    -> RecipDepartment: '{response.Contact.CompanyDepartment}'");
        Console.WriteLine($"    -> FirstName: '{response.Contact.FirstName}'");
        Console.WriteLine($"    -> LastName: '{response.Contact.LastName}'");
        Console.WriteLine($"    -> Position: '{response.Contact.Position}'");
        Console.WriteLine($"    -> StreetAddress: '{response.Contact.StreetAddress}'");
        Console.WriteLine($"    -> Suburb: '{response.Contact.Suburb}'");
        Console.WriteLine($"    -> City: '{response.Contact.City}'");
        Console.WriteLine($"    -> State: '{response.Contact.State}'");
        Console.WriteLine($"    -> Country: '{response.Contact.Country}'");
        Console.WriteLine($"    -> Postcode: '{response.Contact.Postcode}'");
        Console.WriteLine($"    -> MainPhone: '{response.Contact.MainPhone}'");
        Console.WriteLine($"    -> AltPhone1: '{response.Contact.AltPhone1}'");
        Console.WriteLine($"    -> AltPhone2: '{response.Contact.AltPhone2}'");
        Console.WriteLine($"    -> DirectPhone: '{response.Contact.DirectPhone}'");
        Console.WriteLine($"    -> MobilePhone: '{response.Contact.MobilePhone}'");
        Console.WriteLine($"    -> FaxNumber: '{response.Contact.FaxNumber}'");
        Console.WriteLine($"    -> EmailAddress: '{response.Contact.EmailAddress}'");
        Console.WriteLine($"    -> WebAddress: '{response.Contact.WebAddress}'");
        Console.WriteLine($"    -> Custom1: '{response.Contact.Custom1}'");
        Console.WriteLine($"    -> Custom2: '{response.Contact.Custom2}'");
        Console.WriteLine($"    -> Custom3: '{response.Contact.Custom3}'");
        Console.WriteLine($"    -> Custom4: '{response.Contact.Custom4}'");
        Console.WriteLine($"-------------------------");
    }
}
else
{
    Console.WriteLine("Error occurred while processing.");

    foreach (var error in response.ErrorMessage)
    {
        Console.WriteLine($"- Error={error}");
    }
}            

Copy code

Required parameters

Parameter Example Value Description
AuthToken eyJhbGciOiJI...adQssw5c Auth Token value set up in Create a new API Auth token
GroupModel GroupModel object Specifies GroupModel object to delete
ContactModel ContactModel object Specifies ContactModel object to delete

client.Addressbook.GroupContact.Remove() Parameters

Option Structure Description
Remove(
  GroupModel,
  ContactModel
)
GroupContactApiResult Remove(
    GroupModel group,
    ContactModel contact
)                     
Delete contact group using GroupModel & ContactModel objects.

Usage:
client.Addressbook.GroupContact.Remove(
  new GroupModel(){...},
  new ContactModel(){...}
);


Returns GroupContactApiResult.
Remove(
  GroupCode,
  ContactID
)
GroupContactApiResult Remove(
    string groupCode,
    string contactID
)             
Delete contact group using ids.

Usage:
client.Addressbook.GroupContact.Remove(
  [GroupCode],
  [ContactID]
);


Returns GroupContactApiResult.
RemoveAsync(
  GroupModel,
  ContactModel
)
Task<GroupContactApiResult> RemoveAsync(
    GroupModel group,
    ContactModel contact
)                     
Delete contact group using GroupModel & ContactModel objects.

Usage:
await client.Addressbook.GroupContact.RemoveAsync(
  new GroupModel(){...},
  new ContactModel(){...}
);


Returns Task<GroupContactApiResult>.
RemoveAsync(
  GroupCode,
  ContactID
)
Task<GroupContactApiResult> RemoveAsync(
    string groupCode,
    string contactID
)             
Delete contact group using ids.

Usage:
await client.Addressbook.GroupContact.RemoveAsync(
  [GroupCode],
  [ContactID]
);


Returns Task<GroupContactApiResult>.

GroupContactApiResult object properties

Property Type Example Value Description
Result ResultCode ResultCode.Success Result of your API call (not the result of the message)
Group GroupModel GroupModel object Group detail
Contact ContactModel ContactModel object Contact detail
ErrorMessage List<string> Missing Sender Reason for the API call failure (see a list of possible values: TNZ API Errors)

Versioning

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


Frequently Asked Questions

Yes, full international delivery is supported.
The maximum request size supported is 20MB. This is our server side limitation. Your client side limitation may be smaller.
There is no limit to the number of Destinations (in either format), provided you do not breach the maximum request size.
There is a limit of 10 files specified in a single request. There is no file size limitation, provided you do not breach the maximum request size.
Yes, we support email security measures. Contact us for further information on setting up your own security measures for whitelabeled messages delivered with the API.
You can send a wide range of file types, including Microsoft Office® documents (doc, docx, ppt, pptx, xls, xlsx, etc), Openoffice/Libreoffice documents (odt, ods, etc), Adobe® documents (pdf, etc), image file types (jpg, gif, tif, bmp, etc) and more (txt, html, etc).
SMS messages are sent and charged in blocks of characters. One text message is 160 characters. By default, we will limit your message to three-message-parts in length (459 characters using the GSM character set, or 210 characters using Unicode/UCS-2). This can be increased on request. See the SMS Message Parts and Concatenated SMS guide for further information.
Yes, we can provide a daily or monthly email report (as an attached CSV file) containing data on messages sent. This can be used for billing (contains costs) or for reporting (doesn’t contain costs).
Yes, encrypted submissions are accepted via HTTPS. SSL/TLS is also supported for outbound email messages provided the receiving email server supports this.
Some networks support customised SMS Caller IDs. This can be configured using your Web Dashboard.
Your Fax Caller ID can be configured using your Web Dashboard.
Your Voice and TextToSpeech Caller ID is specified on a per-message basis using the 'CallerID' parameter.
");