Skip to contentSkip to navigationSkip to topbar
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.


Binding Properties

binding-properties page anchor

Each User Binding resource contains these properties.

Property nameTypeRequiredDescriptionChild properties
sidSID<BS>

Optional

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>

Optional

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>

Optional

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>

Optional

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>

Optional

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

Optional

PII MTL: 30 days

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


identitystring

Optional

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


user_sidSID<US>

Optional

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>

Optional

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>

Optional

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]

Optional

The Programmable Chat message types the binding is subscribed to.


urlstring<uri>

Optional

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 resourceLink to code sample: Fetch a User Binding resource
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchUserBinding() {
11
const userBinding = await client.chat.v2
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.users("UserSid")
14
.userBindings("BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
15
.fetch();
16
17
console.log(userBinding.sid);
18
}
19
20
fetchUserBinding();

Output

1
{
2
"sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"date_created": "2016-10-21T11:37:03Z",
6
"date_updated": "2016-10-21T11:37:03Z",
7
"endpoint": "TestUser-endpoint",
8
"identity": "TestUser",
9
"user_sid": "UserSid",
10
"binding_type": "gcm",
11
"credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
12
"message_types": [
13
"removed_from_channel",
14
"new_message",
15
"added_to_channel",
16
"invited_to_channel"
17
],
18
"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

PageSizeinteger

Optional

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

Minimum: 1Maximum: 1000

Pageinteger

Optional

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

Minimum: 0

PageTokenstring

Optional

The page token. This is provided by the API.

1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function listUserBinding() {
11
const userBindings = await client.chat.v2
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.users("UserSid")
14
.userBindings.list({ limit: 20 });
15
16
userBindings.forEach((u) => console.log(u.sid));
17
}
18
19
listUserBinding();

Output

1
{
2
"meta": {
3
"page": 0,
4
"page_size": 50,
5
"first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0",
6
"previous_page_url": null,
7
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings?PageSize=50&Page=0",
8
"next_page_url": null,
9
"key": "bindings"
10
},
11
"bindings": [
12
{
13
"sid": "BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
15
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
16
"date_created": "2016-10-21T11:37:03Z",
17
"date_updated": "2016-10-21T11:37:03Z",
18
"endpoint": "TestUser-endpoint",
19
"identity": "TestUser",
20
"user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
21
"binding_type": "gcm",
22
"credential_sid": "CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
23
"message_types": [
24
"removed_from_channel",
25
"new_message",
26
"added_to_channel",
27
"invited_to_channel"
28
],
29
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings/BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
30
}
31
]
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
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function deleteUserBinding() {
11
await client.chat.v2
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.users("UserSid")
14
.userBindings("BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
15
.remove();
16
}
17
18
deleteUserBinding();

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.