Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Conversation Resource


A Conversation is a unique message thread that contains Participants and the Messages they have sent.

(error)

Danger

Do not use Personally Identifiable Information (PII) for the friendlyName field.

Avoid using a person's name, home address, email, phone number, or other PII in the friendlyName field. Use some form of pseudonymized identifier, instead.

You can learn more about how we process your data in our privacy policy.(link takes you to an external page)


API Base URL

api-base-url page anchor

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


_10
https://conversations.twilio.com/v1

Using the shortened base URL

using-the-shortened-base-url page anchor

Using the REST API, you can interact with Conversation resources in the default Conversation Service instance via a "shortened" URL that does not include the Conversation Service instance SID ("ISXXX..."). If you are only using one Conversation Service (the default), you do not need to include the Conversation Service SID in your URL, e.g.


_10
GET /v1/Conversations

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:


_10
GET /v1/Services/ISxx/Conversations


Resource properties
account_sidtype: SID<AC>Not PII

The unique ID of the Account(link takes you to an external page) responsible for this conversation.


chat_service_sidtype: SID<IS>Not PII

The unique ID of the Conversation Service(link takes you to an external page) this conversation belongs to.


messaging_service_sidtype: SID<MG>Not PII

The unique ID of the Messaging Service(link takes you to an external page) this conversation belongs to.


sidtype: SID<CH>Not PII

A 34 character string that uniquely identifies this resource.


friendly_nametype: stringPII MTL: 30 days

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


unique_nametype: stringPII MTL: 30 days

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.


attributestype: stringPII MTL: 30 days

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.


statetype: enum<STRING>Not PII

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

Possible values:
inactiveactiveclosed

date_createdtype: string<DATE TIME>Not PII

The date that this resource was created.


date_updatedtype: string<DATE TIME>Not PII

The date that this resource was last updated.


timerstype: objectNot PII

Timer date values representing state update for this conversation.


urltype: string<URI>Not PII

An absolute API resource URL for this conversation.


bindingstype: objectNot PII

Create a Conversation resource

create-a-conversation-resource page anchor
POST https://conversations.twilio.com/v1/Conversations

Parameters

create-parameters page anchor
Request headers
X-Twilio-Webhook-Enabledtype: enum<STRING>Not PII

The X-Twilio-Webhook-Enabled HTTP request header

Possible values:
truefalse

Request body parameters
FriendlyNametype: stringPII MTL: 30 days

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


UniqueNametype: stringPII MTL: 30 days

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.


DateCreatedtype: string<DATE TIME>Not PII

The date that this resource was created.


DateUpdatedtype: string<DATE TIME>Not PII

The date that this resource was last updated.


MessagingServiceSidtype: SID<MG>Not PII

The unique ID of the Messaging Service(link takes you to an external page) this conversation belongs to.


Attributestype: stringPII MTL: 30 days

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.


Statetype: enum<STRING>Not PII

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

Possible values:
inactiveactiveclosed

Timers.Inactivetype: stringNot PII

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


Timers.Closedtype: stringNot PII

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


Bindings.Email.Addresstype: stringNot PII

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


Bindings.Email.Nametype: stringNot PII

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

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.conversations.v1.conversations
_10
.create({friendlyName: 'Friendly Conversation'})
_10
.then(conversation => console.log(conversation.sid));

Output

_25
{
_25
"sid": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"chat_service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"messaging_service_sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"friendly_name": "Friendly Conversation",
_25
"unique_name": "unique_name",
_25
"attributes": {
_25
"topic": "feedback"
_25
},
_25
"date_created": "2015-12-16T22:18:37Z",
_25
"date_updated": "2015-12-16T22:18:38Z",
_25
"state": "inactive",
_25
"timers": {
_25
"date_inactive": "2015-12-16T22:19:38Z",
_25
"date_closed": "2015-12-16T22:28:38Z"
_25
},
_25
"bindings": {},
_25
"url": "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"links": {
_25
"participants": "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Participants",
_25
"messages": "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages",
_25
"webhooks": "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Webhooks"
_25
}
_25
}


Fetch a Conversation resource

fetch-a-conversation-resource page anchor
GET https://conversations.twilio.com/v1/Conversations/{Sid}

You can fetch a Conversation by providing your account credentials and the conversation SID (provided when the Conversation is created).

The most valuable part of the Conversation resource itself is the attributes key, which includes metadata attached to the conversation from the moment of its creation.

The other relevant parts of a Conversation include its Participants (the entities who are currently conversing) and the Messages they've sent. Both of these are linked directly from the top-level url key.

URI parameters
Sidtype: stringNot PII
Path Parameter

A 34 character string that uniquely identifies this resource. Can also be the unique_name of the Conversation.

Fetch Conversation by SID

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.conversations.v1.conversations('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.fetch()
_10
.then(conversation => console.log(conversation.friendlyName));

Output

_25
{
_25
"sid": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"chat_service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"messaging_service_sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"friendly_name": "My First Conversation",
_25
"unique_name": "first_conversation",
_25
"attributes": {
_25
"topic": "feedback"
_25
},
_25
"date_created": "2015-12-16T22:18:37Z",
_25
"date_updated": "2015-12-16T22:18:38Z",
_25
"state": "active",
_25
"timers": {
_25
"date_inactive": "2015-12-16T22:19:38Z",
_25
"date_closed": "2015-12-16T22:28:38Z"
_25
},
_25
"bindings": {},
_25
"url": "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"links": {
_25
"participants": "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Participants",
_25
"messages": "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages",
_25
"webhooks": "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Webhooks"
_25
}
_25
}


