Create

View as Markdown

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

Path parameters

AccountSidstringRequiredformat: "uuid"
The unique identifier of the project that sent or received this message.

Request

TostringRequired
The phone number in E.164 format that will receive the message.
FromstringOptional
The phone number in E.164 format that will send the message. Either `From` or `MessagingServiceSid` must be provided.
BodystringOptional
The text of the message. Either `Body` or `MediaUrl` must be provided.
MediaUrlstring or list of stringsOptional
URL(s) of media you wish to attach and send with the message. Can be specified multiple times for up to 8 media items.
SendAsMmsbooleanOptional
When set to true, forces the message to be sent as an MMS.
ApplicationSidstringOptionalformat: "uuid"
The SID of a SignalWire cXML Application used to configure the message's status callback.
MaxPricestringOptionalformat: "^\d+\.?\d{0,4}$"
The maximum price in USD acceptable for the message to be sent. Format: decimal with up to 4 decimal places.
StatusCallbackstringOptionalformat: "uri"
A URL endpoint to receive callbacks each time the status of the message changes. See the [SMS status callback](/docs/compatibility-api/rest/messages/webhooks/sms-status-callback) webhook for the payload your URL will receive.
ValidityPeriodintegerOptional1-172800Defaults to 14400
The number of seconds a message will allow being queued before canceling. Must be between 1 and 172800 (48 hours). Default is 14400 (4 hours).
MessagingServiceSidstringOptionalformat: "uuid"
The ID of a number group to use when sending the message. Either `From` or `MessagingServiceSid` must be provided.

Response

account_sidstringRequiredformat: "uuid"
The unique identifier of the project that sent or received this message.
api_versionstringRequired
The version number of the SignalWire cXML REST API used to handle this message.
bodystring or nullRequired
The text of the message. Up to 1600 characters long. May be null if filtered for spam.
num_segmentsintegerRequired
The number of segments that make up the entire message.
num_mediaintegerRequired
The number of media files that were included with the message.
date_createdstringRequired
The date and time the message was created in RFC 2822 format.
date_sentstring or nullRequired
The date and time the message was sent in RFC 2822 format, or null if not yet sent.
date_updatedstringRequired
The date and time the message was last updated in RFC 2822 format.
directionenumRequired
The direction of the message.
Allowed values:
error_codestring or nullRequired
If an error has occurred on the message, the error code will give you a specific code, or null if no error.
error_messagestring or nullRequired
A human readable description of the error that occurred, or null if no error.
fromstringRequired
The phone number in E.164 format that sent the message.
pricedouble or nullRequired
The cost of the individual message billed to your project, or null if not yet calculated.
price_unitstringRequired
The currency in which `price` is charged as.
sidstringRequiredformat: "uuid"
A unique ID that identifies this specific message.
statusenumRequired
Current status of the message.
tostringRequired
The phone number in E.164 format that received the message.
messaging_service_sidstring or nullRequiredformat: "uuid"
If a number group was used when sending an outbound message, the number group's ID will be present, or null otherwise.
uristringRequired
The URI of this particular message.
subresource_urisobjectRequired
The URIs for any subresources associated with this message.

Request examples

1const { RestClient } = require('@signalwire/compatibility-api')
2const client = RestClient('YourProjectID', 'YourAuthToken', { signalwireSpaceUrl: 'example.signalwire.com' })
3
4client.messages
5 .create({from: '+15551234567', body: 'Hello World!', to: '+15557654321'})
6 .then(message => console.log(message.sid))
7 .done();