# Notification Resource

> \[!CAUTION]
>
> Twilio deprecated Notify in October 2022 and no longer supports it. Learn more about [transitioning off Notify](https://support.twilio.com/hc/en-us/articles/11746930233115-Transitioning-off-Notify).
>
> If you're starting a new project, use [Programmable Messaging](/docs/messaging) for SMS notifications. For push notifications, integrate directly with platform-specific services such as APNs for iOS or FCM for Android. If you've already built on Notify, visit the [transition guide](https://support.twilio.com/hc/en-us/articles/11746930233115-Transitioning-off-Notify) to learn about your options.

The Notification resource sends a notification to existing Bindings or a list of addresses.

You can notify users over these channels:

* APNS for iOS devices
* FCM for Android devices
* SMS and MMS

> \[!WARNING]
>
> It's a good practice to obtain your end users' consent before you send them messages and some jurisdictions might require it by law.
>
> *We recommend that you consult with your legal counsel to make sure that your communications comply with all applicable laws.*
>
> To make sure your messages reach the right people, you should make sure that they have given you their consent to send them messages and that their contact information is current.
>
> Check out the [Twilio Marketplace for Add-ons](/docs/marketplace) from our partners that can help you keep your database up to date.

## Notification Properties

```json
{"type":"object","refName":"notify.v1.service.notification","modelName":"notify_v1_service_notification","properties":{"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^NT[0-9a-fA-F]{32}$","nullable":true,"description":"The unique string that we created to identify the Notification resource."},"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Account](/docs/iam/api/account) that created the Notification resource."},"service_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^IS[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Service](/docs/notify/api/service-resource) the resource is associated with."},"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format."},"identities":{"type":"array","nullable":true,"description":"The list of `identity` values of the Users to notify. We will attempt to deliver notifications only to Bindings with an identity in this list.","x-twilio":{"pii":{"handling":"standard","deleteSla":120}},"items":{"type":"string"}},"tags":{"type":"array","nullable":true,"description":"The tags that select the Bindings to notify. Notifications will be attempted only to Bindings that have all of the tags listed in this property.","x-twilio":{"pii":{"handling":"standard","deleteSla":120}},"items":{"type":"string"}},"segments":{"type":"array","nullable":true,"description":"The list of Segments to notify. The [Segment](/docs/notify/api/segment-resource) resource is deprecated. Use the `tags` property, instead.","items":{"type":"string"}},"priority":{"type":"string","enum":["high","low"],"description":"The priority of the notification. Can be: `low` or `high` and the default is `high`. A value of `low` optimizes the client app's battery consumption; however, notifications may be delivered with unspecified delay. For FCM and GCM, `low` priority is the same as `Normal` priority. For APNS `low` priority is the same as `5`. A value of `high` sends the notification immediately, and can wake up a sleeping device. For FCM and GCM, `high` is the same as `High` priority. For APNS, `high` is a priority `10`. SMS does not support this property.","refName":"notification_enum_priority","modelName":"notification_enum_priority"},"ttl":{"type":"integer","default":0,"description":"How long, in seconds, the notification is valid. Can be an integer between 0 and 2,419,200, which is 4 weeks, the default and the maximum supported time to live (TTL). Delivery should be attempted if the device is offline until the TTL elapses. Zero means that the notification delivery is attempted immediately, only once, and is not stored for future delivery. SMS does not support this property."},"title":{"type":"string","nullable":true,"description":"The notification title. For FCM and GCM, this translates to the `data.twi_title` value. For APNS, this translates to the `aps.alert.title` value. SMS does not support this property. This field is not visible on iOS phones and tablets but appears on Apple Watch and Android devices."},"body":{"type":"string","nullable":true,"description":"The notification text. For FCM and GCM, translates to `data.twi_body`. For APNS, translates to `aps.alert.body`. For SMS, translates to `body`. SMS requires either this `body` value, or `media_urls` attribute defined in the `sms` parameter of the notification.","x-twilio":{"pii":{"handling":"standard","deleteSla":0}}},"sound":{"type":"string","nullable":true,"description":"The name of the sound to be played for the notification. For FCM and GCM, this Translates to `data.twi_sound`.  For APNS, this translates to `aps.sound`.  SMS does not support this property."},"action":{"type":"string","nullable":true,"description":"The actions to display for the notification. For APNS, translates to the `aps.category` value. For GCM, translates to the `data.twi_action` value. For SMS, this parameter is not supported and is omitted from deliveries to those channels."},"data":{"nullable":true,"description":"The custom key-value pairs of the notification's payload. For FCM and GCM, this value translates to `data` in the FCM and GCM payloads. FCM and GCM [reserve certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref) that cannot be used in those channels. For APNS, attributes of `data` are inserted into the APNS payload as custom properties outside of the `aps` dictionary. In all channels, we reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed and are rejected as 400 Bad request with no delivery attempted. For SMS, this parameter is not supported and is omitted from deliveries to those channels."},"apn":{"nullable":true,"description":"The APNS-specific payload that overrides corresponding attributes in the generic payload for APNS Bindings. This property maps to the APNS `Payload` item, therefore the `aps` key must be used to change standard attributes. Adds custom key-value pairs to the root of the dictionary. See the [APNS documentation](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html) for more details. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed."},"gcm":{"nullable":true,"description":"The GCM-specific payload that overrides corresponding attributes in the generic payload for GCM Bindings.  This property maps to the root JSON dictionary. Target parameters `to`, `registration_ids`, and `notification_key` are not allowed. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed."},"fcm":{"nullable":true,"description":"The FCM-specific payload that overrides corresponding attributes in the generic payload for FCM Bindings. This property maps to the root JSON dictionary. See the [FCM documentation](https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream) for more details. Target parameters `to`, `registration_ids`, `condition`, and `notification_key` are not allowed in this parameter. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. FCM also [reserves certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref), which cannot be used in that channel."},"sms":{"nullable":true,"description":"The SMS-specific payload that overrides corresponding attributes in the generic payload for SMS Bindings.  Each attribute in this value maps to the corresponding `form` parameter of the Twilio [Message](/docs/sms/api/message-resource) resource.  These parameters of the Message resource are supported in snake case format: `body`, `media_urls`, `status_callback`, and `max_price`.  The `status_callback` parameter overrides the corresponding parameter in the messaging service, if configured. The `media_urls` property expects a JSON array."},"facebook_messenger":{"nullable":true,"description":"Deprecated."},"alexa":{"nullable":true,"description":"Deprecated."}}}
```

## Create a Notification resource

`POST https://notify.twilio.com/v1/Services/{ServiceSid}/Notifications`

Creating a **Notification** resource sends a notification to existing Bindings or to addresses provided in the request.

### Send a Notification to existing Bindings

Set `Identity` or `Tag` to specify the stored Bindings to notify. To notify all available stored Bindings, set `Tag` to *all.* If both `Identity` and `Tag` have values, only the Bindings that match both will be notified.

Check out the below examples which show you how to

* [Send a notification to an existing Binding by its Identity](#code-send-a-notification-to-existing-bindings-identity)
* [Send a notification to an existing Binding by its Tags](#code-send-a-notification-to-existing-bindings-tag)
* [Send a notification to existing Binding by its Identity and its Tags](#code-send-a-notification-to-existing-bindings-identity-and-tag)

### Send a Notification to Bindings in the request

Set `ToBinding` to the JSON object that defines the Bindings to notify. Check out the below example which shows you how to

* [Send a notification to Bindings defined in the request](#code-send-a-notification-to-bindings-in-the-request)

### Send a Notification tailored to the specific channel

Define channel-specific features in the request to tailor the notification to the channel. Check out the below example

* [Send custom notifications by channel](#code-send-custom-notifications-by-channel) which shows you how to apply channel-specific features to customize the notification content to the channel

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the [Service](/docs/notify/api/service-resource) to create the resource under.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^IS[0-9a-fA-F]{32}$"},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"CreateNotificationRequest","properties":{"Body":{"type":"string","description":"The notification text. For FCM and GCM, translates to `data.twi_body`. For APNS, translates to `aps.alert.body`. For SMS, translates to `body`. SMS requires either this `body` value, or `media_urls` attribute defined in the `sms` parameter of the notification.","x-twilio":{"pii":{"handling":"standard","deleteSla":0}}},"Priority":{"type":"string","enum":["high","low"],"description":"The priority of the notification. Can be: `low` or `high` and the default is `high`. A value of `low` optimizes the client app's battery consumption; however, notifications may be delivered with unspecified delay. For FCM and GCM, `low` priority is the same as `Normal` priority. For APNS `low` priority is the same as `5`. A value of `high` sends the notification immediately, and can wake up a sleeping device. For FCM and GCM, `high` is the same as `High` priority. For APNS, `high` is a priority `10`. SMS does not support this property.","refName":"notification_enum_priority","modelName":"notification_enum_priority"},"Ttl":{"type":"integer","description":"How long, in seconds, the notification is valid. Can be an integer between 0 and 2,419,200, which is 4 weeks, the default and the maximum supported time to live (TTL). Delivery should be attempted if the device is offline until the TTL elapses. Zero means that the notification delivery is attempted immediately, only once, and is not stored for future delivery. SMS does not support this property."},"Title":{"type":"string","description":"The notification title. For FCM and GCM, this translates to the `data.twi_title` value. For APNS, this translates to the `aps.alert.title` value. SMS does not support this property. This field is not visible on iOS phones and tablets but appears on Apple Watch and Android devices."},"Sound":{"type":"string","description":"The name of the sound to be played for the notification. For FCM and GCM, this Translates to `data.twi_sound`.  For APNS, this translates to `aps.sound`.  SMS does not support this property."},"Action":{"type":"string","description":"The actions to display for the notification. For APNS, translates to the `aps.category` value. For GCM, translates to the `data.twi_action` value. For SMS, this parameter is not supported and is omitted from deliveries to those channels."},"Data":{"description":"The custom key-value pairs of the notification's payload. For FCM and GCM, this value translates to `data` in the FCM and GCM payloads. FCM and GCM [reserve certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref) that cannot be used in those channels. For APNS, attributes of `data` are inserted into the APNS payload as custom properties outside of the `aps` dictionary. In all channels, we reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed and are rejected as 400 Bad request with no delivery attempted. For SMS, this parameter is not supported and is omitted from deliveries to those channels."},"Apn":{"description":"The APNS-specific payload that overrides corresponding attributes in the generic payload for APNS Bindings. This property maps to the APNS `Payload` item, therefore the `aps` key must be used to change standard attributes. Adds custom key-value pairs to the root of the dictionary. See the [APNS documentation](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html) for more details. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed."},"Gcm":{"description":"The GCM-specific payload that overrides corresponding attributes in the generic payload for GCM Bindings.  This property maps to the root JSON dictionary. See the [GCM documentation](https://firebase.google.com/docs/cloud-messaging/http-server-ref) for more details. Target parameters `to`, `registration_ids`, and `notification_key` are not allowed. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. GCM also [reserves certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref)."},"Sms":{"description":"The SMS-specific payload that overrides corresponding attributes in the generic payload for SMS Bindings.  Each attribute in this value maps to the corresponding `form` parameter of the Twilio [Message](/docs/sms/quickstart) resource.  These parameters of the Message resource are supported in snake case format: `body`, `media_urls`, `status_callback`, and `max_price`.  The `status_callback` parameter overrides the corresponding parameter in the messaging service, if configured. The `media_urls` property expects a JSON array."},"FacebookMessenger":{"description":"Deprecated."},"Fcm":{"description":"The FCM-specific payload that overrides corresponding attributes in the generic payload for FCM Bindings. This property maps to the root JSON dictionary. See the [FCM documentation](https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream) for more details. Target parameters `to`, `registration_ids`, `condition`, and `notification_key` are not allowed in this parameter. We reserve keys that start with `twi_` for future use. Custom keys that start with `twi_` are not allowed. FCM also [reserves certain keys](https://firebase.google.com/docs/cloud-messaging/http-server-ref), which cannot be used in that channel."},"Segment":{"type":"array","description":"The Segment resource is deprecated. Use the `tag` parameter, instead.","items":{"type":"string"}},"Alexa":{"description":"Deprecated."},"ToBinding":{"type":"array","description":"The destination address specified as a JSON string.  Multiple `to_binding` parameters can be included but the total size of the request entity should not exceed 1MB. This is typically sufficient for 10,000 phone numbers.","items":{"type":"string"}},"DeliveryCallbackUrl":{"type":"string","description":"URL to send webhooks."},"Identity":{"type":"array","description":"The `identity` value that uniquely identifies the new resource's [User](/docs/chat/rest/user-resource) within the [Service](/docs/notify/api/service-resource). Delivery will be attempted only to Bindings with an Identity in this list. No more than 20 items are allowed in this list.","items":{"type":"string"}},"Tag":{"type":"array","description":"A tag that selects the Bindings to notify. Repeat this parameter to specify more than one tag, up to a total of 5 tags. The implicit tag `all` is available to notify all Bindings in a Service instance. Similarly, the implicit tags `apn`, `fcm`, `gcm`, `sms` and `facebook-messenger` are available to notify all Bindings in a specific channel.","items":{"type":"string"}}}},"examples":{"create":{"value":{"lang":"json","value":"{\n  \"Identity\": \"jing\",\n  \"Body\": \"body\",\n  \"Priority\": \"high\",\n  \"Title\": \"test\",\n  \"DeliveryCallbackUrl\": \"hello\"\n}","meta":"","code":"{\n  \"Identity\": \"jing\",\n  \"Body\": \"body\",\n  \"Priority\": \"high\",\n  \"Title\": \"test\",\n  \"DeliveryCallbackUrl\": \"hello\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"Identity\"","#7EE787"],[":","#C9D1D9"]," ",["\"jing\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Body\"","#7EE787"],[":","#C9D1D9"]," ",["\"body\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Priority\"","#7EE787"],[":","#C9D1D9"]," ",["\"high\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Title\"","#7EE787"],[":","#C9D1D9"]," ",["\"test\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"DeliveryCallbackUrl\"","#7EE787"],[":","#C9D1D9"]," ",["\"hello\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}},"createDirectNotification":{"value":{"lang":"json","value":"{\n  \"ToBinding\": \"{\\\"binding_type\\\":\\\"apn\\\", \\\"address\\\":\\\"0efb85d06b3cc1bf290545fde4775a929d46b3541aaa4aa167e420b6c8b0ff15\\\"}\",\n  \"Body\": \"body\"\n}","meta":"","code":"{\n  \"ToBinding\": \"{\\\"binding_type\\\":\\\"apn\\\", \\\"address\\\":\\\"0efb85d06b3cc1bf290545fde4775a929d46b3541aaa4aa167e420b6c8b0ff15\\\"}\",\n  \"Body\": \"body\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"ToBinding\"","#7EE787"],[":","#C9D1D9"]," ",["\"{","#A5D6FF"],["\\\"","#79C0FF"],["binding_type","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"],["\\\"","#79C0FF"],["apn","#A5D6FF"],["\\\"","#79C0FF"],[",","#A5D6FF"]," ",["\\\"","#79C0FF"],["address","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"],["\\\"","#79C0FF"],["0efb85d06b3cc1bf290545fde4775a929d46b3541aaa4aa167e420b6c8b0ff15","#A5D6FF"],["\\\"","#79C0FF"],["}\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Body\"","#7EE787"],[":","#C9D1D9"]," ",["\"body\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{"Identity":["Tag"],"Tag":["Identity"]}}
```

Send a Notification to existing Bindings (Identity)

```js
// NOTE: This example uses the next generation Twilio helper library - for more
// information on how to download and install this version, visit
// https://www.twilio.com/docs/libraries/node
// To set up environmental variables, see http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const Twilio = require('twilio');

const client = new Twilio(accountSid, authToken);

const service = client.notify.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service.notifications
  .create({
    identity: '00000001',
    body: 'Hello Bob',
  })
  .then(notification => {
    console.log(notification);
  })
  .catch(error => {
    console.log(error);
  })
  .done();
```

```py
# NOTE: This example uses the next generation Twilio helper library - for more
# information on how to download and install this version, visit
# https://www.twilio.com/docs/libraries/python
import os
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
# To set up environmental variables, see http://twil.io/secure
account = os.environ['TWILIO_ACCOUNT_SID']
token = os.environ['TWILIO_AUTH_TOKEN']
client = Client(account, token)

notification = client.notify.services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \
    .notifications.create(identity="00000001", body="Hello Bob")

print(notification)
```

```cs
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Notify.V1.Service;

public class Example
{
    public static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        // To set up environmental variables, see http://twil.io/secure
        const string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        const string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");
        const string serviceSid = Environment.GetEnvironmentVariable("TWILIO_SERVICE_SID");

        TwilioClient.Init(accountSid, authToken);

        var notification = NotificationResource.Create(
            serviceSid,
            identity: new List<string> { "00000001" },
            body: "Hello Bob");

        Console.WriteLine(notification.Sid);
    }
}
```

```java
// NOTE: This example uses the next generation Twilio helper library - for more
// information on how to download and install this version, visit
// https://www.twilio.com/docs/libraries/java
import com.twilio.Twilio;
import com.twilio.rest.notify.v1.service.Notification;

public class Example {
  // Get your Account SID and Auth Token from https://twilio.com/console
  // To set up environment variables, see http://twil.io/secure
  public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
  public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

  public static final String SERVICE_SID = System.getenv("TWILIO_SERVICE_SID");

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    Notification notification = Notification
        .creator(SERVICE_SID)
        .setBody("Hello Bob")
        .setIdentity("00000001")
        .create();

    System.out.println(notification.getSid());
  }
}
```

```php
<?php
// NOTE: This example uses the next generation Twilio helper library - for more
// information on how to download and install this version, visit
// https://www.twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Your Account SID and Auth Token from https://www.twilio.com/console
// To set up environmental variables, see http://twil.io/secure
$accountSid = getenv('TWILIO_ACCOUNT_SID');
$authToken = getenv('TWILIO_AUTH_TOKEN');

$serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

// Initialize the client
$client = new Client($accountSid, $authToken);

// Create a notification
$notification = $client
    ->notify->services($serviceSid)
    ->notifications->create([
        "identity" => "00000001",
        "body" => "Hello Bob"
    ]);

echo $notification->body; // => Hello Bob
```

```rb
# Download the Ruby helper library from twilio.com/docs/libraries/ruby
require 'twilio-ruby'

# Get your Account Sid and Auth Token from https://www.twilio.com/console
# To set up environmental variables, see http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']

client = Twilio::REST::Client.new(account_sid, auth_token)

service = client.notify.v1.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')

notification = service.notifications.create(
  identity: '00000001',
  body: 'Hello Bob'
)

puts notification
```

```bash
curl -X POST https://notify.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications \
    -d 'Identity=00000001' \
    -d 'Body=Hello Bob' \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
```

```json
{
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "sid": "NTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "date_created": "2015-08-26T00:07:12Z",
  "identities": ["00000001"],
  "tags": [],
  "priority": "high",
  "ttl": 2419200,
  "title": null,
  "body": "Hello Bob",
  "sound": null,
  "action": null,
  "data": null,
  "apn": null,
  "gcm": null,
  "sms": null,
  "fcm": null
}
```

Send a Notification to existing Bindings (Tag)

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function createNotification() {
  const notification = await client.notify.v1
    .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .notifications.create({
      body: '"Hello new user!"',
      tag: ["new_user"],
    });

  console.log(notification.sid);
}

createNotification();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

notification = client.notify.v1.services(
    "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).notifications.create(tag=["new_user"], body='"Hello new user!"')

print(notification.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Notify.V1.Service;
using System.Threading.Tasks;
using System.Collections.Generic;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var notification = await NotificationResource.CreateAsync(
            tag: new List<string> { "new_user" },
            body: "\"Hello new user!\"",
            pathServiceSid: "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

        Console.WriteLine(notification.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import java.util.Arrays;
import com.twilio.Twilio;
import com.twilio.rest.notify.v1.service.Notification;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Notification notification = Notification.creator("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
                                        .setTag(Arrays.asList("new_user"))
                                        .setBody("\"Hello new user!\"")
                                        .create();

        System.out.println(notification.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	notify "github.com/twilio/twilio-go/rest/notify/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &notify.CreateNotificationParams{}
	params.SetTag([]string{
		"new_user",
	})
	params.SetBody("\"Hello new user!\"")

	resp, err := client.NotifyV1.CreateNotification("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$notification = $twilio->notify->v1
    ->services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->notifications->create([
        "tag" => ["new_user"],
        "body" => "\"Hello new user!\"",
    ]);

print $notification->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

notification = @client
               .notify
               .v1
               .services('ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
               .notifications
               .create(
                 tag: [
                   'new_user'
                 ],
                 body: '"Hello new user!"'
               )

puts notification.sid
```

```bash
EXCLAMATION_MARK='!'
# Install the twilio-cli from https://twil.io/cli

twilio api:notify:v1:services:notifications:create \
   --service-sid ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --tag new_user \
   --body "\"Hello new user$EXCLAMATION_MARK\""
```

```bash
EXCLAMATION_MARK='!'
curl -X POST "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications" \
--data-urlencode "Tag=new_user" \
--data-urlencode "Body=\"Hello new user$EXCLAMATION_MARK\"" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "NTb8021351170b4e1286adaac3fdd6d082",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2016-03-24T23:42:28Z",
  "identities": [
    "jing"
  ],
  "tags": [],
  "segments": [],
  "priority": "high",
  "ttl": 2419200,
  "title": "test",
  "body": "\"Hello new user!\"",
  "sound": null,
  "action": null,
  "data": null,
  "apn": null,
  "fcm": null,
  "gcm": null,
  "sms": null,
  "facebook_messenger": null,
  "alexa": null
}
```

Send a Notification to existing Bindings (Identity and Tag)

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function createNotification() {
  const notification = await client.notify.v1
    .services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .notifications.create({
      body: '"Hello, Charlie!"',
      identity: ["00000001"],
      tag: ["preferred_device"],
    });

  console.log(notification.sid);
}

createNotification();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

notification = client.notify.v1.services(
    "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).notifications.create(
    identity=["00000001"], tag=["preferred_device"], body='"Hello, Charlie!"'
)

print(notification.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Notify.V1.Service;
using System.Threading.Tasks;
using System.Collections.Generic;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var notification = await NotificationResource.CreateAsync(
            identity: new List<string> { "00000001" },
            tag: new List<string> { "preferred_device" },
            body: "\"Hello, Charlie!\"",
            pathServiceSid: "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

        Console.WriteLine(notification.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import java.util.Arrays;
import com.twilio.Twilio;
import com.twilio.rest.notify.v1.service.Notification;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Notification notification = Notification.creator("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
                                        .setIdentity(Arrays.asList("00000001"))
                                        .setTag(Arrays.asList("preferred_device"))
                                        .setBody("\"Hello, Charlie!\"")
                                        .create();

        System.out.println(notification.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	notify "github.com/twilio/twilio-go/rest/notify/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &notify.CreateNotificationParams{}
	params.SetIdentity([]string{
		"00000001",
	})
	params.SetTag([]string{
		"preferred_device",
	})
	params.SetBody("\"Hello, Charlie!\"")

	resp, err := client.NotifyV1.CreateNotification("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$notification = $twilio->notify->v1
    ->services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->notifications->create([
        "identity" => ["00000001"],
        "tag" => ["preferred_device"],
        "body" => "\"Hello, Charlie!\"",
    ]);

print $notification->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

notification = @client
               .notify
               .v1
               .services('ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
               .notifications
               .create(
                 identity: [
                   '00000001'
                 ],
                 tag: [
                   'preferred_device'
                 ],
                 body: '"Hello, Charlie!"'
               )

puts notification.sid
```

```bash
EXCLAMATION_MARK='!'
# Install the twilio-cli from https://twil.io/cli

twilio api:notify:v1:services:notifications:create \
   --service-sid ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --identity 00000001 \
   --tag preferred_device \
   --body "\"Hello, Charlie$EXCLAMATION_MARK\""
```

```bash
EXCLAMATION_MARK='!'
curl -X POST "https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications" \
--data-urlencode "Identity=00000001" \
--data-urlencode "Tag=preferred_device" \
--data-urlencode "Body=\"Hello, Charlie$EXCLAMATION_MARK\"" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "NTb8021351170b4e1286adaac3fdd6d082",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2016-03-24T23:42:28Z",
  "identities": [
    "jing"
  ],
  "tags": [],
  "segments": [],
  "priority": "high",
  "ttl": 2419200,
  "title": "test",
  "body": "\"Hello, Charlie!\"",
  "sound": null,
  "action": null,
  "data": null,
  "apn": null,
  "fcm": null,
  "gcm": null,
  "sms": null,
  "facebook_messenger": null,
  "alexa": null
}
```

> \[!NOTE]
>
> You can send notifications to addresses without storing them by using the `toBinding` parameter. However, the total size of the request entity shouldn't exceed `1MB`. This is typically sufficient for 10,000 phone numbers.

Send a Notification to Bindings in the request

```js
// NOTE: This example uses the next generation Twilio helper library - for more
// information on how to download and install this version, visit
// https://www.twilio.com/docs/libraries/node
// To set up environmental variables, see http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const Twilio = require('twilio');

const client = new Twilio(accountSid, authToken);

const service = client.notify.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

service.notifications
  .create({
    toBinding: [
      JSON.stringify({
        binding_type: 'sms',
        address: '+15555555555',
      }),
      JSON.stringify({
        binding_type: 'facebook-messenger',
        address: '123456789123',
      }),
    ],
    body: 'Hello Bob',
  })
  .then(notification => {
    console.log(notification);
  })
  .catch(error => {
    console.log(error);
  })
  .done();
```

```py
# NOTE: This example uses the next generation Twilio helper library - for more
# information on how to download and install this version, visit
# https://www.twilio.com/docs/libraries/python
import os
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
# To set up environmental variables, see http://twil.io/secure
account = os.environ['TWILIO_ACCOUNT_SID']
token = os.environ['TWILIO_AUTH_TOKEN']
client = Client(account, token)

binding1 = '{"binding_type":"sms","address":"+15555555555"}'
binding2 = '{"binding_type":' + \
    '"facebook-messenger","address":"123456789123"}'

notification = client.notify.services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \
    .notifications.create(to_binding=[binding1, binding2], body="Hello Bob")

print(notification)
```

```cs
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Notify.V1.Service;

public class Example
{
    public static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        // To set up environmental variables, see http://twil.io/secure
        const string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        const string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");
        const string serviceSid = Environment.GetEnvironmentVariable("TWILIO_SERVICE_SID");

        TwilioClient.Init(accountSid, authToken);

        var notification = NotificationResource.Create(
            serviceSid,
            toBinding: new List<string> { "{\"binding_type\":\"sms\",\"address\":\"+15555555555\"}",
            "{\"binding_type\":\"facebook-messenger\",\"address\":\"123456789123\"}" },
            body: "Hello Bob");

        Console.WriteLine(notification.Sid);
    }
}
```

```java
// NOTE: This example uses the next generation Twilio helper library - for more
// information on how to download and install this version, visit
// https://www.twilio.com/docs/libraries/java
import java.util.Arrays;
import java.util.List;
import com.twilio.Twilio;
import com.twilio.rest.notify.v1.service.Notification;

public class Example {
  // Get your Account SID and Auth Token from https://twilio.com/console
  // To set up environment variables, see http://twil.io/secure
  public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
  public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

  public static final String SERVICE_SID = System.getenv("TWILIO_SERVICE_SID");

  public static void main(String[] args) {
    // Initialize the client
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    List<String> 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());
  }
}
```

```php
<?php
// NOTE: This example uses the next generation Twilio helper library - for more
// information on how to download and install this version, visit
// https://www.twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Your Account SID and Auth Token from https://www.twilio.com/console
// To set up environmental variables, see http://twil.io/secure
$accountSid = getenv('TWILIO_ACCOUNT_SID');
$authToken = getenv('TWILIO_AUTH_TOKEN');

$serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

// Initialize the client
$client = new Client($accountSid, $authToken);

// Create a notification
$notification = $client
    ->notify->services($serviceSid)
    ->notifications->create([
        "toBinding" => [
            '{"binding_type":"sms", "address":"+15555555555"}',
            '{"binding_type":"facebook-messenger", "address":"123456789123"}'
        ],
        "body" => "Hello Bob"
    ]);

echo $notification->body; // => Hello Bob
```

```rb
# Download the Ruby helper library from twilio.com/docs/libraries/ruby
require 'twilio-ruby'

# Get your Account Sid and Auth Token from https://www.twilio.com/console
# To set up environmental variables, see http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_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
```

```bash
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'
```

```json
{
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "sid": "NTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "date_created": "2015-08-26T00:07:12Z",
  "toBindings": [{
      "binding_type":"sms",
      "address":"+15555555555"
    },{
      "binding_type":"facebook-messenger",
      "address":"123456789123"
    }],
  "identities": [],
  "tags": [],
  "priority": "high",
  "ttl": 2419200,
  "title": null,
  "body": "Hello Bob",
  "sound": null,
  "action": null,
  "data": null,
  "apn": null,
  "gcm": null,
  "sms": null,
  "fcm": null
}
```

> \[!NOTE]
>
> There is a list of available keys for building notification messages for iOS and Android. You can pass any of the available keys for[Apple](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification#2943363) or[Google](https://firebase.google.com/docs/cloud-messaging/http-server-ref#data) on the APNs or FCM parameters. You can also combine these (as well as the `sms` key) all in the same Notification API request, as shown in the `Send custom notifications by channel` code sample.

Send custom notifications by channel

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function createNotification() {
  const notification = await client.notify.v1
    .services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    .notifications.create({
      apn: {
        aps: {
          alert: {
            title: "Short title for Watch.",
          },
        },
      },
      body: "This is the body for all Bindings",
      data: {
        custom_key1: "custom value 1",
        custom_key2: "custom value 2",
      },
      fcm: {
        notification: {
          title: "New alert",
          body: "Hello Bob!",
        },
      },
      identity: ["00000001"],
      title: "Generic loooooooong title for all Bindings",
    });

  console.log(notification.sid);
}

createNotification();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

notification = client.notify.v1.services(
    "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
).notifications.create(
    apn={"aps": {"alert": {"title": "Short title for Watch."}}},
    body="This is the body for all Bindings",
    data={"custom_key1": "custom value 1", "custom_key2": "custom value 2"},
    fcm={"notification": {"title": "New alert", "body": "Hello Bob!"}},
    identity=["00000001"],
    title="Generic loooooooong title for all Bindings",
)

print(notification.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Notify.V1.Service;
using System.Threading.Tasks;
using System.Collections.Generic;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var notification = await NotificationResource.CreateAsync(
            apn: new Dictionary<
                string,
                Object>() { { "aps", new Dictionary<string, Object>() { { "alert", new Dictionary<string, Object>() { { "title", "Short title for Watch." } } } } } },
            body: "This is the body for all Bindings",
            data: new Dictionary<
                string,
                Object>() { { "custom_key1", "custom value 1" }, { "custom_key2", "custom value 2" } },
            fcm: new Dictionary<
                string,
                Object>() { { "notification", new Dictionary<string, Object>() { { "title", "New alert" }, { "body", "Hello Bob!" } } } },
            identity: new List<string> { "00000001" },
            title: "Generic loooooooong title for all Bindings",
            pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

        Console.WriteLine(notification.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import java.util.Arrays;
import java.util.HashMap;
import com.twilio.Twilio;
import com.twilio.rest.notify.v1.service.Notification;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Notification notification = Notification.creator("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                        .setApn(new HashMap<String, Object>() {
                                            {
                                                put("aps", new HashMap<String, Object>() {
                                                    {
                                                        put("alert", new HashMap<String, Object>() {
                                                            {
                                                                put("title", "Short title for Watch.");
                                                            }
                                                        });
                                                    }
                                                });
                                            }
                                        })
                                        .setBody("This is the body for all Bindings")
                                        .setData(new HashMap<String, Object>() {
                                            {
                                                put("custom_key1", "custom value 1");
                                                put("custom_key2", "custom value 2");
                                            }
                                        })
                                        .setFcm(new HashMap<String, Object>() {
                                            {
                                                put("notification", new HashMap<String, Object>() {
                                                    {
                                                        put("title", "New alert");
                                                        put("body", "Hello Bob!");
                                                    }
                                                });
                                            }
                                        })
                                        .setIdentity(Arrays.asList("00000001"))
                                        .setTitle("Generic loooooooong title for all Bindings")
                                        .create();

        System.out.println(notification.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	notify "github.com/twilio/twilio-go/rest/notify/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &notify.CreateNotificationParams{}
	params.SetApn(map[string]interface{}{
		"aps": map[string]interface{}{
			"alert": map[string]interface{}{
				"title": "Short title for Watch.",
			},
		},
	})
	params.SetBody("This is the body for all Bindings")
	params.SetData(map[string]interface{}{
		"custom_key1": "custom value 1",
		"custom_key2": "custom value 2",
	})
	params.SetFcm(map[string]interface{}{
		"notification": map[string]interface{}{
			"title": "New alert",
			"body":  "Hello Bob!",
		},
	})
	params.SetIdentity([]string{
		"00000001",
	})
	params.SetTitle("Generic loooooooong title for all Bindings")

	resp, err := client.NotifyV1.CreateNotification("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$notification = $twilio->notify->v1
    ->services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->notifications->create([
        "apn" => [
            "aps" => [
                "alert" => [
                    "title" => "Short title for Watch.",
                ],
            ],
        ],
        "body" => "This is the body for all Bindings",
        "data" => [
            "custom_key1" => "custom value 1",
            "custom_key2" => "custom value 2",
        ],
        "fcm" => [
            "notification" => [
                "title" => "New alert",
                "body" => "Hello Bob!",
            ],
        ],
        "identity" => ["00000001"],
        "title" => "Generic loooooooong title for all Bindings",
    ]);

print $notification->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

notification = @client
               .notify
               .v1
               .services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
               .notifications
               .create(
                 apn: {
                   'aps' => {
                     'alert' => {
                       'title' => 'Short title for Watch.'
                     }
                   }
                 },
                 body: 'This is the body for all Bindings',
                 data: {
                   'custom_key1' => 'custom value 1',
                   'custom_key2' => 'custom value 2'
                 },
                 fcm: {
                   'notification' => {
                     'title' => 'New alert',
                     'body' => 'Hello Bob!'
                   }
                 },
                 identity: [
                   '00000001'
                 ],
                 title: 'Generic loooooooong title for all Bindings'
               )

puts notification.sid
```

```bash
EXCLAMATION_MARK='!'
# Install the twilio-cli from https://twil.io/cli

twilio api:notify:v1:services:notifications:create \
   --service-sid ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
   --apn "{\"aps\":{\"alert\":{\"title\":\"Short title for Watch.\"}}}" \
   --body "This is the body for all Bindings" \
   --data "{\"custom_key1\":\"custom value 1\",\"custom_key2\":\"custom value 2\"}" \
   --fcm "{\"notification\":{\"title\":\"New alert\",\"body\":\"Hello Bob$EXCLAMATION_MARK\"}}" \
   --identity 00000001 \
   --title "Generic loooooooong title for all Bindings"
```

```bash
EXCLAMATION_MARK='!'

APN_OBJ=$(cat << EOF
{
  "aps": {
    "alert": {
      "title": "Short title for Watch."
    }
  }
}
EOF
)
DATA_OBJ=$(cat << EOF
{
  "custom_key1": "custom value 1",
  "custom_key2": "custom value 2"
}
EOF
)
FCM_OBJ=$(cat << EOF
{
  "notification": {
    "title": "New alert",
    "body": "Hello Bob$EXCLAMATION_MARK"
  }
}
EOF
)
curl -X POST "https://notify.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications" \
--data-urlencode "Apn=$APN_OBJ" \
--data-urlencode "Body=This is the body for all Bindings" \
--data-urlencode "Data=$DATA_OBJ" \
--data-urlencode "Fcm=$FCM_OBJ" \
--data-urlencode "Identity=00000001" \
--data-urlencode "Title=Generic loooooooong title for all Bindings" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "NTb8021351170b4e1286adaac3fdd6d082",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "date_created": "2016-03-24T23:42:28Z",
  "identities": [
    "jing"
  ],
  "tags": [],
  "segments": [],
  "priority": "high",
  "ttl": 2419200,
  "title": "Generic loooooooong title for all Bindings",
  "body": "This is the body for all Bindings",
  "sound": null,
  "action": null,
  "data": {
    "custom_key1": "custom value 1",
    "custom_key2": "custom value 2"
  },
  "apn": {
    "aps": {
      "alert": {
        "title": "Short title for Watch."
      }
    }
  },
  "fcm": {
    "notification": {
      "title": "New alert",
      "body": "Hello Bob!"
    }
  },
  "gcm": null,
  "sms": null,
  "facebook_messenger": null,
  "alexa": null
}
```

### ToBinding attributes

| Name          | Description                                                                                                                         |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| binding\_type | The channel to use. Possible values: `sms`, `apn`, `fcm`.                                                                           |
| address       | The destination address. For SMS, it is the phone number in E.164 format. For APNS and FCM, it is the device or registration token. |

### Customize notification by channel

Notifications can be tailored to each notification channel to take advantage of channel-specific features or to customize the content to each channel.

The channel-specific payload of a notification can be provided by adding a parameter whose name is the BindingType and the value is the channel specific payload in a JSON object. The example [Send custom notifications by channel](#code-send-custom-notifications-by-channel) includes several such objects.

These channels support channel-specific payloads:

* APNS
* FCM
* SMS

The channel-specific content specified in this parameter can add a new property for the channel or replace the value in an existing property, but it cannot remove a property.

The example [Send custom notifications by channel](#code-send-custom-notifications-by-channel) sends a notification to all Bindings with Identity `00000001`. A generic `Title` is specified and will be used for `sms` binding and specifically for `fcm` and `apn` binding types a payload with `title` and `body` are also added, which will override the generic `Title`.

### Unrecoverable channel errors

When the underlying notification channel indicates an unrecoverable error, it is usually because there's a problem with the Binding. To ensure your database contains only valid Bindings, we delete the Bindings that return unrecoverable errors.

The following errors are unrecoverable.

| Channel | Error                                                          |
| ------- | -------------------------------------------------------------- |
| APNS    | APNS response status code 410 with error string "Unregistered" |
| APNS    | Address in invalid format                                      |
| FCM     | Firebase response status code 200 + error:NotRegistered        |
| FCM     | Firebase response status code 200 + error:InvalidRegistration  |
| FCM     | Firebase response status code 200 + error:MismatchSenderId     |
| SMS     | 21604 - 'To' phone number is blank                             |
