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

Chat Service 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 Service is the top-level scope of all other resources in the Programmable Chat REST API. All other Programmable Chat resources, such as Channels, Users, Messages, and Credentials belong to a specific Service.

Services allow you to:

  • Create multiple, distinct environments (such as dev, stage, and prod ) under a single Twilio account
  • Scope access to resources through both the REST and client APIs
  • Configure different service instances with specific behaviors

A Service can also send HTTPS requests(link takes you to an external page) to URLs that you define to let you know of specific events. See what events you can subscribe to in our webhook reference.


Twilio Console

twilio-console page anchor

You can also manage your Programmable Chat Services from your Twilio console when you are logged in.


The Service resource contains these properties.

Property nameTypePIIDescription
sidSID<IS>
Not PII

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

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

account_sidSID<AC>

The SID of the Account that created the Service resource.

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

friendly_namestring
PII MTL: 30 days

The string that you assigned to describe the resource.


date_createdstring<date-time>

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>

The date and time in GMT when the resource was last updated specified in ISO 8601(link takes you to an external page) format.


default_service_role_sidSID<RL>

The service role assigned to users when they are added to the service. See the Role resource for more info about roles.

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

default_channel_role_sidSID<RL>

The channel role assigned to users when they are added to a channel. See the Role resource for more info about roles.

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

default_channel_creator_role_sidSID<RL>

The channel role assigned to a channel creator when they join a new channel. See the Role resource for more info about roles.

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

read_status_enabledboolean

Whether the Message Consumption Horizon feature is enabled. The default is true.


reachability_enabledboolean

Whether the Reachability Indicator is enabled for this Service instance. The default is false.


typing_indicator_timeoutinteger

How long in seconds after a started typing event until clients should assume that user is no longer typing, even if no ended typing message was received. The default is 5 seconds.


consumption_report_intervalinteger

DEPRECATED. The interval in seconds between consumption reports submission batches from client endpoints.


limitsobject

An object that describes the limits of the service instance. The limits object contains channel_members to describe the members/channel limit and user_channels to describe the channels/user limit. channel_members can be 1,000 or less, with a default of 250. user_channels can be 1,000 or less, with a default value of 100.


pre_webhook_urlstring

The URL for pre-event webhooks, which are called by using the webhook_method. See Webhook Events for more details.


post_webhook_urlstring

The URL for post-event webhooks, which are called by using the webhook_method. See Webhook Events for more details.


webhook_methodstring

The HTTP method to use for calls to the pre_webhook_url and post_webhook_url webhooks. Can be: POST or GET and the default is POST. See Webhook Events for more details.


webhook_filtersarray[string]

The list of webhook events that are enabled for this Service instance. See Webhook Events for more details.


pre_webhook_retry_countinteger

The number of times to retry a call to the pre_webhook_url if the request times out (after 5 seconds) or it receives a 429, 503, or 504 HTTP response. Default retry count is 0 times, which means the call won't be retried.


post_webhook_retry_countinteger

The number of times to retry a call to the post_webhook_url if the request times out (after 5 seconds) or it receives a 429, 503, or 504 HTTP response. The default is 0, which means the call won't be retried.


notificationsobject

The notification configuration for the Service instance. See Push Notification Configuration for more info.


mediaobject

An object that describes the properties of media that the service supports. The object contains the size_limit_mb property, which describes the size of the largest media file in MB; and the compatibility_message property, which contains the message text to send when a media message does not have any text.


urlstring<uri>

The absolute URL of the Service resource.


linksobject<uri-map>

The absolute URLs of the Service's Channels, Roles, Bindings, and Users.


Create a Service resource

create-a-service-resource page anchor
POST https://chat.twilio.com/v2/Services

Request body parameters

request-body-parameters page anchor
Property nameTypeRequiredPIIDescription
FriendlyNamestringrequired

A descriptive string that you create to describe the new resource.

Create a Service resource

