Skip to main content

Create a Message

POST 

/Accounts/:AccountSid/Messages

Create a message.

Permissions

The API token must include the following scopes: Messaging.

Request

Path Parameters

    AccountSid uuidrequired

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

Body

    Tostringrequired

    The phone number in E.164 format that received the message. For inbound messages, this is one of your SignalWire phone numbers; for outbound messages, this is the remote phone number that received the message.

    Example: +15557654321
    Fromstringrequired

    The phone number in E.164 format. For inbound messages, this will be the remote phone number who sent the message. For outbound messages, this will be one of your SignalWire phone numbers.

    Example: +15551234567
    Bodystringrequired

    The text of the message. Up to 1600 characters long and can be null if no message was sent.

    Example: Hello World!
    MediaUrlstringrequired

    URL 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.

    ApplicationSidstring

    The SID of a SignalWire cXML bin used to configure the message's MessageStatusCallback attribute. If ApplicationSid and StatusCallback are specified, StatusCallback will take precedence.

    Example: null
    MaxPricestring

    The 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.

    Example: 0.0075
    StatusCallbackstring

    A URL endpoint to receive callbacks each time the status of the message changes from queued, failed, sent, delivered or undelivered.

    ValidityPeriodinteger

    The 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

    Example: 14400
    MessagingServiceSidstring

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

    Example: null

Responses

OK

Schema

    account_siduuid

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

    Example: ea108133-d6b3-407c-9536-9fad8a929a6a
    api_versionstring

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

    Example: 2010-04-01
    bodystring

    The text of the message. Up to 1600 characters long and can be null if no message was sent.

    Example: Hello World!
    num_segmentsinteger

    The number of segments that make up the entire message. If the body of the message is larger than 160 GSM-7 characters or 70 UCS-2 characters, it will automatically be broken up into smaller messages and annotated to attempt proper reconstruction on the recipient handset. Not all carriers and handsets support this. SignalWire will recombine inbound messages into a single message. Your project will be charged for each segment sent or received.

    Example: 1
    num_mediastring

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

    Example: 1
    date_createdstring

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

    Example: Mon, 13 Aug 2018 21:38:46 +0000
    date_sentstring

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

    Example: null
    date_updatedstring

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

    Example: Mon, 13 Aug 2018 21:38:46 +0000
    directionstring

    The direction of the message.

    Possible values: [inbound, outbound-api, outbound-call, outbound-reply]

    Example: outbound-api
    error_codestring

    If an error has occurred on the message, the error code will give you a specific code to help lookup more information on the failure. If no error occurred, error_code will be null.

    Example: null
    error_messagestring

    A human readable description of the error that occurred. If no error occurred, error_message will be null.

    Example: null
    fromstring

    The phone number in E.164 format. For inbound messages, this will be the remote phone number who sent the message. For outbound messages, this will be one of your SignalWire phone numbers.

    Example: +15551234567
    priceinteger

    The cost of the individual message billed to your project.

    Example: 0.005
    price_unitstring

    The currency in which price is charged as.

    Example: USD
    sidstring

    A unique ID that identifies this specific message.

    Example: 0a059168-ead0-41af-9d1f-343dae832527
    statusstring

    Current status of the message.

    Possible values: [queued, sending, sent, delivered, undelivered, failed, receiving, received]

    Example: sent
    tostring

    The phone number in E.164 format that received the message. For inbound messages, this is one of your SignalWire phone numbers; for outbound messages, this is the remote phone number that received the message.

    Example: +15557654321
    messaging_service_sidstring

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

    Example: null
    uristring

    The URI of this particular message.

    Example: /api/laml/2010-04-01/Accounts/ea108133-d6b3-407c-9536-9fad8a929a6a/Messages/0a059168-ead0-41af-9d1f-343dae832527

    subresource_uris

    object

    The URIs for any subresources associated with this message.

    mediastring
    Example: /api/laml/2010-04-01/Accounts/ea108133-d6b3-407c-9536-9fad8a929a6a/Messages/0a059168-ead0-41af-9d1f-343dae832527/Media