Send SMS From Your Command Line: Introducing ClickSend CLI

Send SMS From Your Command Line: Introducing ClickSend CLI

By Michael Riecken

February 01, 2024

13 minutes read

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.

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:

Then install ClickSend CLI:

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.

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:

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”.

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:

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:

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

But Wait, There’s More

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

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.

This blog was originally posted on December 22, 2021
  • developers
  • command line
  • terminal
  • SMS CLI

Related Posts