create-a-service-resource-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_14
// Download the helper library from https://www.twilio.com/docs/node/install
_14
import twilio from "twilio";
_14
_14
// Find your Account SID and Auth Token at twilio.com/console
_14
// and set the environment variables. See http://twil.io/secure
_14
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14
const authToken = process.env.TWILIO_AUTH_TOKEN;
_14
const client = twilio(accountSid, authToken);
_14
_14
const service = await client.chat.v2.services.create({
_14
friendlyName: "FriendlyName",
_14
});
_14
_14
console.log(service.sid);

Output

_38
{
_38
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_38
"consumption_report_interval": 100,
_38
"date_created": "2015-07-30T20:00:00Z",
_38
"date_updated": "2015-07-30T20:00:00Z",
_38
"default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_38
"default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_38
"default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_38
"friendly_name": "FriendlyName",
_38
"limits": {
_38
"channel_members": 100,
_38
"user_channels": 250
_38
},
_38
"links": {
_38
"channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels",
_38
"users": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users",
_38
"roles": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles",
_38
"bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings"
_38
},
_38
"notifications": {},
_38
"post_webhook_url": "post_webhook_url",
_38
"pre_webhook_url": "pre_webhook_url",
_38
"pre_webhook_retry_count": 2,
_38
"post_webhook_retry_count": 3,
_38
"reachability_enabled": false,
_38
"read_status_enabled": false,
_38
"sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_38
"typing_indicator_timeout": 100,
_38
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_38
"webhook_filters": [
_38
"webhook_filters"
_38
],
_38
"webhook_method": "webhook_method",
_38
"media": {
_38
"size_limit_mb": 150,
_38
"compatibility_message": "media compatibility message"
_38
}
_38
}


Fetch a Service resource

fetch-a-service-resource page anchor
GET https://chat.twilio.com/v2/Services/{Sid}

Property nameTypeRequiredPIIDescription
SidSID<IS>required

The SID of the Service resource to fetch.

Pattern: ^IS[0-9a-fA-F]{32}$Min length: 34Max length: 34
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_14
// Download the helper library from https://www.twilio.com/docs/node/install
_14
import twilio from "twilio";
_14
_14
// Find your Account SID and Auth Token at twilio.com/console
_14
// and set the environment variables. See http://twil.io/secure
_14
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14
const authToken = process.env.TWILIO_AUTH_TOKEN;
_14
const client = twilio(accountSid, authToken);
_14
_14
const service = await client.chat.v2
_14
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_14
.fetch();
_14
_14
console.log(service.sid);

Output

_38
{
_38
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_38
"consumption_report_interval": 100,
_38
"date_created": "2015-07-30T20:00:00Z",
_38
"date_updated": "2015-07-30T20:00:00Z",
_38
"default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_38
"default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_38
"default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_38
"friendly_name": "friendly_name",
_38
"limits": {
_38
"channel_members": 100,
_38
"user_channels": 250
_38
},
_38
"links": {
_38
"channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels",
_38
"users": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users",
_38
"roles": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles",
_38
"bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings"
_38
},
_38
"notifications": {},
_38
"post_webhook_url": "post_webhook_url",
_38
"pre_webhook_url": "pre_webhook_url",
_38
"pre_webhook_retry_count": 2,
_38
"post_webhook_retry_count": 3,
_38
"reachability_enabled": false,
_38
"read_status_enabled": false,
_38
"sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_38
"typing_indicator_timeout": 100,
_38
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_38
"webhook_filters": [
_38
"webhook_filters"
_38
],
_38
"webhook_method": "webhook_method",
_38
"media": {
_38
"size_limit_mb": 150,
_38
"compatibility_message": "media compatibility message"
_38
}
_38
}


Read multiple Service resources

read-multiple-service-resources page anchor
GET https://chat.twilio.com/v2/Services

Property nameTypeRequiredPIIDescription
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.

Read multiple Service resources

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

_12
// Download the helper library from https://www.twilio.com/docs/node/install
_12
import twilio from "twilio";
_12
_12
// Find your Account SID and Auth Token at twilio.com/console
_12
// and set the environment variables. See http://twil.io/secure
_12
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_12
const authToken = process.env.TWILIO_AUTH_TOKEN;
_12
const client = twilio(accountSid, authToken);
_12
_12
const services = await client.chat.v2.services.list({ limit: 20 });
_12
_12
services.forEach((s) => console.log(s.sid));

