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

User 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.

The User Binding resource provides access to Binding resources that is scoped to a single User.


UserBinding Properties

userbinding-properties page anchor

Each User Binding resource contains these properties.

Property nameTypePIIDescription
sidSID<BS>
Not PII

The unique string that we created to identify the User 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 User Binding resource.

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

service_sidSID<IS>

The SID of the Service the User 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 User Binding. The format of the 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.


user_sidSID<US>

The SID of the User with the User Binding resource. See push notification configuration for more info.

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

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 User 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 User Binding resource.


Fetch a User Binding resource

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

The {UserSid} value can be either the sid or the identity of the User resource to fetch the User Binding resource from.

Path parameters

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

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

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

UserSidstringrequired

The SID of the User with the User Binding resource to fetch. See push notification configuration for more info.


SidSID<BS>required

The SID of the User Binding resource to fetch.

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

Fetch a User Binding resource

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

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

Output

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


Read multiple UserBinding resources

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

The {UserSid} value can be either the sid or the identity of the User resource to read User Binding resources from.

Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required

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

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

UserSidstringrequired

The SID of the User with the User Binding resources to read. See push notification configuration for more info.

Property nameTypeRequiredPIIDescription
BindingTypearray[enum<string>]Optional

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

Possible values:
gcmapnfcm

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 User Binding resources

read-multiple-user-binding-resources 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 listUserBinding() {
_19
const userBindings = await client.chat.v2
_19
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19
.users("UserSid")
_19
.userBindings.list({ limit: 20 });
_19
_19
userBindings.forEach((u) => console.log(u.sid));
_19
}
_19
_19
listUserBinding();

Output

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


Delete a User Binding resource

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

The {UserSid} value can be either the sid or the identity of the User resource to delete the User Channel resource from.

Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required

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

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

UserSidstringrequired

The SID of the User with the User Binding resources to delete. See push notification configuration for more info.


SidSID<BS>required

The SID of the User Binding resource to delete.

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

Delete a User Binding resource

delete-a-user-binding-resource-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 deleteUserBinding() {
_18
await client.chat.v2
_18
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.users("UserSid")
_18
.userBindings("BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.remove();
_18
}
_18
_18
deleteUserBinding();


Rate this page: