Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Programmable Chat Binding Resource


(error)

Danger

Programmable Chat has been deprecated and is no longer supported. Instead, we'll be focusing on the next generation of chat: Twilio Conversations. Find out more about the EOL process here(link takes you to an external page).

If you're starting a new project, please visit the Conversations Docs to begin. If you've already built on Programmable Chat, please visit our Migration Guide to learn about how to switch.

A Binding resource of Programmable Chat represents a push notification subscription for a User within their Service instance. Bindings are unique per service instance, user identity, device, and notification channel (such as APNS, GCM, FCM).

We recommend following the standard URI specification and avoid the following reserved characters ! * ' ( ) ; : @ & = + $ , / ? % # [ ] for values such as identity and friendly name.


Binding Properties

binding-properties page anchor

Each Binding resource contains these properties.

Property nameTypePIIDescription
sidSID<BS>
Not PII

The unique string that we created to identify the Binding resource.

Pattern: ^BS[0-9a-fA-F]{32}$Min length: 34Max length: 34

account_sidSID<AC>

The SID of the Account that created the Binding resource.

Pattern: ^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34

service_sidSID<IS>

The SID of the Service the Binding resource is associated with.

Pattern: ^IS[0-9a-fA-F]{32}$Min length: 34Max length: 34

date_createdstring<date-time>

The date and time in GMT when the resource was created specified in ISO 8601(link takes you to an external page) format.


date_updatedstring<date-time>

The date and time in GMT when the resource was last updated specified in ISO 8601(link takes you to an external page) format.


endpointstring
PII MTL: 30 days

The unique endpoint identifier for the Binding. The format of this value depends on the binding_type.


identitystring

The application-defined string that uniquely identifies the resource's User within the Service. See access tokens for more info.


credential_sidSID<CR>

The SID of the Credential for the binding. See push notification configuration for more info.

Pattern: ^CR[0-9a-fA-F]{32}$Min length: 34Max length: 34

binding_typeenum<string>

The push technology to use for the Binding. Can be: apn, gcm, or fcm. See push notification configuration for more info.

Possible values:
gcmapnfcm

message_typesarray[string]

The Programmable Chat message types the binding is subscribed to.


urlstring<uri>

The absolute URL of the Binding resource.


linksobject<uri-map>

The absolute URLs of the Binding's User.


Fetch a Binding resource

fetch-a-binding-resource page anchor
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Bindings/{Sid}

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required

The SID of the Service to fetch the Binding resource from.

Pattern: ^IS[0-9a-fA-F]{32}$Min length: 34Max length: 34

SidSID<BS>required

The SID of the Binding resource to fetch.

Pattern: ^BS[0-9a-fA-F]{32}$Min length: 34Max length: 34

Fetch a Binding resource

fetch-a-binding-resource-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_19
// Download the helper library from https://www.twilio.com/docs/node/install
_19
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19
_19
// Find your Account SID and Auth Token at twilio.com/console
_19
// and set the environment variables. See http://twil.io/secure
_19
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19
const authToken = process.env.TWILIO_AUTH_TOKEN;
_19
const client = twilio(accountSid, authToken);
_19
_19
async function fetchBinding() {
_19
const binding = await client.chat.v2
_19
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19
.bindings("BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19
.fetch();
_19
_19
console.log(binding.sid);
_19
}
_19
_19
fetchBinding();

Output

_21
{
_21
"sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_21
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_21
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_21
"date_created": "2016-10-21T11:37:03Z",
_21
"date_updated": "2016-10-21T11:37:03Z",
_21
"endpoint": "TestUser-endpoint",
_21
"identity": "TestUser",
_21
"binding_type": "gcm",
_21
"credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_21
"message_types": [
_21
"removed_from_channel",
_21
"new_message",
_21
"added_to_channel",
_21
"invited_to_channel"
_21
],
_21
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_21
"links": {
_21
"user": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/TestUser"
_21
}
_21
}


Read multiple Binding resources

read-multiple-binding-resources page anchor
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Bindings

Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required

The SID of the Service to read the Binding resources from.

Pattern: ^IS[0-9a-fA-F]{32}$Min length: 34Max length: 34
Property nameTypeRequiredPIIDescription
BindingTypearray[enum<string>]Optional

The push technology used by the Binding resources to read. Can be: apn, gcm, or fcm. See push notification configuration for more info.

Possible values:
gcmapnfcm

Identityarray[string]Optional

The User's identity value of the resources to read. See access tokens for more details.


PageSizeintegerOptional

How many resources to return in each list page. The default is 50, and the maximum is 1000.

Minimum: 1Maximum: 1000

PageintegerOptional

The page index. This value is simply for client state.

Minimum: 0

PageTokenstringOptional

The page token. This is provided by the API.

Read multiple Binding resources

read-multiple-binding-resources-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = twilio(accountSid, authToken);
_18
_18
async function listBinding() {
_18
const bindings = await client.chat.v2
_18
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.bindings.list({ limit: 20 });
_18
_18
bindings.forEach((b) => console.log(b.sid));
_18
}
_18
_18
listBinding();

Output

_34
{
_34
"meta": {
_34
"page": 0,
_34
"page_size": 50,
_34
"first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0",
_34
"previous_page_url": null,
_34
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0",
_34
"next_page_url": null,
_34
"key": "bindings"
_34
},
_34
"bindings": [
_34
{
_34
"sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_34
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_34
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_34
"date_created": "2016-10-21T11:37:03Z",
_34
"date_updated": "2016-10-21T11:37:03Z",
_34
"endpoint": "TestUser-endpoint",
_34
"identity": "TestUser",
_34
"binding_type": "gcm",
_34
"credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_34
"message_types": [
_34
"removed_from_channel",
_34
"new_message",
_34
"added_to_channel",
_34
"invited_to_channel"
_34
],
_34
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_34
"links": {
_34
"user": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/TestUser"
_34
}
_34
}
_34
]
_34
}


Delete a Binding resource

delete-a-binding-resource page anchor
DELETE https://chat.twilio.com/v2/Services/{ServiceSid}/Bindings/{Sid}

Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required

The SID of the Service to delete the Binding resource from.

Pattern: ^IS[0-9a-fA-F]{32}$Min length: 34Max length: 34

SidSID<BS>required

The SID of the Binding resource to delete.

Pattern: ^BS[0-9a-fA-F]{32}$Min length: 34Max length: 34
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_17
// Download the helper library from https://www.twilio.com/docs/node/install
_17
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_17
_17
// Find your Account SID and Auth Token at twilio.com/console
_17
// and set the environment variables. See http://twil.io/secure
_17
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_17
const authToken = process.env.TWILIO_AUTH_TOKEN;
_17
const client = twilio(accountSid, authToken);
_17
_17
async function deleteBinding() {
_17
await client.chat.v2
_17
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_17
.bindings("BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_17
.remove();
_17
}
_17
_17
deleteBinding();


Rate this page: