Skip to contentSkip to navigationSkip to topbar
On this page

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

(error)

Danger

This is reference documentation for the v1 REST API, which has been deprecated. You should use the current v2 REST API.

The Member resource of Programmable Chat represents the membership of a User within the Service instance to a Channel.


Properties

properties page anchor

Each member has these properties:

Property nameTypeRequiredDescriptionChild properties
sidSID<MB>

Optional

Not PII

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

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

account_sidSID<AC>

Optional

The SID of the Account that created the Member resource.

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

channel_sidSID<CH>

Optional

The unique ID of the Channel for the member.

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

service_sidSID<IS>

Optional

The SID of the Service the resource is associated with.

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

identitystring

Optional

PII MTL: 30 days

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


date_createdstring<date-time>

Optional

The date and time in GMT when the resource was created specified in RFC 2822(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 RFC 2822(link takes you to an external page) format.


role_sidSID<RL>

Optional

The SID of the Role assigned to the member.

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

last_consumed_message_indexinteger

Optional

The index of the last Message in the Channel that the Member has read.


last_consumption_timestampstring<date-time>

Optional

The ISO 8601 timestamp string that represents the date-time of the last Message read event for the Member within the Channel.


urlstring<uri>

Optional

The absolute URL of the Member resource.


List All Members of a Channel

list-all-members-of-a-channel page anchor
1
GET /Services/{Instance SID}/Channels/{Channel SID}/Members
2
List all MembersLink to code sample: List all Members
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 listMember() {
11
const members = await client.chat.v1
12
.services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
13
.channels("CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
14
.members.list({ limit: 20 });
15
16
members.forEach((m) => console.log(m.sid));
17
}
18
19
listMember();

Output

1
{
2
"meta": {
3
"page": 0,
4
"page_size": 50,
5
"first_page_url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0",
6
"previous_page_url": null,
7
"url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0",
8
"next_page_url": null,
9
"key": "members"
10
},
11
"members": [
12
{
13
"sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
15
"channel_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
16
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
17
"identity": "jing",
18
"role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
19
"last_consumed_message_index": null,
20
"last_consumption_timestamp": null,
21
"date_created": "2016-03-24T21:05:50Z",
22
"date_updated": "2016-03-24T21:05:50Z",
23
"url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
24
}
25
]
26
}

Add a Member to a Channel

add-a-member-to-a-channel page anchor
1
POST /Services/{Instance SID}/Channels/{Channel SID}/Members
2

Parameters

parameters page anchor
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required

The SID of the Service to create the resource under.

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

ChannelSidstringrequired

The unique ID of the Channel the new member belongs to. Can be the Channel resource's sid or unique_name.

Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
Identitystringrequired

The identity value that uniquely identifies the new resource's User within the Service. See access tokens for more details.


RoleSidSID<RL>

Optional

The SID of the Role to assign to the member. The default roles are those specified on the Service.

Pattern: ^RL[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 createMember() {
11
const member = await client.chat.v1
12
.services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
13
.channels("CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
14
.members.create({ identity: "IDENTITY" });
15
16
console.log(member.sid);
17
}
18
19
createMember();

Output

1
{
2
"sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"channel_sid": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
5
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
6
"identity": "IDENTITY",
7
"role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"last_consumed_message_index": null,
9
"last_consumption_timestamp": null,
10
"date_created": "2016-03-24T21:05:50Z",
11
"date_updated": "2016-03-24T21:05:50Z",
12
"url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
13
}

Retrieve a Member of a Channel

retrieve-a-member-of-a-channel page anchor
1
GET /Services/{Instance SID}/Channels/{Channel SID}/Members/{Member SID}
2
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 fetchMember() {
11
const member = await client.chat.v1
12
.services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
13
.channels("CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
14
.members("MBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
15
.fetch();
16
17
console.log(member.sid);
18
}
19
20
fetchMember();

Output

1
{
2
"sid": "MBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"channel_sid": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
5
"service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
6
"identity": "jing",
7
"role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"last_consumed_message_index": null,
9
"last_consumption_timestamp": null,
10
"date_created": "2016-03-24T21:05:50Z",
11
"date_updated": "2016-03-24T21:05:50Z",
12
"url": "https://chat.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
13
}

Remove a Member from a Channel

remove-a-member-from-a-channel page anchor
1
DELETE /Services/{Instance SID}/Channels/{Channel SID}/Members/{Member SID}
2
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 deleteMember() {
11
await client.chat.v1
12
.services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
13
.channels("CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
14
.members("MBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
15
.remove();
16
}
17
18
deleteMember();