Output

_12
{
_12
"meta": {
_12
"first_page_url": "https://chat.twilio.com/v2/Services?PageSize=50&Page=0",
_12
"key": "services",
_12
"next_page_url": null,
_12
"page": 0,
_12
"page_size": 50,
_12
"previous_page_url": null,
_12
"url": "https://chat.twilio.com/v2/Services?PageSize=50&Page=0"
_12
},
_12
"services": []
_12
}


Update a Service resource

update-a-service-resource page anchor
POST https://chat.twilio.com/v2/Services/{Sid}

Property nameTypeRequiredPIIDescription
SidSID<IS>required

The SID of the Service resource to update.

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

A descriptive string that you create to describe the resource.


DefaultServiceRoleSidSID<RL>Optional

The service role assigned to users when they are added to the service. See the Role resource for more info about roles.

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

DefaultChannelRoleSidSID<RL>Optional

The channel role assigned to users when they are added to a channel. See the Role resource for more info about roles.

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

DefaultChannelCreatorRoleSidSID<RL>Optional

The channel role assigned to a channel creator when they join a new channel. See the Role resource for more info about roles.

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

ReadStatusEnabledbooleanOptional

Whether to enable the Message Consumption Horizon feature. The default is true.


ReachabilityEnabledbooleanOptional

Whether to enable the Reachability Indicator for this Service instance. The default is false.


TypingIndicatorTimeoutintegerOptional

How long in seconds after a started typing event until clients should assume that user is no longer typing, even if no ended typing message was received. The default is 5 seconds.


ConsumptionReportIntervalintegerOptional

DEPRECATED. The interval in seconds between consumption reports submission batches from client endpoints.


Notifications.NewMessage.EnabledbooleanOptional

Whether to send a notification when a new message is added to a channel. The default is false.


Notifications.NewMessage.TemplatestringOptional

The template to use to create the notification text displayed when a new message is added to a channel and notifications.new_message.enabled is true.


Notifications.NewMessage.SoundstringOptional

The name of the sound to play when a new message is added to a channel and notifications.new_message.enabled is true.


Notifications.NewMessage.BadgeCountEnabledbooleanOptional

Whether the new message badge is enabled. The default is false.


Notifications.AddedToChannel.EnabledbooleanOptional

Whether to send a notification when a member is added to a channel. The default is false.


Notifications.AddedToChannel.TemplatestringOptional

The template to use to create the notification text displayed when a member is added to a channel and notifications.added_to_channel.enabled is true.


Notifications.AddedToChannel.SoundstringOptional

The name of the sound to play when a member is added to a channel and notifications.added_to_channel.enabled is true.


Notifications.RemovedFromChannel.EnabledbooleanOptional

Whether to send a notification to a user when they are removed from a channel. The default is false.


Notifications.RemovedFromChannel.TemplatestringOptional

The template to use to create the notification text displayed to a user when they are removed from a channel and notifications.removed_from_channel.enabled is true.


Notifications.RemovedFromChannel.SoundstringOptional

The name of the sound to play to a user when they are removed from a channel and notifications.removed_from_channel.enabled is true.


Notifications.InvitedToChannel.EnabledbooleanOptional

Whether to send a notification when a user is invited to a channel. The default is false.


Notifications.InvitedToChannel.TemplatestringOptional

The template to use to create the notification text displayed when a user is invited to a channel and notifications.invited_to_channel.enabled is true.


Notifications.InvitedToChannel.SoundstringOptional

The name of the sound to play when a user is invited to a channel and notifications.invited_to_channel.enabled is true.


PreWebhookUrlstring<uri>Optional

The URL for pre-event webhooks, which are called by using the webhook_method. See Webhook Events for more details.


PostWebhookUrlstring<uri>Optional

The URL for post-event webhooks, which are called by using the webhook_method. See Webhook Events for more details.


WebhookMethodenum<http-method>Optional

