Sinch Developer Documentation

We provide building blocks to enable you to build rich customer communication

Get Started

Send SMS in Java

This tutorial will walk you through building a simple Java SMS project that uses Sinch to send an SMS.

You can find the finished project here.


If you don’t yet have a Sinch developer account, create one at Us take note of the app key and secret.

Library for Base64 encoding

You will need to download and add the commons codec library to your
Eclipse project to encode your app key and secret. the .jar file and click build path –> add to build path

Send an SMS

Start by creating a new class; I’ll name mine To keep
things simple, I put the code to send an message, your app key, and your app secret.

import org.apache.commons.codec.binary.Base64;

public class Sms {

    public static void main(String[] args) {

        try {
            String phoneNumber = "phone-number";
            String appKey = "your-app-key";
            String appSecret = "your-app-secret";
            String message = "Hello, world!";

            URL url = new URL("" + phoneNumber);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestProperty("Content-Type", "application/json");

            String userCredentials = "application\\" + appKey + ":" + appSecret;
            byte[] encoded = Base64.encodeBase64(userCredentials.getBytes());
            String basicAuth = "Basic " + new String(encoded);
            connection.setRequestProperty("Authorization", basicAuth);

            String postData = "{\"Message\":\"" + message + "\"}";
            OutputStream os = connection.getOutputStream();

            StringBuilder response = new StringBuilder();
            BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));

            String line;
            while ( (line = br.readLine()) != null)



        } catch (IOException e) {



Now run the project and you will see “Hello, world!” appear as an SMS
to the phone number you enter with Sinch.

Note about sending quotes in your message: If you want to send a
message like **Jordan says “hi backslashes before the quotes that you want to show up in the message.

In addition, you can find SMS prices by country

Edit on GitHub

Send SMS in Java

This tutorial will walk you through building a simple Java SMS project that uses Sinch to send an SMS.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.