Skip to contentSkip to navigationSkip to topbar
On this page

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

An Invite resource for Programmable Chat represents an invitation for a User (within the Service instance) to join a Channel and become a Member.


Invite Properties

invite-properties page anchor

Each Invite resource contains these properties.

Property nameTypeRequiredDescriptionChild properties
sidSID<IN>Optional
Not PII

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

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

account_sidSID<AC>Optional

The SID of the Account that created the Invite resource.

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

channel_sidSID<CH>Optional

The SID of the Channel the Invite 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 Invite 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 resource.

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

created_bystringOptional

The identity of the User that created the invite.


urlstring<uri>Optional

The absolute URL of the Invite resource.


Create an Invite resource

create-an-invite-resource page anchor
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Invites

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

Path parameters

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

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

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

ChannelSidstringrequired

The SID of the Channel the new Invite 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 assigned to the new member.

Pattern: ^RL[0-9a-fA-F]{32}$Min length: 34Max length: 34
Create an Invite resourceLink to code sample: Create an Invite 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 createInvite() {
11
const invite = await client.chat.v2
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.channels("ChannelSid")
14
.invites.create({ identity: "Identity" });
15
16
console.log(invite.sid);
17
}
18
19
createInvite();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"channel_sid": "ChannelSid",
4
"created_by": "created_by",
5
"date_created": "2015-07-30T20:00:00Z",
6
"date_updated": "2015-07-30T20:00:00Z",
7
"identity": "Identity",
8
"role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
9
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
10
"sid": "INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
11
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
12
}

Fetch an Invite resource

fetch-an-invite-resource page anchor
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Invites/{Sid}

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

Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required

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

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

ChannelSidstringrequired

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


SidSID<IN>required

The SID of the Invite resource to fetch.

Pattern: ^IN[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 fetchInvite() {
11
const invite = await client.chat.v2
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.channels("ChannelSid")
14
.invites("INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
15
.fetch();
16
17
console.log(invite.sid);
18
}
19
20
fetchInvite();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"channel_sid": "ChannelSid",
4
"created_by": "created_by",
5
"date_created": "2015-07-30T20:00:00Z",
6
"date_updated": "2015-07-30T20:00:00Z",
7
"identity": "identity",
8
"role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
9
"service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
10
"sid": "INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
11
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites/INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
12
}

Read multiple Invite resources

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

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 Invite resources from.

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

ChannelSidstringrequired

The SID of the Channel the Invite 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 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 listInvite() {
11
const invites = await client.chat.v2
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.channels("ChannelSid")
14
.invites.list({ limit: 20 });
15
16
invites.forEach((i) => console.log(i.sid));
17
}
18
19
listInvite();

Output

1
{
2
"invites": [],
3
"meta": {
4
"first_page_url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites?Identity=identity&PageSize=50&Page=0",
5
"key": "invites",
6
"next_page_url": null,
7
"page": 0,
8
"page_size": 50,
9
"previous_page_url": null,
10
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Invites?Identity=identity&PageSize=50&Page=0"
11
}
12
}

Delete an Invite resource

delete-an-invite-resource page anchor
DELETE https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Invites/{Sid}

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

Property nameTypeRequiredPIIDescription
ServiceSidSID<IS>required

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

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

ChannelSidstringrequired

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


SidSID<IN>required

The SID of the Invite resource to delete.

Pattern: ^IN[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 deleteInvite() {
11
await client.chat.v2
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.channels("ChannelSid")
14
.invites("INaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
15
.remove();
16
}
17
18
deleteInvite();

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.