Messages

Create a Message

Create a message.

Permissions

The API token must include the following scopes: Messaging.

post/Accounts/{AccountSid}/Messages

Path parameters

AccountSidstring uuid required

The unique identifier of the project that sent or received this message.

Request body

Tostring required

The phone number in E.164 format that received the message.

Fromstring required

The phone number in E.164 format that sent the message.

Bodystring required

The text of the message. Up to 1600 characters long.

MediaUrlstring

URL of media you wish to attach and send with the message.

SendAsMmsboolean

When set to true, forces the message to be sent as an MMS.

ApplicationSidstring

The SID of a SignalWire cXML bin used to configure the message's MessageStatusCallback attribute.

MaxPricestring

The maximum price in USD acceptable for the message to be sent.

StatusCallbackstring

A URL endpoint to receive callbacks each time the status of the message changes.

ValidityPeriodinteger

The number of seconds a message will allow being queued before canceling. Default value is 14400.

MessagingServiceSidstring

If a number group was used when sending an outbound message, the number group's ID will be present.

Example request

{
  "To": "+15557654321",
  "From": "+15551234567",
  "Body": "Hello World!",
  "MediaUrl": "https://example.com/image.jpg",
  "ApplicationSid": "b3877c40-da60-4998-90ad-b792e98472ap",
  "MaxPrice": "0.0075",
  "StatusCallback": "https://example.com/status-callback",
  "ValidityPeriod": 14400,
  "MessagingServiceSid": "b3877c40-da60-4998-90ad-b792e98472ms"
}

Response

The request has succeeded.

account_sidstring uuid

The unique identifier of the project that sent or received this message.

api_versionstring

The version number of the SignalWire cXML REST API used to handle this message.

bodystring

The text of the message. Up to 1600 characters long.

num_segmentsinteger

The number of segments that make up the entire message.

num_mediastring

The number of media files that were included with the message.

date_createdstring

The date and time the message was created in RFC 2822 format.

date_sentstring

The date and time the message was sent in RFC 2822 format.

date_updatedstring

The date and time the message was last updated in RFC 2822 format.

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

Message direction.

error_codestring

If an error has occurred on the message, the error code will give you a specific code.

error_messagestring

A human readable description of the error that occurred.

fromstring

The phone number in E.164 format that sent the message.

pricenumber float

The cost of the individual message billed to your project.

price_unitstring

The currency in which price is charged as.

sidstring

A unique ID that identifies this specific message.

status'queued' | 'sending' | 'sent' | 'delivered' | 'undelivered' | 'failed' | 'receiving' | 'received'

Message status.

tostring

The phone number in E.164 format that received the message.

messaging_service_sidstring

If a number group was used when sending an outbound message, the number group's ID will be present.

uristring

The URI of this particular message.

Example response

{
  "account_sid": "ea108133-d6b3-407c-9536-9fad8a929a6a",
  "api_version": "2010-04-01",
  "body": "Hello World!",
  "num_segments": 1,
  "num_media": "1",
  "date_created": "Mon, 13 Aug 2018 21:38:46 +0000",
  "date_sent": "Mon, 13 Aug 2018 21:38:46 +0000",
  "date_updated": "Mon, 13 Aug 2018 21:38:46 +0000",
  "error_code": "30001",
  "error_message": "Queue overflow",
  "from": "+15551234567",
  "price": 0.005,
  "price_unit": "USD",
  "sid": "0a059168-ead0-41af-9d1f-343dae832527",
  "to": "+15557654321",
  "messaging_service_sid": "b3877c40-da60-4998-90ad-b792e98472ms",
  "uri": "/api/laml/2010-04-01/Accounts/ea108133-d6b3-407c-9536-9fad8a929a6a/Messages/0a059168-ead0-41af-9d1f-343dae832527.json",
  "subresource_uris": {
    "media": "/api/laml/2010-04-01/Accounts/ea108133-d6b3-407c-9536-9fad8a929a6a/Messages/0a059168-ead0-41af-9d1f-343dae832527/Media.json"
  }
}

Changes