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

Service Resource


(warning)

Public Beta

The Service Resource is currently available as a Public Beta product. This means that some features for configuring your Messaging Service via the REST API are not yet implemented, and others may be changed before the product is declared Generally Available. Messaging Service Configuration through the Twilio Console(link takes you to an external page) is Generally Available.

Public Beta products are not covered by a Twilio SLA(link takes you to an external page).

The resources for sending Messages with a Messaging Service are Generally Available.

When sending a message with a Messaging Service, you can improve message performance by enabling the included features.

Developers can associate phone numbers, short codes, and alpha sender IDs to an instance of a Messaging Service. The Service handles all inbound and outbound behaviors for the phone numbers and shortcodes.

Twilio Console

You can manage your Messaging Services through the Twilio Console when logged in.(link takes you to an external page)


Messaging Services Resource

messaging-services-resource page anchor

The Services resource of Messaging represents a set of configurable behavior for sending and receiving Messages.

Subresources

subresources page anchor

The Services resource also has phone numbers, short codes, and alpha sender IDs subresources for managing the phone numbers, short codes, and alpha sender IDs associated with the Service.

All URLs in this documentation use the following base URL:


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


sidSID<MG>
Not PII

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

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

account_sidSID<AC>

The SID of the Account(link takes you to an external page) that created the Service resource.

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

friendly_namestring

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.


inbound_request_urlstring<uri>

The URL we call using inbound_method when a message is received by any phone number or short code in the Service. When this property is null, receiving inbound messages is disabled. All messages sent to the Twilio phone number or short code will not be logged and received on the Account. If the use_inbound_webhook_on_number field is enabled then the webhook url defined on the phone number will override the inbound_request_url defined for the Messaging Service.


inbound_methodenum<http-method>

The HTTP method we use to call inbound_request_url. Can be GET or POST.

Possible values:
GETPOST

fallback_urlstring<uri>

The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. If the use_inbound_webhook_on_number field is enabled then the webhook url defined on the phone number will override the fallback_url defined for the Messaging Service.


fallback_methodenum<http-method>

The HTTP method we use to call fallback_url. Can be: GET or POST.

Possible values:
GETPOST

status_callbackstring<uri>

The URL we call to pass status updates(link takes you to an external page) about message delivery.


sticky_senderboolean

Whether to enable Sticky Sender(link takes you to an external page) on the Service instance.


mms_converterboolean

Whether to enable the MMS Converter(link takes you to an external page) for messages sent through the Service instance.


smart_encodingboolean

Whether to enable Smart Encoding(link takes you to an external page) for messages sent through the Service instance.


scan_message_contentenum<string>

Reserved.

Possible values:
inheritenabledisable

fallback_to_long_codeboolean

[OBSOLETE] Former feature used to fallback to long code sender after certain short code message failures.


area_code_geomatchboolean

Whether to enable Area Code Geomatch(link takes you to an external page) on the Service Instance.


synchronous_validationboolean

Reserved.


validity_periodinteger

How long, in seconds, messages sent from the Service are valid. Can be an integer from 1 to 14,400.


urlstring<uri>

The absolute URL of the Service resource.


linksobject<uri-map>

The absolute URLs of related resources.


usecasestring

A string that describes the scenario in which the Messaging Service will be used. Possible values are notifications, marketing, verification, discussion, poll, undeclared.


us_app_to_person_registeredboolean

Whether US A2P campaign is registered for this Service.


use_inbound_webhook_on_numberboolean

A boolean value that indicates either the webhook url configured on the phone number will be used or inbound_request_url/fallback_url url will be called when a message is received from the phone number. If this field is enabled then the webhook url defined on the phone number will override the inbound_request_url/fallback_url defined for the Messaging Service.


Create a Service resource

create-a-service-resource page anchor
POST https://messaging.twilio.com/v1/Services

FriendlyNamestringrequired

A descriptive string that you create to describe the resource. It can be up to 64 characters long.


InboundRequestUrlstring<uri>

