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 is Generally Available.
Public Beta products are not covered by a Twilio SLA.
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.
The Services resource of Messaging represents a set of configurable behavior for sending and receiving Messages.
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:
https://messaging.twilio.com/v1
The unique string that we created to identify the Service resource.
^MG[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Account that created the Service resource.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The date and time in GMT when the resource was created specified in ISO 8601 format.
The date and time in GMT when the resource was last updated specified in ISO 8601 format.
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.
The HTTP method we use to call inbound_request_url
. Can be GET
or POST
.
GET
POST
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.
The HTTP method we use to call fallback_url
. Can be: GET
or POST
.
GET
POST
The URL we call to pass status updates about message delivery.
Whether to enable the MMS Converter for messages sent through the Service instance.
Whether to enable Smart Encoding for messages sent through the Service instance.
[OBSOLETE] Former feature used to fallback to long code sender after certain short code message failures.
Whether to enable Area Code Geomatch on the Service Instance.
How long, in seconds, messages sent from the Service are valid. Can be an integer from 1
to 14,400
.
0
A string that describes the scenario in which the Messaging Service will be used. Possible values are notifications
, marketing
, verification
, discussion
, poll
, undeclared
.
Whether US A2P campaign is registered for this Service.
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.
POST https://messaging.twilio.com/v1/Services
application/x-www-form-urlencoded
A descriptive string that you create to describe the resource. It can be up to 64 characters long.
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.
The HTTP method we should use to call inbound_request_url
. Can be GET
or POST
and the default is POST
.
GET
POST
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.
The HTTP method we should use to call fallback_url
. Can be: GET
or POST
.
GET
POST
The URL we should call to pass status updates about message delivery.
Whether to enable the MMS Converter for messages sent through the Service instance.
Whether to enable Smart Encoding for messages sent through the Service instance.
[OBSOLETE] Former feature used to fallback to long code sender after certain short code message failures.
How long, in seconds, messages sent from the Service are valid. Can be an integer from 1
to 14,400
.
A string that describes the scenario in which the Messaging Service will be used. Possible values are notifications
, marketing
, verification
, discussion
, poll
, undeclared
.
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.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createService() {11const service = await client.messaging.v1.services.create({12friendlyName: "FriendlyName",13});1415console.log(service.sid);16}1718createService();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"date_created": "2015-07-30T20:12:31Z",5"date_updated": "2015-07-30T20:12:33Z",6"friendly_name": "FriendlyName",7"inbound_request_url": "https://www.example.com/",8"inbound_method": "POST",9"fallback_url": "https://www.example.com",10"fallback_method": "GET",11"status_callback": "https://www.example.com",12"sticky_sender": true,13"smart_encoding": false,14"mms_converter": true,15"fallback_to_long_code": true,16"scan_message_content": "inherit",17"area_code_geomatch": true,18"validity_period": 600,19"synchronous_validation": true,20"usecase": "marketing",21"us_app_to_person_registered": false,22"use_inbound_webhook_on_number": true,23"sending_windows": [],24"links": {25"phone_numbers": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers",26"short_codes": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes",27"alpha_senders": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders",28"messages": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",29"us_app_to_person": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p",30"us_app_to_person_usecases": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/Usecases",31"channel_senders": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ChannelSenders"32},33"url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"34}
GET https://messaging.twilio.com/v1/Services/{Sid}
The SID of the Service resource to fetch.
^MG[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchService() {11const service = await client.messaging.v112.services("MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.fetch();1415console.log(service.sid);16}1718fetchService();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"date_created": "2015-07-30T20:12:31Z",5"date_updated": "2015-07-30T20:12:33Z",6"friendly_name": "My Service!",7"inbound_request_url": "https://www.example.com/",8"inbound_method": "POST",9"fallback_url": null,10"fallback_method": "POST",11"status_callback": "https://www.example.com",12"sticky_sender": true,13"mms_converter": true,14"smart_encoding": false,15"fallback_to_long_code": true,16"area_code_geomatch": true,17"validity_period": 600,18"scan_message_content": "inherit",19"synchronous_validation": true,20"usecase": "marketing",21"us_app_to_person_registered": false,22"use_inbound_webhook_on_number": true,23"sending_windows": [24{25"start_time": "10:00",26"end_time": "21:00"27}28],29"links": {30"phone_numbers": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers",31"short_codes": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes",32"alpha_senders": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders",33"messages": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",34"us_app_to_person": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p",35"us_app_to_person_usecases": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/Usecases",36"channel_senders": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ChannelSenders"37},38"url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"39}
GET https://messaging.twilio.com/v1/Services
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listService() {11const services = await client.messaging.v1.services.list({ limit: 20 });1213services.forEach((s) => console.log(s.sid));14}1516listService();
1{2"meta": {3"page": 0,4"page_size": 20,5"first_page_url": "https://messaging.twilio.com/v1/Services?PageSize=20&Page=0",6"previous_page_url": null,7"next_page_url": null,8"key": "services",9"url": "https://messaging.twilio.com/v1/Services?PageSize=20&Page=0"10},11"services": [12{13"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"friendly_name": "My Service!",15"sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",16"date_created": "2015-07-30T20:12:31Z",17"date_updated": "2015-07-30T20:12:33Z",18"sticky_sender": true,19"mms_converter": true,20"smart_encoding": false,21"fallback_to_long_code": true,22"area_code_geomatch": true,23"validity_period": 600,24"scan_message_content": "inherit",25"synchronous_validation": true,26"inbound_request_url": "https://www.example.com/",27"inbound_method": "POST",28"fallback_url": null,29"fallback_method": "POST",30"status_callback": "https://www.example.com",31"usecase": "marketing",32"us_app_to_person_registered": false,33"use_inbound_webhook_on_number": false,34"sending_windows": [35{36"start_time": "10:00",37"end_time": "21:00"38}39],40"links": {41"phone_numbers": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers",42"short_codes": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes",43"alpha_senders": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders",44"messages": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",45"us_app_to_person": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p",46"us_app_to_person_usecases": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/Usecases",47"channel_senders": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ChannelSenders"48},49"url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"50}51]52}
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.
The SID of the Service resource to update.
^MG[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
application/x-www-form-urlencoded
A descriptive string that you create to describe the resource. It can be up to 64 characters long.
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.
The HTTP method we should use to call inbound_request_url
. Can be GET
or POST
and the default is POST
.
GET
POST
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.
The HTTP method we should use to call fallback_url
. Can be: GET
or POST
.
GET
POST
The URL we should call to pass status updates about message delivery.
Whether to enable the MMS Converter for messages sent through the Service instance.
Whether to enable Smart Encoding for messages sent through the Service instance.
[OBSOLETE] Former feature used to fallback to long code sender after certain short code message failures.
How long, in seconds, messages sent from the Service are valid. Can be an integer from 1
to 14,400
.
A string that describes the scenario in which the Messaging Service will be used. Possible values are notifications
, marketing
, verification
, discussion
, poll
, undeclared
.
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.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function updateService() {11const service = await client.messaging.v112.services("MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.update({ friendlyName: "FriendlyName" });1415console.log(service.sid);16}1718updateService();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"friendly_name": "FriendlyName",4"sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"date_created": "2015-07-30T20:12:31Z",6"date_updated": "2015-07-30T20:12:33Z",7"sticky_sender": false,8"mms_converter": true,9"smart_encoding": false,10"fallback_to_long_code": true,11"scan_message_content": "inherit",12"synchronous_validation": true,13"area_code_geomatch": true,14"validity_period": 600,15"inbound_request_url": "https://www.example.com",16"inbound_method": "POST",17"fallback_url": null,18"fallback_method": "POST",19"status_callback": "https://www.example.com",20"usecase": "marketing",21"us_app_to_person_registered": false,22"use_inbound_webhook_on_number": true,23"sending_windows": [],24"links": {25"phone_numbers": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers",26"short_codes": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ShortCodes",27"alpha_senders": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders",28"messages": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",29"us_app_to_person": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p",30"us_app_to_person_usecases": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Compliance/Usa2p/Usecases",31"channel_senders": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ChannelSenders"32},33"url": "https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"34}
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.
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.
The SID of the Service resource to delete.
^MG[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function deleteService() {11await client.messaging.v112.services("MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.remove();14}1516deleteService();