Quick Start: Ruby

There are three steps to integrating our programmable SMS API into your Ruby project.

1. Create an account.

Sign up for an Esendex account. When you register you will receive a license key. You will need this to use the API.

2. Install Ruby.

Install Ruby if it is not on your computer already. To check, run this command in your terminal: ruby --version

PS C:\> ruby --version
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x64-mingw-ucrt]

3. Send a test message.

Create a new Ruby file. Let’s call it demo.rb.

You can use the SendMessage method to send a text message. Add the displayed code to your new file.

Replace the LicenseKey value with your account’s license key.

Replace the To value with your own mobile phone number.

require 'date_core'
require 'json'
require 'net/http'

headers = { Accept: 'application/json', 'Content-Type': 'application/json' }
uri = URI('')

data = {
  'Body': 'Hi, this message was sent using Ruby.',
  'LicenseKey': '00000000-0000-0000-0000-000000000000',
  'To': ['7575559999'],
  'UseMMS': false,

response =, data, headers)
raise response.message if response.is_a?(Net::HTTPClientError) || response.is_a?(Net::HTTPServerError)
message = JSON.parse(response.body)[0]

puts message['MessageStatus']

Run the project in your terminal with this command: ruby demo.rb. If the message status is 201 (the code for Ready), your call to the API was a success! You will receive the text message shortly on your phone.

PS C:\RubyDemo> ruby demo.rb
Message status: 201

Let’s start sending, together.