The URL we call using inbound_method when a message is received by any phone number or short code in the Service. When this property is null, receiving inbound messages is disabled. All messages sent to the Twilio phone number or short code will not be logged and received on the Account. If the use_inbound_webhook_on_number field is enabled then the webhook url defined on the phone number will override the inbound_request_url defined for the Messaging Service.


InboundMethodenum<http-method>

The HTTP method we should use to call inbound_request_url. Can be GET or POST and the default is POST.

Possible values:
GETPOST

FallbackUrlstring<uri>

The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. If the use_inbound_webhook_on_number field is enabled then the webhook url defined on the phone number will override the fallback_url defined for the Messaging Service.


FallbackMethodenum<http-method>

The HTTP method we should use to call fallback_url. Can be: GET or POST.

Possible values:
GETPOST

StatusCallbackstring<uri>

The URL we should call to pass status updates(link takes you to an external page) about message delivery.


StickySenderboolean

Whether to enable Sticky Sender(link takes you to an external page) on the Service instance.


MmsConverterboolean

Whether to enable the MMS Converter(link takes you to an external page) for messages sent through the Service instance.


SmartEncodingboolean

Whether to enable Smart Encoding(link takes you to an external page) for messages sent through the Service instance.


ScanMessageContentenum<string>

Reserved.

Possible values:
inheritenabledisable

FallbackToLongCodeboolean

[OBSOLETE] Former feature used to fallback to long code sender after certain short code message failures.


AreaCodeGeomatchboolean

Whether to enable Area Code Geomatch(link takes you to an external page) on the Service Instance.


ValidityPeriodinteger

How long, in seconds, messages sent from the Service are valid. Can be an integer from 1 to 14,400.


SynchronousValidationboolean

Reserved.


Usecasestring

A string that describes the scenario in which the Messaging Service will be used. Possible values are notifications, marketing, verification, discussion, poll, undeclared.


UseInboundWebhookOnNumberboolean

A boolean value that indicates either the webhook url configured on the phone number will be used or inbound_request_url/fallback_url url will be called when a message is received from the phone number. If this field is enabled then the webhook url defined on the phone number will override the inbound_request_url/fallback_url defined for the Messaging Service.

Create a Service

create-a-service 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.messaging.v1.services
_10
.create({friendlyName: 'friendly_name'})
_10
.then(service => console.log(service.sid));

Output

_33
{
_33
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_33
"sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_33
"date_created": "2015-07-30T20:12:31Z",
_33
"date_updated": "2015-07-30T20:12:33Z",
_33
"friendly_name": "My Service!",
_33
"inbound_request_url": "https://www.example.com/",
_33
"inbound_method": "POST",
_33
"fallback_url": "https://www.example.com",
_33
"fallback_method": "GET",
_33
"status_callback": "https://www.example.com",
_33
"sticky_sender": true,
_33
"smart_encoding": false,
_33
"mms_converter": true,
_33
"fallback_to_long_code": true,
_33
"scan_message_content": "inherit",
_33
"area_code_geomatch": true,
_33
"validity_period": 600,
_33
"synchronous_validation": true,
_33
"usecase": "marketing",
_33
"us_app_to_person_registered": false,
_33
"use_inbound_webhook_on_number": true,
_33
"links": {
_33
"phone_numbers": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers",
_33
"short_codes": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ShortCodes",
_33
"alpha_senders": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AlphaSenders",
_33
"messages": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages",
_33
"us_app_to_person": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Compliance/Usa2p",
_33
"us_app_to_person_usecases": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Compliance/Usa2p/Usecases",
_33
"channel_senders": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ChannelSenders"
_33
},
_33
"url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_33
}


Fetch a Service resource

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

SidSID<MG>required

The SID of the Service resource to fetch.

