Are you a developer? Do you need to batch send SMS messages, but don’t want to go to the trouble of writing a program to do the work for you? Well, have we got a solution for you!

ClickSend’s Command Line Interface (CLI) is designed to make the automation of sending messages easy and fun without having to write a single line of code.

Send SMS From Your Favourite Terminal

Send and receive SMS messages from your preferred operating system and shell:

  • Send SMS from Linux and Unix
    Execute commands through popular shells like bash, bsh, zsh and more to send texts on macOS, Linux, and Unix.
  • Windows SMS Command Line
    Whether you’re loyal to Command Prompt or prefer Powershell, you’ll be sending texts in minutes.
  • Send Messages Remotely
    Execute send SMS commands through remote terminals like PuTTY or SSH.

Before You Begin

You’ll Need a Free ClickSend Account

You will need to sign up for a free ClickSend account. We’ll even give you some free credit to use to try this out!
If you already have an account, please skip this step.

You’ll Need to have Node and Git Installed on Your System

We’ll leave it to you to download and install Node and a Git command-line tool. They’re required.

Note: we are working on getting this installable via NPM, but at the moment, you’ll have to download the code from GitHub. Once we have the NPM registration up and running, Git will be optional.

Start Sending SMS from Command Line

Install and start sending text messages via your preferred command-line interface in 3 steps.

1. Get Your ClickSend Username and API Token

Log into our dashboard and navigate to the API Credentials page by using the Developers > API Credentials on the left side of the page.

If you don’t have a sub-account set up with API credentials, you can create one by clicking on the “Add Subaccount” button. Make sure that your sub-account has the permissions that you need later. In this case, we want to ensure “Access SMS” is enabled.

Screenshot showing how to add a subaccount to your ClickSend account in the ClickSend Dashboard

Find the sub-account that is going to send your message and grab the Username and API Key. The API key is a UUID in the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.

2. ClickSend CLI Installation

Download the ClickSend CLI:

git clone https://github.com/ClickSend/cli.git 

Then install ClickSend CLI:

cd cli 
npm install -g

3. Send Those Command-Line Texts

Substitute reasonable and obvious defaults for the values in [square brackets] and press enter. Voila! Your message is rocketing through the networks to your intended recipient.

clicksend sms send  
  --to [phonenumber]  
  --body "[The message]"  
  --csuser [your user id]  
  --cstoken [your API token]

Note: [phonenumber] must be a mobile phone number in international format (or E.164 format), which means that it has to start with a plus (+), followed by the country code, and then all of the digits.

Sample code:

clicksend sms send 
    --to +61422222222 
    --body "You have been a good developer this year." 
    --csuser GoodDeveloper 
    --cstoken XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

If the message body is more than 160 characters, then you will be charged for multiple message parts. To see how much this is going to cost you, send the exact same command but use the “calculate” sub-command instead of “send”.

clicksend sms calculate  
  --to [phonenumber]  
  --body "[The message]"  
  --csuser [your user id]  
  --cstoken [your API token]

If you wish to send the same message to up to 1,000 phone numbers, you can add as many as you’d like after –to with spaces separating the numbers.

The Command Response

There’s a lot of good information in the response that comes back in JSON format. Here’s a sample:

{
"http_code": 200,
"response_code": "SUCCESS",
"response_msg": "Messages queued for delivery.",
"data": {
	"total_price": 0.077,
	"total_count": 1,
	"queued_count": 1,
	"messages": [
		{
		"direction": "out",
		"date": 1639990444,
		"to": "+61422222222",
		"body": "You have been a good developer this year.",
		"from": "+61447213651",
		"schedule": 1639990444,
		"message_id": "AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE",
		"message_parts": 1,
		"message_price": "0.0770",
		"from_email": null,
		"list_id": null,
		"custom_string": "",
		"contact_id": null,
		"user_id": 222222,
		"subaccount_id": 111111,
		"country": "AU",
		"carrier": "Vodafone",
		"status": "SUCCESS"
		}
	],
	"_currency": {
		"currency_name_short": "AUD",
		"currency_prefix_d": "$",
		"currency_prefix_c": "c",
		"currency_name_long": "Australian Dollars"
	}
}
}

Taking it to the Next Level

Hide Those Credentials

You don’t have to pass the Username and Token with every call. On your system, set up environment variables with these values and the CLI will grab them for you:

CLICKSEND_USER 
CLICKSEND_TOKEN

Send Test Messages

Use one of our test phone numbers to send a message to /dev/null without incurring any costs. Some example test numbers for SMS are:

  • +61411111111
  • +61422222222
  • +61433333333
  • +61444444444
  • +14055555555
  • +14055555666
  • +447777777777
  • +8615555555555

Set the Sender ID

You can specify a --from option in the sms send command and that number will be displayed when your recipient receives that number. Sending a sender name like --from Santa will also work, but then the recipient won’t be able to respond to you. If you don’t specify a “from” then ClickSend will use a number from a shared number pool.

Check for Responses

Use the sms incoming command to see who has responded

clicksend sms incoming

But Wait, There’s More

Use our CLI’s extensive integrated help to get an idea of all of the features currently available.

clicksend help 
clicksend sms help 
clicksend sms send help

Easy Peasy

Have fun integrating ClickSend’s powerful messaging capabilities into whatever it is you’re building. Send us some news about what you’ve built, we’d love to see what you’re doing with the platform.