Sending an SMS

Sending an SMS message with Nexmo is straightforward. Sign up for an account and replace the following variables in the example below:

Key Description
TO_NUMBER The number you are sending the SMS to in E.164 format. For example 447700900000.
NEXMO_API_KEY You can find this in your account overview
NEXMO_API_SECRET You can find this in your account overview
curl -X "POST" "https://rest.nexmo.com/sms/json" \
  -d "from=Acme Inc" \
  -d "text=A text message sent using the Nexmo SMS API" \
  -d "to=TO_NUMBER" \
  -d "api_key=NEXMO_API_KEY" \
  -d "api_secret=NEXMO_API_SECRET"

Prerequisites

Install the Nexmo library

Initialize the library

Code

const from = 'Acme Inc'
const to = TO_NUMBER
const text = 'A text message sent using the Nexmo SMS API'

nexmo.message.sendSms(from, to, text)

Prerequisites

Install the Nexmo library

Initialize the library

Code

SmsSubmissionResult[] responses = client.getSmsClient().submitMessage(new TextMessage(
        "Acme Inc",
        TO_NUMBER,
        "A text message sent using the Nexmo SMS API"));
for (SmsSubmissionResult response : responses) {
    System.out.println(response);
}

Prerequisites

Install the Nexmo library via the NuGet Package Manager Console

Initialize the library

Code

var results = client.SMS.Send(request: new SMS.SMSRequest
{
    from = "Acme Inc",
    to = TO_NUMBER,
    text = "A test SMS sent using the Nexmo SMS API"
});

Prerequisites

Install the Nexmo library

Initialize the library

Code

$message = $client->message()->send([
    'to' => TO_NUMBER,
    'from' => 'Acme Inc',
    'text' => 'A text message sent using the Nexmo SMS API'
]);

Prerequisites

Install the Nexmo library

Initialize the library

Code

client.send_message({
    'from': 'Acme Inc',
    'to': TO_NUMBER,
    'text': 'A text message sent using the Nexmo SMS API',
})

Prerequisites

Install the Nexmo library

Initialize the library

Code

client.sms.send(
  from: 'Acme Inc',
  to: RECIPIENT_NUMBER,
  text: 'A text message sent using the Nexmo SMS API'
)