Click on the banner to learn about and purchase my database training on Azure

Using the Pushbullet API to send SMS messages in C #, PHP, Java, or SQL Server (with CLR)

Views: 4.714 views
Reading Time: 8 minutes

Hello people,
Good afternoon!

In this post, I want to show you something new that I was able to develop this week and I found very cool, which is sending SMS messages from virtually any current programming language (C #, VB.NET, Java, PHP, etc.) and even , by the SQL Server database itself using SQL CLR (can also be done using xp_cmdshell).

This is especially useful for creating alerting and monitoring in production environments, where in case of any serious issues you can be notified, wherever you are, even if you are out of time with 3G or Wi-Fi.

You can use this to send an SMS to a company's business sector when a customer submits a quote request. If you have an online store, you can send torpedoes to your customers with status changes to an order, for example. The possibilities are many!

What is Pushbullet?


Pushbullet is a simple application with one main purpose: to transfer things from your smartphone to your computer and vice versa. You can send files and links to your phone, and get notifications from any smartphone associated with your PC account, such as when a friend checks in on Swarm, someone is calling you, or when your calendar reminds you about some compromise.

You can also send and receive SMS and reply to messages from WhatsApp, Facebook Messager, Hangouts, and others without touching your smartphone. It's easy: When someone sends a message via WhatsApp, an interactive notification will appear on your computer. Click Reply, type your message, and click Send.

Pushbullet also has some cool tricks, such as syncing the clipboard between devices, so you can cut text on your computer and paste it on your smartphone.

How does this solution work? How is the torpedo shipped?

The basic working of this functionality is as follows:

  • Through a programming language of your choice, you will send the request to the Pushbullet API, requesting the sending of SMS and informing the recipient number and the message.
  • The Pushbullet server will receive this request and direct you to the application associated with the device requested in your request.
  • The application of your selected mobile phone will receive the request from the server and use the SMS sending feature of your mobile phone.
  • SMS SMS successfully sent to recipient!

What are the requirements for this API to work?

Since the actual sending is from your mobile phone, messages sent by the API are available on your smartphone's SMS screen. In addition, you will need to have credits to send SMS as well as any regular SMS, or have a package with your mobile carrier that allows you to send these messages.

In my tests, I used my cell phone, where I have a Vivo 1 GB control plan and unlimited torpedoes for any carrier on any DDD, so that plan suits me perfectly. It even has some exclusive SMS packages that allow unlimited sending of messages for an even lower cost.

As you may have noticed, for this feature to work, the mobile device that will be responsible for sending the messages will always need to be on and have internet access.

What is the cost of this solution? Is there any shipping limit?

An important point to note is that the Pushbullet Free account only allows sending 500 pushes per month. To remove this limit and make it unlimited shipments, you will need to upgrade your Pushbullet account to the PRO version ( at a cost of $ 4,99 (dollars) per month or $ 3,33 (dollars) per month if you choose the annual plan. I find the value very fair and affordable.

I believe it is a very interesting solution and with a ZERO cost, for those who need a few shipments per month and already have a data pack with unlimited torpedo support in your phone.

Even if you have a need to send lots of SMS messages and you need to purchase a data packet with unlimited SMS + 1 GB internet 4G (actual 40 per month) and upgrade your Pushbullet account to PRO version (actual 10 per month) , the monthly cost for this solution is quite small (52 reais per month) and much lower than the business solutions that carriers and other companies offer in the market (and with a limit on the number of torpedoes sent).

I did a quick search on the internet and saw that some companies charge 100 reais per month to be able to send 1.000 torpedoes / month and some companies charge $ 0,16 per torpedo (500 torpedoes per month = 80 reais).

Creating your account and adding devices

To accomplish this activity, I will use the easy-to-use, well-documented Pushbullet API ( to use to access all of these features using your favorite programming language.

The first step is to create your account on the app's website ( It supports integration with Facebook and Google, allowing the service to read your data from one of these two services and save you time by entering the registration data.

Once registered, add your mobile devices by downloading and installing the Pushbullet app on them. Once installed and logged in to Pushbullet through the app on your mobile phone, it will be added to your device list from your account.

Retrieving Access Token, User ID, and Device ID

Once you have created your account and added the devices, go to the Preferences screen (Settings - and in the “Access Tokens” section click on the “Create Access Tokens” button


After clicking the button, a code will be shown on your screen. Write down this code as it will be the passcode to authenticate the requests we will send.

Now that you have your Pushbullet account and you have your Access Token, we need to retrieve your user ID and the ID of your mobile device that will be used to send the messages.

To retrieve this information, I recommend downloading the cURL binary, available from this link (Windows) ou this link (Any OS) or the use of the extension Postman, Google Chrome (more convenient and better viewing results)

Once downloaded and installed (on Windows, copy the executable to the C: \ Windows directory), we will use cURL to retrieve our account ID using the command below:


or making the same request with Postman:


With that, write down the iden code returned. This is your user ID, as you can have multiple users associated with your account.

Now let's retrieve the ID of our mobile device, which will send the SMS, using the command below in cURL:

or by Postman:

Write down the iden code returned from your device. This is the device ID.

Developing SMS push solution with Pushbullet API

Now that we have the necessary ID's to send the SMS, we can start our SMS sending routine.

Solution written in C # programming language for use in SQL Server by CLR


Source code:

In this script, I used the class ROI, which aims to send information messages and error messages to the database through the CLR. Your source code is available in the post. SQL Server - How to send warnings and error messages to the bank through CLR (C #).

Solution written in PHP Web programming language


Source code:

Generic solution using cURL.exe binary
After demonstrating examples using two different programming languages, I will demonstrate how to use cURL.exe itself, installed on your PC, to send SMS. You can choose your favorite programming language to submit your request, as I did in the examples above, or you can simply run cURL.exe binary from your programming language:

The default command to send SMS through cURL is this:


In the cURL command I used an external file (push_message.json) to store the information for the request I am going to send. You can have your programming language create this file at run time, use the path of the newly created file in the –data-binary parameter and delete it after execution.

I believe this solution through cURL is very generic and can be used by any programming language that allows you to execute binary files on the server, be it C #, PHP, Java, Ruby, etc.

That's it folks!
I hope you enjoyed this post.

Any questions, leave here in the comments!

sql sql server send torpedo send sms php java c # clr .net csharp ruby ​​curl command line code script snipplet script

sql sql server send torpedo send sms php java c # clr .net csharp ruby ​​curl command line code script snipplet script