Notify API
Create a binding
A binding ties a notification address to a user. For example, User123’s Android phone push registration or Sue’s mobile phone number.
View docs- Curl
- Ruby
- Python
- Java
curl -XPOST https://notifications.twilio.com/v1/Services/ISxxx/Bindings \ -d "Identity=User123" \ -d "BindingType=gcm" \ -d "Address=xxx" \ -u '{twilio account sid}:{twilio auth token}'
require 'twilio-ruby' # Twilio credentials and service SID account_sid = 'AC421124bfab3052ad108f3e8c7a119cfb' auth_token = 'AUTH_TOKEN' notify_service_sid = 'IS13c4cce46710eb656ffffdef2c82c589' # Initialize the client client = Twilio::REST::Client.new(account_sid, auth_token) service = client.notifications.v1.services(notify_service_sid) # Create a binding binding = service.bindings.create( identity: 'User123', binding_type: 'apn', address: 'FE66489F304DC75B8D6E9200DFF8A456E8DAEACEC428B427E9518741C92C6660')
from twilio.rest import Client # Twilio credentials and service SID account_sid = 'AC421124bfab3052ad108f3e8c7a119cfb' auth_token = 'AUTH_TOKEN' notify_service_sid = 'IS13c4cce46710eb656ffffdef2c82c589' # Initialize the client client = Client(account_sid, auth_token) service = client.notifications.v1.services(notify_service_sid) # Create the binding binding = service.bindings.create( identity='User123', binding_type='apn', address='FE66489F304DC75B8D6E9200DFF8A456E8DAEACEC428B427E9518741C92C6660', )
import com.twilio.sdk.Twilio; import com.twilio.sdk.creator.notifications.v1.service.BindingCreator; public class CreateBinding { // Twilio credentials and service SID public static final String ACCOUNT_SID = "AC421124bfab3052ad108f3e8c7a119cfb"; public static final String AUTH_TOKEN = "AUTH_TOKEN"; public static final String NOTIFY_SERVICE_SID = "IS13c4cce46710eb656ffffdef2c82c589"; public static void main(String[] args) { Twilio.init(ACCOUNT_SID, AUTH_TOKEN); // Create the binding BindingCreator notification = new BindingCreator( NOTIFY_SERVICE_SID, "User123", Binding.BindingType.APN, "FE66489F304DC75B8D6E9200DFF8A456E8DAEACEC428B427E9518741C92C6660"); System.out.println(notification.execute()); } }
Send a transactional notification
Just select whom to send to and what to say and we translate that to all supported channels.
View docs- Curl
- Ruby
- Python
- Java
curl -X POST https://notifications.twilio.com/v1/Services/ISxxx/Notifications \ -d 'Identity=User123' \ -d 'Body=Hello World delivered via SMS, APNS, FCM and Facebook Messenger' \ -u '{twilio account sid}:{twilio auth token}'
require 'twilio-ruby' # Twilio credentials and service SID account_sid = 'AC421124bfab3052ad108f3e8c7a119cfb' auth_token = 'AUTH_TOKEN' notify_service_sid = 'IS13c4cce46710eb656ffffdef2c82c589' # Initialize the client client = Twilio::REST::Client.new(account_sid, auth_token) service = client.notifications.v1.services(notify_service_sid) # Send a notification notification = service.notifications.create( identity: 'User123', body: 'Hello there!')
from twilio.rest import Client # Twilio credentials and service SID account_sid = 'AC421124bfab3052ad108f3e8c7a119cfb' auth_token = 'AUTH_TOKEN' notify_service_sid = 'IS13c4cce46710eb656ffffdef2c82c589' # Initialize the client client = Client(account_sid, auth_token) service = client.notifications.v1.services(notify_service_sid) # Send the notification notification = service.notifications.create(identity='User123', body='Hello there!')
import com.twilio.sdk.creator.notifications.v1.service.NotificationCreator; import com.twilio.sdk.Twilio; public class SendNotification { // Twilio credentials and service SID public static final String ACCOUNT_SID = "AC421124bfab3052ad108f3e8c7a119cfb"; public static final String AUTH_TOKEN = "AUTH_TOKEN"; public static final String NOTIFY_SERVICE_SID = "IS13c4cce46710eb656ffffdef2c82c589"; public static void main(String[] args) { Twilio.init(ACCOUNT_SID, AUTH_TOKEN); // Send the notification NotificationCreator notification = new NotificationCreator(NOTIFY_SERVICE_SID); notification.setIdentity("User123"); notification.setBody("Hello there!"); System.out.println(notification.execute()); } }
Send bulk SMS messages with a single API request
With Passthrough API, developers can build bulk SMS through a single API request by providing addresses directly in the send request.
View docs
This can be used not just for SMS, but for all the other channels supported by Notify. You can even mix multiple channels in a single request.- Curl
- Ruby
- Python
- Java
curl -X POST https://notify.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications \ --data-urlencode 'ToBinding={"binding_type":"sms", "address":"+15555555555"}' \ --data-urlencode 'ToBinding={"binding_type":"facebook-messenger", "address":"123456789123"}' \ -d 'Body=Hello Bob' \ -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
require 'twilio-ruby' # Get your Account Sid and Auth Token from https://www.twilio.com/console account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' auth_token = 'your_auth_token' client = Twilio::REST::Client.new(account_sid, auth_token) service = client.notify.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') notification = service.notifications.create( to_binding: ['{"binding_type":"sms", "address":"+15555555555"}', '{"binding_type":"facebook-messenger", "address":"123456789123"}'], body: 'Hello Bob' ) puts notification
from twilio.rest import Client # Your Account Sid and Auth Token from twilio.com/console account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" token = "your_auth_token" client = Client(account, token) notification = client.notify.services( "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ).notifications.create( to_binding=[ "{\"binding_type\":\"sms\",\"address\":\"+15555555555\"}", "{\"binding_type\":\"facebook-messenger\",\"address\":\"123456789123\"}", ], body="Hello Bob", ) print(notification)
import java.util.Arrays; import java.util.List; import com.twilio.Twilio; import com.twilio.rest.notify.v1.service.Notification; public class Example { // Find your Account Sid and Token at twilio.com/console public static final String ACCOUNT_SID = "ACCOUNT_SID"; public static final String AUTH_TOKEN = "AUTH_TOKEN"; public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; public static void main(String[] args) { // Initialize the client Twilio.init(ACCOUNT_SID, AUTH_TOKEN); List
toBindings = Arrays.asList( "{\"binding_type\":\"sms\",\"address\":\"+15555555555\"}", "{\"binding_type\":\"facebook-messenger\",\"address\":\"123456789123\"}"); Notification notification = Notification .creator(SERVICE_SID) .setBody("Hello Bob") .setToBinding(toBindings) .create(); System.out.println(notification.getSid()); } }
The Twilio advantage
Communicate reliably
Experience a 99.95% uptime SLA made possible with automated failover and zero maintenance windows.
Operate at scale
Extend the same app you write once to new markets with configurable features for localization and compliance.
Many channels
Use the same platform you know for voice, SMS, video, chat, two-factor authentication, and more.
No shenanigans
Get to market faster with pay‑as‑you‑go pricing, free support, and the freedom to scale up or down without contracts.
Not ready yet? Talk to an expert