How to Send SMS Text Messages with Python

To send a text message, your application makes an HTTP Request to the SMS resource in the Telecoms Cloud API, which then sends the SMS to your recipient.

The first thing we’ll need is a Telecoms Cloud number, so if you’ve not done so already sign up using this link. Choose any number you like and then keep a note of it once you’ve bought it so we can use it in our script.

You’ll then need to generate yourself a set of Credentials to use with the API. In your Telecoms Cloud account just head over to your API Settings page to generate your Client ID and Client Secret.

Then, in your favourite text editor create a new script, and we’ll start by requiring the “requests” and “json” libraries. The first thing we need to do is authenticate ourselves by creating a POST request to the /authorization resource and POSTing our API credentials as JSON data in the request. We’ll receive back an access token, which we can use to sign our requests to any of the API’s resources.

PAUSE: In the real world, you should save this access token either in a database or some local storage, and re-use it with each request until it expires.

To send a text message we’ll construct another POST request, this time to the /SMS/outbound resource, and sign it with our access token. We include JSON data consisting of the recipient mobile phone number, our Telecoms Cloud number that we bought earlier on, and the message itself. When we execute that request we’ll receive back a unique ID which lets us check the status of that message later.

So now if we run our script we’ll see the unique ID returned and a couple of moments later, the text message is received!

That’s all there is to it! You can download a copy of this example code, and don’t forget to add in things like proper error handling and any other processing required by your application.

Don’t forget to subscribe to Telecoms Cloud on YouTube and follow us on Twitter. If you’ve got any questions or comments please leave them below and take a look at our other videos to learn more about what you can do with Telecoms Cloud.

Paul Freeman-Powell

About Paul Freeman-Powell

Paul Freeman-Powell is an Internet Entrepreneur and Co-founder of Telecoms Cloud. He's a Cloud technology enthusiast, and has worked with organisations such as the University of Liverpool, Banco de España and the Carphone Warehouse Group. Follow him on Twitter: @paulfp

About Telecoms Cloud

Telecoms Cloud makes it easy to build apps with powerful communication functionality, via a suite of easy-to-use APIs accessible within any programming language.

Speak to our team now on +44 (0)333 315 3333

Start Building Now

Cloud Service APIs

Voice API

Trigger outbound calls, record responses, initiate conference calls, transcript recordings and more…

Messaging API

Send and receive faxes or push notifications to devices worldwide.

Data & Tools API

Give us any phone number and we’ll re-format it for you, give you other technical information and more.


Connect to us and our API over the public internet, via peering agreements or even by co-locating your own equipment in one of our DCs.

Telecoms Cloud - Connecting Things™