Skip to contentSkip to navigationSkip to topbar
On this page

Conversation with Participants Resource


The ConversationWithParticipants resource accepts all the details for a conversation and allows up to 10 participants in one request. It 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.


API Base URL

api-base-url page anchor

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

https://conversations.twilio.com/v1

Using the shortened base URL

using-the-shortened-base-url page anchor

Using the REST API, you can create Conversation with Participants in the default Conversation Service instance via a "shortened" URL that doesn't include the Conversation Service instance SID (ISXXX...). If you are only using one Conversation Service (the default), you don't need to include the Conversation Service SID in your URL, e.g.

POST /v1/ConversationWithParticipants

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_namestring

Optional

PII MTL: 30 days

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


unique_namestring

Optional

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.


attributesstring

Optional

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 initializing, 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.


timersobject

Optional

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.


bindingsnull

Optional


urlstring<uri>

Optional

An absolute API resource URL for this conversation.


Create a Conversation with Participants resource

create-a-conversation-with-participants-resource page anchor
POST https://conversations.twilio.com/v1/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: Once all participants are added, the conversation state will be set to active and the conversation can be used. Listening to the onConversationStateUpdated webhook event or 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. You can view the error logs in the Twilio Console(link takes you to an external page), and in your webhook notifications if you subscribe to them.

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

Optional

The X-Twilio-Webhook-Enabled HTTP request header

Possible values:
truefalse
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
FriendlyNamestring

Optional

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


UniqueNamestring

Optional

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

Attributesstring

Optional

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

Optional

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


Timers.Closedstring

Optional

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


Bindings.Email.Addressstring

Optional

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


Bindings.Email.Namestring

Optional

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 JSON object attributes are as parameters 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 createConversationWithParticipants() {
11
const conversationWithParticipant =
12
await client.conversations.v1.conversationWithParticipants.create({
13
friendlyName: "Friendly Conversation",
14
participant: [
15
'{"messaging_binding": {"address": "<External Participant Number>", "proxy_address": "<Your Twilio Number>"}}',
16
'{"identity": "<Chat User Identity>"}',
17
],
18
});
19
20
console.log(conversationWithParticipant.sid);
21
}
22
23
createConversationWithParticipants();

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/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants",
19
"messages": "https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",
20
"webhooks": "https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks"
21
},
22
"url": "https://conversations.twilio.com/v1/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 createConversationWithParticipants() {
11
const conversationWithParticipant =
12
await client.conversations.v1.conversationWithParticipants.create({
13
friendlyName: "Friendly Conversation",
14
participant: [
15
'{"messaging_binding": {"address": "<External Participant Number>"}}',
16
'{"messaging_binding": {"address": "<External Participant Number>"}}',
17
'{"messaging_binding": {"projected_address": "<Your Twilio Number>"}}',
18
],
19
});
20
21
console.log(conversationWithParticipant.sid);
22
}
23
24
createConversationWithParticipants();

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/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants",
19
"messages": "https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",
20
"webhooks": "https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks"
21
},
22
"url": "https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
23
}

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.