Api20100401Message

Send a message

post/2010-04-01/Accounts/{AccountSid}/Messages.json

Request

  • Base URL
    https://api.twilio.com
  • URL
    https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Messages.json
  • Auth
    HTTP basic

Path parameters

AccountSidstring required

The SID of the Account creating the Message resource.

Request body application/x-www-form-urlencoded

Tostring phone-number required

The recipient's phone number in E.164 format (for SMS/MMS) or channel address, e.g. whatsapp:+15552229999.

StatusCallbackstring uri

The URL of the endpoint to which Twilio sends Message status callback requests. URL must contain a valid hostname and underscores are not allowed. If you include this parameter with the messaging_service_sid, Twilio uses this URL instead of the Status Callback URL of the Messaging Service.

ApplicationSidstring

The SID of the associated TwiML Application. Message status callback requests are sent to the TwiML App's message_status_callback URL. Note that the status_callback parameter of a request takes priority over the application_sid parameter; if both are included application_sid is ignored.

MaxPricenumber

[OBSOLETE] This parameter will no longer have any effect as of 2024-06-03.

ProvideFeedbackboolean

Boolean indicating whether or not you intend to provide delivery confirmation feedback to Twilio (used in conjunction with the Message Feedback subresource). Default value is false.

Attemptinteger

Total number of attempts made (including this request) to send the message regardless of the provider used

ValidityPeriodinteger

The maximum length in seconds that the Message can remain in Twilio's outgoing message queue. If a queued Message exceeds the validity_period, the Message is not sent. Accepted values are integers from 1 to 36000. Default value is 36000. A validity_period greater than 5 is recommended. Learn more about the validity period

ForceDeliveryboolean

Reserved

ContentRetention'retain' | 'discard'

Determines if the message content can be stored or redacted based on privacy settings

AddressRetention'retain' | 'obfuscate'

Determines if the address can be stored or obfuscated based on privacy settings

SmartEncodedboolean

Whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be: true or false.

PersistentActionstring[]

Rich actions for non-SMS/MMS channels. Used for sending location in WhatsApp messages.

TrafficType'free'
ShortenUrlsboolean

For Messaging Services with Link Shortening configured only: A Boolean indicating whether or not Twilio should shorten links in the body of the Message. Default value is false. If true, the messaging_service_sid parameter must also be provided.

ScheduleType'fixed'

For Messaging Services only: Include this parameter with a value of fixed in conjuction with the send_time parameter in order to schedule a Message.

SendAtstring date-time

The time that Twilio will send the message. Must be in ISO 8601 format.

SendAsMmsboolean

If set to true, Twilio delivers the message as a single MMS message, regardless of the presence of media.

ContentVariablesstring

For Content Editor/API only: Key-value pairs of Template variables and their substitution values. content_sid parameter must also be provided. If values are not defined in the content_variables parameter, the Template's default placeholder values are used.

MessageIntentstring

Specifies the purpose or use case of the outbound communication. This parameter is used by Twilio's Traffic Shaping and Compliance Toolkit products. Possible values include: otp, notifications, marketing, fraud, security, customercare, delivery, education, polling, announcements, and events.

RiskCheck'enable' | 'disable'

Include this parameter with a value of disable to skip any kind of risk check on the respective message request.

Fromstring phone-number

The sender's Twilio phone number (in E.164 format), alphanumeric sender ID, Wireless SIM, short code, or channel address (e.g., whatsapp:+15554449999). The value of the from parameter must be a sender that is hosted within Twilio and belongs to the Account creating the Message. If you are using messaging_service_sid, this parameter can be empty (Twilio assigns a from value from the Messaging Service's Sender Pool) or you can provide a specific sender from your Sender Pool.

FallbackFromstring phone-number

A fallback SMS sender to use when the recipient cannot be reached over RCS. This parameter may only be used when also providing a Messaging Service containing an RCS sender. The fallback SMS sender must be either a Twilio phone number (in E.164 format), alphanumeric sender ID, or short code, hosted within Twilio and belong to the Account creating the Message.

MessagingServiceSidstring

The SID of the Messaging Service you want to associate with the Message. When this parameter is provided and the from parameter is omitted, Twilio selects the optimal sender from the Messaging Service's Sender Pool. You may also provide a from parameter if you want to use a specific Sender from the Sender Pool.

Bodystring

The text content of the outgoing message. Can be up to 1,600 characters in length. SMS only: If the body contains more than 160 GSM-7 characters (or 70 UCS-2 characters), the message is segmented and charged accordingly. For long body text, consider using the send_as_mms parameter.

MediaUrlstring[]

The URL of media to include in the Message content. jpeg, jpg, gif, and png file types are fully supported by Twilio and content is formatted for delivery on destination devices. The media size limit is 5 MB for supported file types (jpeg, jpg, png, gif) and 500 KB for other types of accepted media. To send more than one image in the message, provide multiple media_url parameters in the POST request. You can include up to ten media_url parameters per message. International and carrier limits apply.

ContentSidstring

For Content Editor/API only: The SID of the Content Template to be used with the Message, e.g., HXXXXXXXXXXXXXXXXXXXXXXXXXXXXX. If this parameter is not provided, a Content Template is not used. Find the SID in the Console on the Content Editor page. For Content API users, the SID is found in Twilio's response when creating the Template or by fetching your Templates.

Response

Created

bodystring nullable

The text content of the message

num_segmentsstring nullable

The number of segments that make up the complete message. SMS message bodies that exceed the character limit are segmented and charged as multiple messages. Note: For messages sent via a Messaging Service, num_segments is initially 0, since a sender hasn't yet been assigned.

direction'inbound' | 'outbound-api' | 'outbound-call' | 'outbound-reply'

The direction of the message. Can be: inbound for incoming messages, outbound-api for messages created by the REST API, outbound-call for messages created during a call, or outbound-reply for messages created in response to an incoming message.

fromstring phone-number nullable

The sender's phone number (in E.164 format), alphanumeric sender ID, Wireless SIM, short code, or channel address (e.g., whatsapp:+15554449999). For incoming messages, this is the number or channel address of the sender. For outgoing messages, this value is a Twilio phone number, alphanumeric sender ID, short code, or channel address from which the message is sent.

tostring nullable

The recipient's phone number (in E.164 format) or channel address (e.g. whatsapp:+15552229999)

date_updatedstring date-time-rfc-2822 nullable

The RFC 2822 timestamp (in GMT) of when the Message resource was last updated

pricestring nullable

The amount billed for the message in the currency specified by price_unit. The price is populated after the message has been sent/received, and may not be immediately availalble. View the Pricing page for more details.

error_messagestring nullable

The description of the error_code if the Message status is failed or undelivered. If no error was encountered, the value is null. The value returned in this field for a specific error cause is subject to change as Twilio improves errors. Users should not use the error_code and error_message fields programmatically.

uristring nullable

The URI of the Message resource, relative to https://api.twilio.com.

account_sidstring nullable

The SID of the Account associated with the Message resource

num_mediastring nullable

The number of media files associated with the Message resource.

status'queued' | 'sending' | 'sent' | 'failed' | 'delivered' | 'undelivered' | 'receiving' | 'received' | 'accepted' | 'scheduled' | 'read' | 'partially_delivered' | 'canceled'

The status of the Message. Possible values: accepted, scheduled, canceled, queued, sending, sent, failed, delivered, undelivered, receiving, received, or read (WhatsApp only). For more information, See detailed descriptions.

messaging_service_sidstring nullable

The SID of the Messaging Service associated with the Message resource. A unique default value is assigned if a Messaging Service is not used.

sidstring nullable

The unique, Twilio-provided string that identifies the Message resource.

date_sentstring date-time-rfc-2822 nullable

The RFC 2822 timestamp (in GMT) of when the Message was sent. For an outgoing message, this is when Twilio sent the message. For an incoming message, this is when Twilio sent the HTTP request to your incoming message webhook URL.

date_createdstring date-time-rfc-2822 nullable

The RFC 2822 timestamp (in GMT) of when the Message resource was created

error_codeinteger nullable

The error code returned if the Message status is failed or undelivered. If no error was encountered, the value is null. The value returned in this field for a specific error cause is subject to change as Twilio improves errors. Users should not use the error_code and error_message fields programmatically.

price_unitstring currency nullable

The currency in which price is measured, in ISO 4127 format (e.g. usd, eur, jpy).

api_versionstring nullable

The API version used to process the Message

subresource_urisobject nullable

A list of related resources identified by their URIs relative to https://api.twilio.com

Changes