Read multiple Conversation resources

read-multiple-conversation-resources page anchor
GET https://conversations.twilio.com/v1/Conversations

Returns a list of conversations sorted by recent message activity.

URI parameters
StartDatetype: stringNot PII
Query Parameter

Start date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the start time of the date is used (YYYY-MM-DDT00:00:00Z). Can be combined with other filters.


EndDatetype: stringNot PII
Query Parameter

End date or time in ISO8601 format for filtering list of Conversations. If a date is provided, the end time of the date is used (YYYY-MM-DDT23:59:59Z). Can be combined with other filters.


Statetype: enum<STRING>Not PII
Query Parameter

State for sorting and filtering list of Conversations. Can be active, inactive or closed

Possible values:
inactiveactiveclosed

PageSizetype: integerNot PII
Query Parameter

How many resources to return in each list page. The default is 50, and the maximum is 1000.


Pagetype: integerNot PII
Query Parameter

The page index. This value is simply for client state.


PageTokentype: stringNot PII
Query Parameter

The page token. This is provided by the API.

Read multiple Conversation resources

read-multiple-conversation-resources-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.conversations.v1.conversations
_10
.list({limit: 20})
_10
.then(conversations => conversations.forEach(c => console.log(c.sid)));

Output

_38
{
_38
"conversations": [
_38
{
_38
"sid": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_38
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_38
"chat_service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_38
"messaging_service_sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_38
"friendly_name": "Home Repair Visit",
_38
"unique_name": null,
_38
"attributes": {
_38
"topic": "feedback"
_38
},
_38
"date_created": "2015-12-16T22:18:37Z",
_38
"date_updated": "2015-12-16T22:18:38Z",
_38
"state": "active",
_38
"timers": {
_38
"date_inactive": "2015-12-16T22:19:38Z",
_38
"date_closed": "2015-12-16T22:28:38Z"
_38
},
_38
"bindings": {},
_38
"url": "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_38
"links": {
_38
"participants": "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Participants",
_38
"messages": "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages",
_38
"webhooks": "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Webhooks"
_38
}
_38
}
_38
],
_38
"meta": {
_38
"page": 0,
_38
"page_size": 50,
_38
"first_page_url": "https://conversations.twilio.com/v1/Conversations?PageSize=50&Page=0",
_38
"previous_page_url": "https://conversations.twilio.com/v1/Conversations?PageSize=50&Page=0",
_38
"url": "https://conversations.twilio.com/v1/Conversations?PageSize=50&Page=0",
_38
"next_page_url": "https://conversations.twilio.com/v1/Conversations?PageSize=50&Page=1",
_38
"key": "conversations"
_38
}
_38
}


POST https://conversations.twilio.com/v1/Conversations/{Sid}

The core definition of any Conversation can be modified on the fly. Update a Conversation to attach metadata that you extract on the fly (e.g. "customer-loyalty-status": "gold", or "aml-risk-level": "heightened"), or to correct mistakes manually.

Request headers
X-Twilio-Webhook-Enabledtype: enum<STRING>Not PII

The X-Twilio-Webhook-Enabled HTTP request header

Possible values:
truefalse

URI parameters
Sidtype: stringNot PII
Path Parameter

A 34 character string that uniquely identifies this resource. Can also be the unique_name of the Conversation.


Request body parameters
FriendlyNametype: stringPII MTL: 30 days

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


DateCreatedtype: string<DATE TIME>Not PII

The date that this resource was created.


DateUpdatedtype: string<DATE TIME>Not PII

The date that this resource was last updated.


Attributestype: stringPII MTL: 30 days

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.


MessagingServiceSidtype: SID<MG>Not PII

The unique ID of the Messaging Service(link takes you to an external page) this conversation belongs to.


Statetype: enum<STRING>Not PII

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

Possible values:
inactiveactiveclosed

Timers.Inactivetype: stringNot PII

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


Timers.Closedtype: stringNot PII

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


UniqueNametype: stringPII MTL: 30 days

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.


Bindings.Email.Addresstype: stringNot PII

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


Bindings.Email.Nametype: stringNot PII

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

Update a Conversation's property

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.conversations.v1.conversations('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.update({friendlyName: 'Important Customer Question'})
_10
.then(conversation => console.log(conversation.friendlyName));

Output

_25
{
_25
"sid": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"chat_service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"messaging_service_sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"friendly_name": "Important Customer Question",
_25
"unique_name": "unique_name",
_25
"attributes": {
_25
"topic": "feedback"
_25
},
_25
"date_created": "2015-12-16T22:18:37Z",
_25
"date_updated": "2015-12-16T22:18:38Z",
_25
"state": "inactive",
_25
"timers": {
_25
"date_inactive": "2015-12-16T22:19:38Z",
_25
"date_closed": "2015-12-16T22:28:38Z"
_25
},
_25
"bindings": {},
_25
"url": "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"links": {
_25
"participants": "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Participants",
_25
"messages": "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages",
_25
"webhooks": "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Webhooks"
_25
}
_25
}


Delete a Conversation resource

delete-a-conversation-resource page anchor
DELETE https://conversations.twilio.com/v1/Conversations/{Sid}

Request headers
X-Twilio-Webhook-Enabledtype: enum<STRING>Not PII

The X-Twilio-Webhook-Enabled HTTP request header

Possible values:
truefalse

URI parameters
Sidtype: stringNot PII
Path Parameter

A 34 character string that uniquely identifies this resource. Can also be the unique_name of the Conversation.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.conversations.v1.conversations('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.remove();


Rate this page: