Skip to main content

Create a message

Use this endpoint for the Media method to send an outbound message from one of your SignalWire phone numbers.

Parameters

ParameterDescription
To RequiredThe recipient of the outbound message formatted in E.164 format.
From RequiredOne of your SignalWire phone numbers or short codes used as the sender of the message. You must use one of your project's phone numbers or short codes that you have purchased from SignalWire and which are capable of messaging.
Body required*if MediaUrl is not presentThe body of the message you want to send, up to a maximum of 1600 characters per message.
MediaUrl required*if Body is not presentURL of media you wish to attach and send with the message. Include multiple MediaUrl arguments if you which to send more than one media per message, up to a maximum of 10 media URLs per message. There is a limit of 5MB for the total combined media size per message. See the MIME Types section for a full list of content types supported by SignalWire.
ApplicationSid OptionalThe SID of a SignalWire CXML application used to configure the message's MessageStatusCallback attribute. If ApplicationSid and StatusCallback are specified, StatusCallback will take precedence.
MaxPrice OptionalThe maximum price in USD acceptable for the message to be sent. Once your message is queued, the cost to send the message is calculated and if it is greater than MaxPrice, the message will be set as failed and not sent. You will not be charged. If MaxPrice is not set, all messages will be sent. The price can have a maximum of four decimal places, i.e. 0.0075.
StatusCallback OptionalA URL endpoint to receive callbacks each time the status of the message changes from queued, failed, sent, delivered or undelivered. See detailed information on the status callback parameters sent during the callback.
ValidityPeriod OptionalThe number of seconds a message will allow being queued before canceling. When sending high volume of messages, messages can sit in your sending queue. If the message should only be sent in in a specific timeframe, use ValidityPeriod to ensure you don't send messages after time-sensitive operations. It is not recommended to set a validity period of less than 5 seconds. Default value is 14400
MessagingServiceSid OptionalThe ID of a SignalWire Number Group to be used to automatically choose the best number from the number group to improve deliverability and optimize throughput. Only From or MessagingServiceSid need be set. If MessagingServiceSid is set, it will take precedence over any value of From.

Request

In this example, we will send an outbound message from one of your SignalWire phone numbers.

curl https://example.signalwire.com/api/laml/2010-04-01/Accounts/{AccountSid}/Messages.json \
-X POST \
--data-urlencode "From=+15551234567" \
--data-urlencode "Body=Hello World\!" \
--data-urlencode "To=+15557654321" \
-u "YourProjectID:YourAuthToken"

Responses

201 CREATED

{
"account_sid": "ea108133-d6b3-407c-9536-9fad8a929a6a",
"api_version": "2010-04-01",
"body": "Hello World",
"num_segments": 1,
"num_media": 0,
"date_created": "Mon, 13 Aug 2018 23:08:35 +0000",
"date_sent": null,
"date_updated": "Mon, 13 Aug 2018 23:08:35 +0000",
"direction": "outbound-api",
"error_code": null,
"error_message": null,
"from": "+15551234567",
"price": null,
"price_unit": "USD",
"sid": "b3877c40-da60-4998-90ad-b792e98472af",
"status": "queued",
"to": "+15557654321",
"messaging_service_sid": null,
"uri": "/api/laml/2010-04-01/Accounts/ea108133-d6b3-407c-9536-9fad8a929a6a/Messages/b3877c40-da60-4998-90ad-b792e98472af",
"subresource_uris": {
"media": "/api/laml/2010-04-01/Accounts/ea108133-d6b3-407c-9536-9fad8a929a6a/Messages/b3877c40-da60-4998-90ad-b792e98472af/Media"
}
}