Getting started
- Sign up for a ToucanText account.
- Select how you want to connect to your service.
Select your programming language
We have created a set of libraries to allow you to integrate our API into your code in minutes.
C# Synchronous
Add the API
In C# you should add the following to any .cs files that need to use the API.using ToucanText.Api.SenderApi;
Run the Code
To use the API create a new instance of theMessageSender(); object. Replace the user name and password with your Toucan API user name and password.
MessageSender messageSender =newMessageSender("userName","password");
Parameters
Get the Code
To send a message use theSendMessage(); method. The sender address can be an alphanumeric or numeric (depending on the country).
MessageSender messageSender =newMessageSender("userName","password"); messageSender.SendMessage("sourceAddress","destinationAddress","message");
ToucanText API Requirements
Download the DLL wrapper file and add The DLL reference to your project.
Download ToucanText .Net API v2.3Target Application
The ToucanText .NET API requires a minimum of .NET Framework 4.5 or .NET 10 to operate.
If your application targets .NET Framework 4.7.2 or later, we recommend using the .NET Standard 2.0 assembly.
If your application targets .NET 10 or later, we recommend using the .NET Standard 2.0 assembly.
If your application requires portability to different operating systems such as Linux, then we recommend targeting .NET 10 or later and using the .NET Standard 2.0 assembly.
C# Asynchronous
Add the API
In C# you should add the following to any .cs files that need to use the API.using ToucanText.Api.SenderApi;
Run the Code
To use the API create a new instance of theMessageSender(); object. Replace the user name and password with your Toucan API user name and password.
MessageSender messageSender =newMessageSender("userName","password");
Parameters
Get the Code
To send a message use theSendMessage(); method. The sender address can be an alphanumeric or numeric (depending on the country).
async public voidSubmitPage(Stringc,Stringmessage) { MessageSender messageSender =newMessageSender("userName","password");varresult =awaitmessageSender.SendMessageAsync("sourceAddress","destinationAddress","message"); }async private voidbutton1_Click(objectsender, EventArgs e) { MessageSender messageSender =newMessageSender("userName","password");varresult =awaitmessageSender.SendMessageAsync("sourceAddress","destinationAddress","message"); }
ToucanText API Requirements
Download the DLL wrapper file and add The DLL reference to your project.
Download ToucanText .Net API v2.3Target Application
The ToucanText .NET API requires a minimum of .NET Framework 4.5 or .NET 10 to operate.
If your application targets .NET Framework 4.7.2 or later, we recommend using the .NET Standard 2.0 assembly.
If your application targets .NET 10 or later, we recommend using the .NET Standard 2.0 assembly.
If your application requires portability to different operating systems such as Linux, then we recommend targeting .NET 10 or later and using the .NET Standard 2.0 assembly.
HTTP API
The basic construct of our API is as follows.Parameters
Get the Code
The DESTADDR parameter should be the destination number to send the message to in the format cc = Country code and nnnnnnnnnn is the phone number (with the leading 0 removed if present) i.e. 447123456789https://api.toucantext.com/bin/send.xml?USERNAME=apiusername&PASSWORD=apipassword&DESTADDR=ccnnnnnnnnnn&MESSAGE=messagecontent
Set the sender in a call
It is also possible to set the sender in a call, to do this you pass the SOURCEADDR in the URL. The SOURCEADDR can either be passed as a correctly formatted number (in the same format as the DESTADDR) or can be specified as alphanumeric text.Numeric
https://api.toucantext.com/bin/send.xml?USERNAME=apiusername&PASSWORD=apipassword&SOURCEADDR=ccnnnnnnnnnn&DESTADDR=ccnnnnnnnnnn&MESSAGE=messagecontent
Alphanumeric
https://api.toucantext.com/bin/send.xml?USERNAME=apiusername&PASSWORD=apipassword&DESTADDR=alphanumerictext&MESSAGE=messagecontent
PHP SDK
This library requires a minimum PHP version of 5.5Installation
To install the PHP client to your project, we recommend using Composer.composer require toucantext/php-sdk
Instantiating the SDK Client
Pass in the configuration to the client:$config=[ 'username'=>'{your_api_username}', 'password'=>'{your_api_password}']; $toucan=new\ToucanText\Client($config);
Using the Client
Getting all messages To return a list of all your messages (both inbound and delivery receipts):// return all your messages $messagesBy default, this returns a maximum of 25 messages but does NOT acknowledge them. To override this, pass the following parameters (the first denotes whether to acknowledge messages; the second for the maximum number of messages to return):=$toucan->messages->all();
// return 15 messages maximum and acknowledge them $messagesGetting inbound messages or delivery receipts only To return a list of inbound messages or delivery receipts:=$toucan->messages->all(true,15);
// return only inbound messages $messagesBy default, this returns a maximum of 25 inbound messages or delivery receipts but does NOT acknowledge them. To override this, pass the following parameters (the second denotes whether to acknowledge messages; the third for the maximum number of messages to return):=$toucan->messages->get('messagesOnly'); // return only delivery receipts $receipts=$toucan->messages->get('dlrsOnly');
// return 15 inbound messages maximum and acknowledge them $messagesSending a message To send a message you, can call the following:=$toucan->messages->get('messagesOnly',true,15); // return 15 delivery receipts maximum and acknowledge them $receipts=$toucan->messages->get('dlrsOnly',true,15);
// send a message $messageYou can also set a source address and request a delivery receipt:=[ 'destinationAddress'=>'{the_destination_address}', 'message'=>'{your_message}']; $toucan->messages->send($message);
// send a message with source address and request delivery receipt $messageAcknowledging delivery receipts and messages When you retrieve your inbound messages or delivery receipts, there is a MbStorageId element within the response of the query. This ID can be used to acknowledge messages and delivery receipts individually. To acknowledge a message or delivery receipt create an array with the ID's to acknowledge and then call the following:=[ 'sourceAddress'=>'{your_source_address}', 'destinationAddress'=>'{the_destination_address}', 'message'=>'{your_message}''deliveryReceipt'=>true]; $toucan->messages->send($message);
// array of message ID's to acknowledge $messages=[245,4564,456]; $toucan->messages->acknowledge($messages);
Handling Exceptions
Aside from errors that may occur due to the call, there may be other Exceptions thrown. To handle them, wrap your call in a try catch block:try{ $messages = $toucan->messages->all(); }catch(\Exception$e) { // do something with $e }
REST API
Send and receive messages using the ToucanText REST API. The full interactive reference for every endpoint is available in Swagger.Authentication
The API uses HTTP Basic authentication. Use your ToucanText account ID as the username and your API token as the password.Send a message
Send a message to one or more recipients by posting a JSON body to:POST https://ttapi.toucantext.com/Message
Parameters
Example
curlThe response contains a results array and your account balance. Check the status and statustext of each result to confirm the outcome for each recipient; each result also includes the msgid assigned to the message.-u"ACCOUNT_ID:API_TOKEN"-X POSThttps://ttapi.toucantext.com/Message \-H"Content-Type: application/json"\-d'{"senderID": "ToucanText", "recipientList": ["447123456789"], "messageDetail": "Hello from ToucanText"}'
Retrieve messages and delivery reports
Retrieve inbound messages and delivery reports from your account's inbound queue:GET https://ttapi.toucantext.com/Message
Parameters
Example
curlThe response contains a messageList array. Each entry includes the sourceAddr, destAddr, messageContents and arrivalTimeUTC. Delivery reports have dlr set to true, with dlrOriginalMessageId identifying the original message.-u"ACCOUNT_ID:API_TOKEN"\"https://ttapi.toucantext.com/Message?MaxMessageCount=25&AckMessages=False"
Premium SMS service for first-class developers
ToucanText provides a high-level of service that you should expect from an experienced, global provider.
Worldwide Reach
Our global network enables you to connect to over 7 billion people across 195 countries via 1600 direct-to-carrier and Tier 1 connections. ToucanText adheres to local rules using a global compliance engine.
2FA and Flash SMS
Provide two-factor authentication (2FA) via Flash SMS. Add a 2nd layer of security for remote access or login procedures – a One Time Password or SMS token, can easily be sent to mobiles via SMS.
Two-way SMS
Send SMS with low latency and high delivery rates. Benefit from inbound virtual numbers to allow customers to reply to messages, thus improving customer engagement and communication.



