Skip to contentSkip to navigationSkip to topbar
On this page

Member 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 Member resource of Programmable Chat represents the membership of a User to a Channel within a Service instance.

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


Member Properties

member-properties page anchor

Each Member resource contains 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 SID of the Channel the Member resource belongs to.

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

service_sidSID<IS>Optional

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

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

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


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_indexintegerOptional

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


last_consumption_timestampstring<date-time>Optional

The ISO 8601(link takes you to an external page) timestamp of the last Message read event for the Member within the Channel.


urlstring<uri>Optional

The absolute URL of the Member resource.


attributesstringOptional

The JSON string that stores application-specific data. If attributes have not been set, {} is returned.


Create a Member resource

create-a-member-resource page anchor
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Members

The {ChannelSid} value can be the Channel's sid or its unique_name.

Headers

headers page anchor
Property nameTypeRequiredPIIDescription
X-Twilio-Webhook-Enabledenum<string>Optional

The X-Twilio-Webhook-Enabled HTTP request header

Possible values:
truefalse
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required

The SID of the Service to create the Member resource under.

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

ChannelSidstringrequired

The SID of the Channel the new Member resource belongs to. This value 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 info.


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

LastConsumedMessageIndexintegerOptional

The index of the last Message in the Channel that the Member has read. This parameter should only be used when recreating a Member from a backup/separate source.


LastConsumptionTimestampstring<date-time>Optional

The ISO 8601(link takes you to an external page) timestamp of the last Message read event for the Member within the Channel.


DateCreatedstring<date-time>Optional

The date, specified in ISO 8601(link takes you to an external page) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. Note that this parameter should only be used when a Member is being recreated from a backup/separate source.


DateUpdatedstring<date-time>Optional

The date, specified in ISO 8601(link takes you to an external page) format, to assign to the resource as the date it was last updated. The default value is null. Note that this parameter should only be used when a Member is being recreated from a backup/separate source and where a Member was previously updated.


AttributesstringOptional

A valid JSON string that contains application-specific data.

Create a Member resourceLink to code sample: Create a Member 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 createMember() {
11
const member = await client.chat.v2
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.channels("ChannelSid")
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": "ChannelSid",
5
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
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
"attributes": "{}",
13
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
14
}

GET https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Members/{Sid}

The {ChannelSid} value can be the Channel's sid or its unique_nameand the {Sid} value can be either the sid or the identity of the Member resource to fetch.

Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required

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

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

ChannelSidstringrequired

The SID of the Channel the Member resource to fetch belongs to. This value can be the Channel resource's sid or unique_name.


Sidstringrequired

The SID of the Member resource to fetch. This value can be either the Member's sid or its identity value.

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.v2
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.channels("ChannelSid")
14
.members("Sid")
15
.fetch();
16
17
console.log(member.sid);
18
}
19
20
fetchMember();

Output

1
{
2
"sid": "Sid",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"channel_sid": "ChannelSid",
5
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
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
"attributes": "{}",
13
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
14
}

Read multiple Member resources

read-multiple-member-resources page anchor
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Members

The {ChannelSid} value can be the Channel's sid or its unique_name.

Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required

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

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

ChannelSidstringrequired

The SID of the Channel the Member resources to read belong to. This value can be the Channel resource's sid or unique_name.

Property nameTypeRequiredPIIDescription
Identityarray[string]Optional

The User's identity value of the Member 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.

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.v2
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.channels("ChannelSid")
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/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0",
6
"previous_page_url": null,
7
"url": "https://chat.twilio.com/v2/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
"attributes": "{}",
24
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
25
}
26
]
27
}

Update a Member resource

update-a-member-resource page anchor
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Members/{Sid}

The {Sid} value can be either the sid or the identity of the Member resource to update and the {ChannelSid} value can be the Channel's sid or its unique_name.

Property nameTypeRequiredPIIDescription
X-Twilio-Webhook-Enabledenum<string>Optional

The X-Twilio-Webhook-Enabled HTTP request header

Possible values:
truefalse
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required

The SID of the Service to update the Member resource in.

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

ChannelSidstringrequired

The SID of the Channel the Member resource to update belongs to. This value can be the Channel resource's sid or unique_name.


Sidstringrequired

The SID of the Member resource to update. This value can be either the Member's sid or its identity value.

Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
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

LastConsumedMessageIndexintegerOptional

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


LastConsumptionTimestampstring<date-time>Optional

The ISO 8601(link takes you to an external page) timestamp of the last Message read event for the Member within the Channel.


DateCreatedstring<date-time>Optional

The date, specified in ISO 8601(link takes you to an external page) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. Note that this parameter should only be used when a Member is being recreated from a backup/separate source.


DateUpdatedstring<date-time>Optional

The date, specified in ISO 8601(link takes you to an external page) format, to assign to the resource as the date it was last updated.


AttributesstringOptional

A valid JSON string that contains application-specific data.

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 updateMember() {
11
const member = await client.chat.v2
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.channels("ChannelSid")
14
.members("Sid")
15
.update({ roleSid: "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" });
16
17
console.log(member.sid);
18
}
19
20
updateMember();

Output

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

Delete a Member resource

delete-a-member-resource page anchor
DELETE https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Members/{Sid}

The {Sid} value can be either the sid or the identity of the Member resource to delete and the {ChannelSid} value can be the Channel's sid or its unique_name.

Property nameTypeRequiredPIIDescription
X-Twilio-Webhook-Enabledenum<string>Optional

The X-Twilio-Webhook-Enabled HTTP request header

Possible values:
truefalse
Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required

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

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

ChannelSidstringrequired

The SID of the Channel the Member resource to delete belongs to. This value can be the Channel resource's sid or unique_name.


Sidstringrequired

The SID of the Member resource to delete. This value can be either the Member's sid or its identity value.

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.v2
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.channels("ChannelSid")
14
.members("Sid")
15
.remove();
16
}
17
18
deleteMember();

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.