Notify API Binding Resource
We are no longer allowing customers to onboard to Notify. We intend to deprecate the Notify product on April 25, 2024. Learn more in our Notify API End of Life Notice. We prepared this Transition Guide to assist in supporting your push notification use cases.
The Binding resource binds an identity
to the address
used by a notification channel. For example, iOS push notifications use an APNS device token for their address and SMS uses a phone number. Creating a Binding allows you to send notifications by referring to an identity
rather than a specific device. You can create up to 20 Bindings with the same identity
in a given Service.
You can add tags
to a Binding that describe related Bindings. For example, you can add a tag to the Bindings of a user's preferred devices and then refer to that tag to notify them on only their preferred devices. Read more about Sending Notifications.
Do not use Personally Identifiable Information (PII) for identity.
The systems that process this parameter assume it does not contain PII.
You should use a GUID or other pseudonymized identifier for identity
instead of PII such as a person's name, home address, email or phone number. If you identify your users with PII, we recommend creating a pseudonymized identifier from their PII, for example by hashing or encrypting it, before you use it for identity
.
You can read more about how we process your data in our privacy policy.
Make sure you have consent from users before storing their device's address.
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 from our partners that can help you keep your database up to date.
Address for push notifications
While the address
of an SMS message is the phone number, the address
to use for push notifications is obtained by your client-side mobile app. Learn how to:
- Register for Notifications on iOS to obtain the APNS address, called a device token.
- Register for Notifications on Android to obtain the FCM address, called a registration token.
Binding properties
Resource Properties in REST API format | |
---|---|
sid
|
The unique string that we created to identify the Binding resource. |
account_sid
|
The SID of the Account that created the Binding resource. |
service_sid
|
The SID of the Service the resource is associated with. |
credential_sid
|
The SID of the Credential resource to be used to send notifications to this Binding. If present, this overrides the Credential specified in the Service resource. Applicable only to |
date_created
|
The date and time in GMT when the resource was created specified in RFC 2822 format. |
date_updated
|
The date and time in GMT when the resource was last updated specified in RFC 2822 format. |
notification_protocol_version
|
The protocol version to use to send the notification. This defaults to the value of |
endpoint
|
Deprecated. |
identity
|
The |
binding_type
|
The transport technology to use for the Binding. Can be: |
address
|
The channel-specific address. For APNS, the device token. For FCM and GCM, the registration token. For SMS, a phone number in E.164 format. For Facebook Messenger, the Messenger ID of the user or a phone number in E.164 format. |
tags
|
The list of tags associated with this Binding. Tags can be used to select the Bindings to use when sending a notification. Maximum 20 tags are allowed. |
url
|
The absolute URL of the Binding resource. |
links
|
The URLs of related resources. |
Endpoint (DEPRECATED)
We deprecated endpoint
and trust the push-channel provider (such as APNS or Firebase) to let us know when an app has changed or invalidated the device token used as the address
.
The endpoint
property was used to uniquely identify push notification Bindings when the app installation's address
changed, such as when the device token changed in an iOS app. You can still include an Endpoint
parameter when you create a Binding; however, it will be ignored.
Create a Binding resource
https://notify.twilio.com/v1/Services/{ServiceSid}/Bindings
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Service to create the resource under. |
identity
Required
|
The |
binding_type
Required
|
The transport technology to use for the Binding. Can be: |
address
Required
|
The channel-specific address. For APNS, the device token. For FCM and GCM, the registration token. For SMS, a phone number in E.164 format. For Facebook Messenger, the Messenger ID of the user or a phone number in E.164 format. |
tag
Optional
|
A tag that can be used to select the Bindings to notify. Repeat this parameter to specify more than one tag, up to a total of 20 tags. |
notification_protocol_version
Optional
|
The protocol version to use to send the notification. This defaults to the value of |
credential_sid
Optional
|
The SID of the Credential resource to be used to send notifications to this Binding. If present, this overrides the Credential specified in the Service resource. Applies to only |
endpoint
Optional
|
Deprecated. |
Example 1
Existing Bindings with the same Address are replaced
If the Service already has a Binding with the same Address
as specified in the create request, the Binding being created replaces the existing Binding.
The new Binding replaces the existing one under these conditions to prevent leaking notifications between users when, for example, a new user logs into your app on a device that has already been registered to another user.
To register the same Address twice, such as when someone is a buyer and a seller at the same time in a marketplace, we recommend creating separate Service instances, such as one for buyers and one for sellers.
Endpoint (DEPRECATED)
We deprecated endpoint
and trust the push-channel provider (such as APNS or Firebase) to let us know when an app has changed or invalidated the device token used as the address
.
The endpoint
property was used to uniquely identify push notification Bindings when the app installation's address
changed, such as when the device token changed in an iOS app. You can still include an Endpoint
parameter when you create a Binding; however, it will be ignored.
Fetch a Binding resource
https://notify.twilio.com/v1/Services/{ServiceSid}/Bindings/{Sid}
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Service to fetch the resource from. |
sid
Path
|
The Twilio-provided string that uniquely identifies the Binding resource to fetch. |
Example 1
Read multiple Binding resources
https://notify.twilio.com/v1/Services/{ServiceSid}/Bindings
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Service to read the resource from. |
start_date
Optional
|
Only include usage that has occurred on or after this date. Specify the date in GMT and format as |
end_date
Optional
|
Only include usage that occurred on or before this date. Specify the date in GMT and format as |
identity
Optional
|
The User's |
tag
Optional
|
Only list Bindings that have all of the specified Tags. The following implicit tags are available: |
Example 1
Note that no more than 50 Bindings are returned at a time.
Delete a Binding resource
https://notify.twilio.com/v1/Services/{ServiceSid}/Bindings/{Sid}
Parameters
Parameters in REST API format | |
---|---|
service_sid
Path
|
The SID of the Service to delete the resource from. |
sid
Path
|
The Twilio-provided string that uniquely identifies the Binding resource to delete. |
Example 1
Need some help?
We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.