Skip to contentSkip to navigationSkip to topbar
On this page

Service-Scoped Conversation with Participants Resource


The Service-scoped ConversationWithParticipants resource accepts all the details for a conversation and allows up to 10 participants in one request. This resource is especially helpful for situations where you want to send group texts. It helps prevent issues that might occur with existing conversations when you add participants individually.

Please see the Conversation with Participants Resource for Conversations within the default Conversation Service instance.


API Base URL

api-base-url page anchor

All URLs in the reference documentation use the following base URL:

https://conversations.twilio.com/v1

For Conversations applications that build on more than one Conversation Service instance, you will need to specify the Conversation Service SID in the REST API call:

POSt /v1/Services/ISxx/ConversationWithParticipants

ConversationWithParticipant Properties

conversationwithparticipant-properties page anchor
Property nameTypeRequiredDescriptionChild properties
account_sidSID<AC>Optional
Not PII

The unique ID of the Account responsible for this conversation.

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

chat_service_sidSID<IS>Optional

The unique ID of the Conversation Service this conversation belongs to.

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

messaging_service_sidSID<MG>Optional

The unique ID of the Messaging Service this conversation belongs to.

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

sidSID<CH>Optional

A 34 character string that uniquely identifies this resource.

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

friendly_namestringOptional
PII MTL: 30 days

The human-readable name of this conversation, limited to 256 characters. Optional.


unique_namestringOptional

An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's sid in the URL.


attributesstringOptional

An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. Note that if the attributes are not set "{}" will be returned.


stateenum<string>Optional

Current state of this conversation. Can be either active, inactive or closed and defaults to active

Possible values:
inactiveactiveclosed

date_createdstring<date-time>Optional

The date that this resource was created.


date_updatedstring<date-time>Optional

The date that this resource was last updated.


timersobjectOptional

Timer date values representing state update for this conversation.


linksobject<uri-map>Optional

Contains absolute URLs to access the participants, messages and webhooks of this conversation.


bindingsnullOptional

urlstring<uri>Optional

An absolute API resource URL for this conversation.


Create a new conversation with the list of participants in your account's default service

create-a-new-conversation-with-the-list-of-participants-in-your-accounts-default-service page anchor
POST https://conversations.twilio.com/v1/Services/{ChatServiceSid}/ConversationWithParticipants

This resource behaves differently than most other Conversations API resources. Here's how it works:

  1. Parameter validation: It validates all conversation and participant parameters and returns various possible conversations errors.

  2. Conversations are created synchronously: If the request is valid, a conversation will be created and returned in the response. This conversation will be in the state initializing while the participants are added. In this state, the conversation cannot be updated.

  3. Participants are added to the conversation asynchronously: When all participants are added, the conversation state will be set to active and the conversation can be used. Listening to the onConversationStateUpdated webhook event and polling the conversations GET endpoint are both acceptable ways to check if the conversation is ready to be used.

  4. System Errors: If any unexpected errors happen while adding the participants, the conversation state will be set to closed. Errors from this process will appear in the Console Error Logs, which can also be subscribed via webhooks.

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
ChatServiceSidSID<IS>required

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

Pattern: ^IS[0-9a-fA-F]{32}$Min length: 34Max length: 34
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
FriendlyNamestringOptional

The human-readable name of this conversation, limited to 256 characters. Optional.


UniqueNamestringOptional

An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's sid in the URL.


DateCreatedstring<date-time>Optional

The date that this resource was created.


DateUpdatedstring<date-time>Optional

The date that this resource was last updated.


MessagingServiceSidSID<MG>Optional

The unique ID of the Messaging Service this conversation belongs to.

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

AttributesstringOptional

An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. Note that if the attributes are not set "{}" will be returned.


Stateenum<string>Optional

Current state of this conversation. Can be either active, inactive or closed and defaults to active

Possible values:
inactiveactiveclosed

Timers.InactivestringOptional

ISO8601 duration when conversation will be switched to inactive state. Minimum value for this timer is 1 minute.


Timers.ClosedstringOptional

ISO8601 duration when conversation will be switched to closed state. Minimum value for this timer is 10 minutes.


Bindings.Email.AddressstringOptional

The default email address that will be used when sending outbound emails in this conversation.


Bindings.Email.NamestringOptional

The default name that will be used when sending outbound emails in this conversation.


Participantarray[string]Optional

The participant to be added to the conversation in JSON format. The parameters are as in Participant Resource. The maximum number of participants that can be added in a single request is 10.

Create Conversation with ParticipantsLink to code sample: Create Conversation with Participants
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 createServiceConversationWithParticipants() {
11
const conversationWithParticipant = await client.conversations.v1
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.conversationWithParticipants.create({
14
friendlyName: "Friendly Conversation",
15
participant: [
16
'{"messaging_binding": {"address": "<External Participant Number>", "proxy_address": "<Your Twilio Number>"}}',
17
'{"identity": "<Chat User Identity>"}',
18
],
19
});
20
21
console.log(conversationWithParticipant.sid);
22
}
23
24
createServiceConversationWithParticipants();

Output

1
{
2
"sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
6
"friendly_name": "Friendly Conversation",
7
"unique_name": "unique_name",
8
"attributes": "{ \"topic\": \"feedback\" }",
9
"date_created": "2015-12-16T22:18:37Z",
10
"date_updated": "2015-12-16T22:18:38Z",
11
"state": "inactive",
12
"timers": {
13
"date_inactive": "2015-12-16T22:19:38Z",
14
"date_closed": "2015-12-16T22:28:38Z"
15
},
16
"bindings": {},
17
"links": {
18
"participants": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants",
19
"messages": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",
20
"webhooks": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks"
21
},
22
"url": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
23
}
Create GMMS Conversation with ParticipantsLink to code sample: Create GMMS Conversation with Participants
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 createServiceConversationWithParticipants() {
11
const conversationWithParticipant = await client.conversations.v1
12
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.conversationWithParticipants.create({
14
friendlyName: "Friendly Conversation",
15
participant: [
16
'{"messaging_binding": {"address": "<External Participant Number>"}}',
17
'{"messaging_binding": {"address": "<External Participant Number>"}}',
18
'{"messaging_binding": {"projected_address": "<Your Twilio Number>"}}',
19
],
20
});
21
22
console.log(conversationWithParticipant.sid);
23
}
24
25
createServiceConversationWithParticipants();

Output

1
{
2
"sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
6
"friendly_name": "Friendly Conversation",
7
"unique_name": "unique_name",
8
"attributes": "{ \"topic\": \"feedback\" }",
9
"date_created": "2015-12-16T22:18:37Z",
10
"date_updated": "2015-12-16T22:18:38Z",
11
"state": "inactive",
12
"timers": {
13
"date_inactive": "2015-12-16T22:19:38Z",
14
"date_closed": "2015-12-16T22:28:38Z"
15
},
16
"bindings": {},
17
"links": {
18
"participants": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants",
19
"messages": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",
20
"webhooks": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks"
21
},
22
"url": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
23
}

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.