Pattern: ^MG[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
// 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.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.fetch()
_10
.then(service => console.log(service.friendlyName));

Output

_33
{
_33
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_33
"sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_33
"date_created": "2015-07-30T20:12:31Z",
_33
"date_updated": "2015-07-30T20:12:33Z",
_33
"friendly_name": "My Service!",
_33
"inbound_request_url": "https://www.example.com/",
_33
"inbound_method": "POST",
_33
"fallback_url": null,
_33
"fallback_method": "POST",
_33
"status_callback": "https://www.example.com",
_33
"sticky_sender": true,
_33
"mms_converter": true,
_33
"smart_encoding": false,
_33
"fallback_to_long_code": true,
_33
"area_code_geomatch": true,
_33
"validity_period": 600,
_33
"scan_message_content": "inherit",
_33
"synchronous_validation": true,
_33
"usecase": "marketing",
_33
"us_app_to_person_registered": false,
_33
"use_inbound_webhook_on_number": true,
_33
"links": {
_33
"phone_numbers": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers",
_33
"short_codes": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ShortCodes",
_33
"alpha_senders": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AlphaSenders",
_33
"messages": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages",
_33
"us_app_to_person": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Compliance/Usa2p",
_33
"us_app_to_person_usecases": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Compliance/Usa2p/Usecases",
_33
"channel_senders": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ChannelSenders"
_33
},
_33
"url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_33
}


Read multiple Service resources

read-multiple-service-resources page anchor
GET https://messaging.twilio.com/v1/Services

PageSizeinteger

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

Minimum: 1Maximum: 1000

Pageinteger

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

Minimum: 0

PageTokenstring

The page token. This is provided by the API.

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.messaging.v1.services
_10
.list({limit: 20})
_10
.then(services => services.forEach(s => console.log(s.sid)));

Output

_52
{
_52
"meta": {
_52
"page": 0,
_52
"page_size": 20,
_52
"first_page_url": "https://messaging.twilio.com/v1/Services?PageSize=20&Page=0",
_52
"previous_page_url": "https://messaging.twilio.com/v1/Services?PageSize=20&Page=0",
_52
"next_page_url": "https://messaging.twilio.com/v1/Services?PageSize=20&Page=1",
_52
"key": "services",
_52
"url": "https://messaging.twilio.com/v1/Services?PageSize=20&Page=0"
_52
},
_52
"services": [
_52
{
_52
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_52
"friendly_name": "My Service!",
_52
"sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_52
"date_created": "2015-07-30T20:12:31Z",
_52
"date_updated": "2015-07-30T20:12:33Z",
_52
"sticky_sender": true,
_52
"mms_converter": true,
_52
"smart_encoding": false,
_52
"fallback_to_long_code": true,
_52
"area_code_geomatch": true,
_52
"validity_period": 600,
_52
"scan_message_content": "inherit",
_52
"synchronous_validation": true,
_52
"inbound_request_url": "https://www.example.com/",
_52
"inbound_method": "POST",
_52
"fallback_url": null,
_52
"fallback_method": "POST",
_52
"status_callback": "https://www.example.com",
_52
"usecase": "marketing",
_52
"us_app_to_person_registered": false,
_52
"use_inbound_webhook_on_number": false,
_52
"sending_windows": [
_52
{
_52
"start_time": "10:00",
_52
"end_time": "21:00"
_52
}
_52
],
_52
"links": {
_52
"phone_numbers": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers",
_52
"short_codes": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ShortCodes",
_52
"alpha_senders": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AlphaSenders",
_52
"messages": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages",
_52
"us_app_to_person": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Compliance/Usa2p",
_52
"us_app_to_person_usecases": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Compliance/Usa2p/Usecases",
_52
"channel_senders": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ChannelSenders"
_52
},
_52
"url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_52
}
_52
]
_52
}


Update a Service resource

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

You may specify one or more of the optional parameters above to update the Service's respective properties. Parameters not specified in your request are not updated.

SidSID<MG>required

The SID of the Service resource to update.

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

A descriptive string that you create to describe the resource. It can be up to 64 characters long.


InboundRequestUrlstring<uri>

The URL we call using inbound_method when a message is received by any phone number or short code in the Service. When this property is null, receiving inbound messages is disabled. All messages sent to the Twilio phone number or short code will not be logged and received on the Account. If the use_inbound_webhook_on_number field is enabled then the webhook url defined on the phone number will override the inbound_request_url defined for the Messaging Service.


InboundMethodenum<http-method>

The HTTP method we should use to call inbound_request_url. Can be GET or POST and the default is POST.

Possible values:
GETPOST

FallbackUrlstring<uri>

The URL that we call using fallback_method if an error occurs while retrieving or executing the TwiML from the Inbound Request URL. If the use_inbound_webhook_on_number field is enabled then the webhook url defined on the phone number will override the fallback_url defined for the Messaging Service.


FallbackMethodenum<http-method>

The HTTP method we should use to call fallback_url. Can be: GET or POST.

Possible values:
GETPOST

StatusCallbackstring<uri>

The URL we should call to pass status updates(link takes you to an external page) about message delivery.


StickySenderboolean

Whether to enable Sticky Sender(link takes you to an external page) on the Service instance.


MmsConverterboolean

Whether to enable the MMS Converter(link takes you to an external page) for messages sent through the Service instance.


SmartEncodingboolean

Whether to enable Smart Encoding(link takes you to an external page) for messages sent through the Service instance.


ScanMessageContentenum<string>

Reserved.

Possible values:
inheritenabledisable

FallbackToLongCodeboolean

[OBSOLETE] Former feature used to fallback to long code sender after certain short code message failures.


AreaCodeGeomatchboolean

Whether to enable Area Code Geomatch(link takes you to an external page) on the Service Instance.


ValidityPeriodinteger

How long, in seconds, messages sent from the Service are valid. Can be an integer from 1 to 14,400.


SynchronousValidationboolean

Reserved.


Usecasestring

A string that describes the scenario in which the Messaging Service will be used. Possible values are notifications, marketing, verification, discussion, poll, undeclared.


UseInboundWebhookOnNumberboolean

A boolean value that indicates either the webhook url configured on the phone number will be used or inbound_request_url/fallback_url url will be called when a message is received from the phone number. If this field is enabled then the webhook url defined on the phone number will override the inbound_request_url/fallback_url defined for the Messaging Service.

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.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.update({friendlyName: 'friendly_name'})
_10
.then(service => console.log(service.friendlyName));

Output

_33
{
_33
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_33
"friendly_name": "My Service!",
_33
"sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_33
"date_created": "2015-07-30T20:12:31Z",
_33
"date_updated": "2015-07-30T20:12:33Z",
_33
"sticky_sender": false,
_33
"mms_converter": true,
_33
"smart_encoding": false,
_33
"fallback_to_long_code": true,
_33
"scan_message_content": "inherit",
_33
"synchronous_validation": true,
_33
"area_code_geomatch": true,
_33
"validity_period": 600,
_33
"inbound_request_url": "https://www.example.com",
_33
"inbound_method": "POST",
_33
"fallback_url": null,
_33
"fallback_method": "POST",
_33
"status_callback": "https://www.example.com",
_33
"usecase": "marketing",
_33
"us_app_to_person_registered": false,
_33
"use_inbound_webhook_on_number": true,
_33
"links": {
_33
"phone_numbers": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers",
_33
"short_codes": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ShortCodes",
_33
"alpha_senders": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AlphaSenders",
_33
"messages": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages",
_33
"us_app_to_person": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Compliance/Usa2p",
_33
"us_app_to_person_usecases": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Compliance/Usa2p/Usecases",
_33
"channel_senders": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ChannelSenders"
_33
},
_33
"url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_33
}


Delete a Service resource

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

When a Service is deleted, all phone numbers and short codes in the Service are returned to your Account.

(warning)

Warning

If you are using a Messaging Service for A2P 10DLC, you should not delete the Messaging Service. Doing so deletes the A2P 10DLC Campaign, which immediately halts all US A2P 10DLC messaging. A new Campaign and Messaging Service must be created and re-registered. This process can take several days.

SidSID<MG>required

The SID of the Service resource to delete.

Pattern: ^MG[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
// 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.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove();


Rate this page: