💬 Send SMS

Overview

SMS notifications provide instant, direct communication with your users. NotificationAPI makes it easy to send personalized SMS messages with features like proper phone number formatting, delivery tracking, and global reach.

This guide covers everything you need to know about sending SMS notifications, from basic setup to advanced features.

Step 1: Create your account and first notification

  • Create your NotificationAPI account and complete the onboarding. Sign up for free.
  • In the dashboard, create your first notification and enable the SMS channel. See the Configure Notification guide if needed.
  • Note the notification’s Type (e.g., welcome_sms). You’ll use this later in the send step.

Step 2: Install the SDK

In the dashboard send step, the first thing you’ll need to do is install the SDK. Select the appropriate language and follow the instructions.

Install the node package using one of the following package managers:

npm install notificationapi-node-server-sdk
yarn add notificationapi-node-server-sdk
pnpm add notificationapi-node-server-sdk
pip install notificationapi_python_server_sdk
composer require notificationapi/notificationapi-php-server-sdk
go get github.com/notificationapi-com/notificationapi-go-server-sdk
dotnet add package NotificationAPI --version 0.5.0

Add the following dependencies to your pom.xml file:

<dependencies>
    <dependency>
        <groupId>com.notificationapi</groupId>
        <artifactId>notificationapi-java-server-sdk</artifactId>
        <version>0.3.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.14</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.15.2</version>
    </dependency>
</dependencies>

Add the NotificationAPI class to your application - see the full Ruby implementation.

Step 3: Send an SMS Notification

The next part of the send step is to send the notification from your backend. Here’s how to send an SMS notification by passing the SMS content directly:

TIP

Replace the type value (e.g., welcome_sms) with the notification Type you noted in Step 1, and replace YOUR_CLIENT_ID and YOUR_CLIENT_SECRET with the values from the code sample in your NotificationAPI dashboard.

import notificationapi from 'notificationapi-node-server-sdk';

// Initialize (default US region)
// For CA region: add 'https://api.ca.notificationapi.com' after CLIENT_SECRET
// For EU region: add 'https://api.eu.notificationapi.com' after CLIENT_SECRET
notificationapi.init('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET');

// Send SMS notification (direct content)
notificationapi.send({
  type: 'welcome_sms',
  to: {
    id: 'user123',
    number: '+16175551212' // Replace using format [+][country code][area code][local number]
  },
  sms: {
    message: 'Welcome to Acme Corp! Thanks for joining.'
  }
});
import asyncio
from notificationapi_python_server_sdk import notificationapi

# Initialize (default US region)
notificationapi.init("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET")

async def send_sms():
    await notificationapi.send({
        "type": "welcome_sms",
        "to": {
            "id": "user123",
            "number": "+16175551212"  # Replace using format [+][country code][area code][local number]
        },)
        "sms": {
            "message": "Welcome to Acme Corp! Thanks for joining."
        }
    })

# Run the async function
asyncio.run(send_sms())
use NotificationAPI\NotificationAPI;

// Initialize
$notificationapi = new NotificationAPI('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET');

// Send SMS notification (direct content)
$notificationapi->send([
    "type" => "welcome_sms",
    "to" => [
        "id" => "user123",
        "number" => "+16175551212"  // Replace using format [+][country code][area code][local number]
    ],
    "sms" => [
        "message" => "Welcome to Acme Corp! Thanks for joining."
    ]
]);
package main

import (
    notificationapi "github.com/notificationapi-com/notificationapi-go-server-sdk"
)

func main() {
    // Initialize
    notificationapi.Init("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", "https://api.notificationapi.com")

    // Send SMS notification (direct content)
    notificationapi.Send(
        notificationapi.SendRequest{
            Type: "welcome_sms",
            To: notificationapi.User{
                Id:     "user123",
                Number: "+16175551212",  // Replace using format [+][country code][area code][local number]
            },
            Sms: map[string]interface{}{
                "message": "Welcome to Acme Corp! Thanks for joining.",
            },
        },
    )
}
using NotificationApi.Server;
using NotificationApi.Server.Models;

// Initialize
var notificationApi = new NotificationApiServer("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET");

// Create user
var user = new NotificationUser("user123")
{
    TelephoneNumber = "+16175551212"  // Replace using format [+][country code][area code][local number]
};

// Send SMS notification (direct content)
await notificationApi.Send(new SendNotificationData("welcome_sms", user)
{
    Type = "welcome_sms",
    To = user,
    Sms = new Dictionary<string, object>
    {
        { "message", "Welcome to Acme Corp! Thanks for joining." }
    }
});
package com.example;

import com.notificationapi.NotificationApi;
import com.notificationapi.model.*;

public class Example {
    public static void main(String[] args) {
        NotificationApi api = new NotificationApi(
            "YOUR_CLIENT_ID",
            "YOUR_CLIENT_SECRET"
        );

        // Create user
        User user = new User("user123")
            .setEmail("user@example.com")
            .setNumber("+16175551212"); // Replace using format [+][country code][area code][local number]

        // Create and send notification request
        NotificationRequest request = new NotificationRequest("welcome_sms", user)
            .setSms(new SmsOptions()
                .setMessage("Welcome to Acme Corp! Thanks for joining.")
            );

        System.out.println("Sending notification request...");
        String response = api.send(request);
        System.out.println("Response: " + response);
    }
}
# Initialize
notificationapi = NotificationAPI.new("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET")

# Send SMS notification (direct content)
notificationapi.send({
  type: 'welcome_sms',
  to: {
    id: 'user123',
    number: '+16175551212'  # Replace using format [+][country code][area code][local number]
  },
  sms: {
    message: 'Welcome to Acme Corp! Thanks for joining.'
  }
})

You’re All Set!

🎉 Congrats! You’re now sending notifications!

If you’d like to send using templates configured in the Dashboard, check out our Templating guide and Backend Integration, or learn more about SMS best practices below.

TIP

SMS messages are limited to 800 ASCII characters. Design concise templates that convey essential information clearly.

Phone Number Formatting

Proper phone number formatting is crucial for SMS delivery. Always use the international E.164 format with a plus sign and country code.

E.164 Format (Required)

Use the E.164 format for all phone numbers:

// ✅ Correct E.164 format examples
notificationapi.send({
  type: 'order_update',
  to: {
    id: 'user456',
    number: '+16175551212' // US number
  },
  parameters: {
    orderNumber: 'ORD-123',
    status: 'shipped'
  }
});

// More E.164 examples
const phoneNumbers = [
  '+16175551212', // United States
  '+447911123456', // United Kingdom
  '+33123456789', // France
  '+81901234567', // Japan
  '+5511987654321', // Brazil
  '+4917612345678', // Germany
  '+61412345678' // Australia
];
WARNING

Always use E.164 format (+[country code][phone number]) for reliable SMS delivery worldwide.

SMS Best Practices

1. Message Length and Content

Character Limits:

  • SMS limit: 800 ASCII characters maximum
  • Recommended: Keep messages under 160 characters for single SMS segments
  • Long messages: Automatically split into multiple segments
  • Avoid spam: Don’t send excessive messages
  • Opt-in required: Ensure users have consented to SMS notifications
  • Opt-out mechanism: Include unsubscribe instructions when required
  • Regulatory compliance: Follow local regulations (TCPA in US, GDPR in EU)
  • Record keeping: Maintain consent records
  • Avoid spam: Don’t send excessive messages

A2P 10DLC Registration (US)

See the dedicated guide: A2P 10DLC Registration

Sender Phone Numbers

See sender options and details here: Sender phone numbers.

SMS Responses and Two-Way Communication

NotificationAPI supports receiving and processing SMS replies:

Setting Up SMS Responses

SMS responses are an enterprise and paid account feature that requires a dedicated phone number.

  1. Webhook configuration: Contact support to set up response webhooks
  2. Response handling: Process incoming SMS replies in your application
  3. Auto-responses: Set up automated replies for common responses

Tracking and Analytics

NotificationAPI automatically tracks SMS metrics:

  • Delivery status: Successfully delivered messages
  • Failed deliveries: Numbers that couldn’t receive messages

View all analytics in your dashboard under Logs and Insights.

Need more help?

If you need help, reach out through our live chat or Slack community.