The HTTP method to use for calls to the pre_webhook_url and post_webhook_url webhooks. Can be: POST or GET and the default is POST. See Webhook Events for more details.

Possible values:
GETPOST

WebhookFiltersarray[string]Optional

The list of webhook events that are enabled for this Service instance. See Webhook Events for more details.


Limits.ChannelMembersintegerOptional

The maximum number of Members that can be added to Channels within this Service. Can be up to 1,000.


Limits.UserChannelsintegerOptional

The maximum number of Channels Users can be a Member of within this Service. Can be up to 1,000.


Media.CompatibilityMessagestringOptional

The message to send when a media message has no text. Can be used as placeholder message.


PreWebhookRetryCountintegerOptional

The number of times to retry a call to the pre_webhook_url if the request times out (after 5 seconds) or it receives a 429, 503, or 504 HTTP response. Default retry count is 0 times, which means the call won't be retried.


PostWebhookRetryCountintegerOptional

The number of times to retry a call to the post_webhook_url if the request times out (after 5 seconds) or it receives a 429, 503, or 504 HTTP response. The default is 0, which means the call won't be retried.


Notifications.LogEnabledbooleanOptional

Whether to log notifications. The default is false.

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

_14
// Download the helper library from https://www.twilio.com/docs/node/install
_14
import twilio from "twilio";
_14
_14
// Find your Account SID and Auth Token at twilio.com/console
_14
// and set the environment variables. See http://twil.io/secure
_14
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14
const authToken = process.env.TWILIO_AUTH_TOKEN;
_14
const client = twilio(accountSid, authToken);
_14
_14
const service = await client.chat.v2
_14
.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_14
.update({ friendlyName: "FriendlyName" });
_14
_14
console.log(service.sid);

Output

_57
{
_57
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_57
"consumption_report_interval": 100,
_57
"date_created": "2015-07-30T20:00:00Z",
_57
"date_updated": "2015-07-30T20:00:00Z",
_57
"default_channel_creator_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_57
"default_channel_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_57
"default_service_role_sid": "RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_57
"friendly_name": "FriendlyName",
_57
"limits": {
_57
"channel_members": 500,
_57
"user_channels": 600
_57
},
_57
"links": {
_57
"channels": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels",
_57
"users": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users",
_57
"roles": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Roles",
_57
"bindings": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings"
_57
},
_57
"notifications": {
_57
"log_enabled": true,
_57
"added_to_channel": {
_57
"enabled": false,
_57
"template": "notifications.added_to_channel.template"
_57
},
_57
"invited_to_channel": {
_57
"enabled": false,
_57
"template": "notifications.invited_to_channel.template"
_57
},
_57
"new_message": {
_57
"enabled": false,
_57
"template": "notifications.new_message.template",
_57
"badge_count_enabled": true
_57
},
_57
"removed_from_channel": {
_57
"enabled": false,
_57
"template": "notifications.removed_from_channel.template"
_57
}
_57
},
_57
"post_webhook_url": "post_webhook_url",
_57
"pre_webhook_url": "pre_webhook_url",
_57
"pre_webhook_retry_count": 2,
_57
"post_webhook_retry_count": 3,
_57
"reachability_enabled": false,
_57
"read_status_enabled": false,
_57
"sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_57
"typing_indicator_timeout": 100,
_57
"url": "https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_57
"webhook_filters": [
_57
"webhook_filters"
_57
],
_57
"webhook_method": "webhook_method",
_57
"media": {
_57
"size_limit_mb": 150,
_57
"compatibility_message": "new media compatibility message"
_57
}
_57
}


Delete a Service resource

delete-a-service-resource page anchor
DELETE https://chat.twilio.com/v2/Services/{Sid}

Property nameTypeRequiredPIIDescription
SidSID<IS>required

The SID of the Service resource to delete.

Pattern: ^IS[0-9a-fA-F]{32}$Min length: 34Max length: 34
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
import twilio from "twilio";
_10
_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 = twilio(accountSid, authToken);
_10
_10
await client.chat.v2.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").remove();


Rate this page: