Docs

Message controller

https://api.apifonica.com/v2/accounts/{accountSID}/messages

Overview

Message controller allows you to be informed on the current message status and also send XML instructions in response.

You will need to create an Application and specify controller URL for it. Then use this application’s SID when making the Send message request. Thus Apifonica will be able to notify you every time a message status changes.

Request example

curl –X POST https://api.apifonica.com/v2/accounts/{accountSID}/messages \
-H ‘Content-Type: application/json’ \
-d ‘{
        "from": "35315313424",
        "to": "447860041755",
        "msg_app_sid": "app0794c1fe-b34b-3d89-bc91-faf37a343f83",
        "text": "Apifonica API provides a really cool SMS messaging service"
    }' \
-u {accountSID}:{authToken}

Response example

{
  "status_code": 201,
  "status_message": "CREATED",
  "uri": "/v2/accounts/{accountSID}/messages/{messageSID}"
}

Apifonica request parameters being sent to controller url

The following parameters are sent to controller URL specified in msg_app_sid.
{
  account_sid: '{accountSID}',
  direction: 'outbound',
  from: '35315313424',
  message_sid: '{messageSID}',
  sms_count: '1',
  status: 'sent',
  text: 'Apifonica API provides a really cool SMS messaging service',
  to: '447860041755'
}
ParameterDescription
account_sid

Account unique identifier.

direction

inbound or outbound.

from

Sender’s phone number.

message_sid

Message unique identifier.

sms_count

Number of parts in the message

status

The current message status.

For more information on possible statuses, see below.

text

Message text.

to

Recipient’s phone number.

Possible message statuses

StatusDescription
prebilling

The price of the message is being calculated

queued

Message is going to be sent.

sent

Message was sent.

received

Message was received by your Apifonica number.

Works only for inbound messages.

delivered

Message was delivered to the recipient.

rejected

Message was not sent, because recipient number is not a valid mobile number.

The price is calculated by the destination country.

undeliverable

Message was sent, but not delivered.

expired

Message was sent, but not delivered. Recipient is not available for 48 hours.

failed

Message was not delivered to the recipient.

If this happens, an error message is included in Apifonica request.

msg_controller.PNG

Example of the message statuses in the controller