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

The following cURL example demonstrates sending a message with msg_app_sid parameter:

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'
}

Parameter name

Description

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.

Description

Account unique identifier.

Description

Message unique identifier.

Description

inbound or outbound

Description

Message unique identifier.

Description

Number of parts in the message

Description

Recipient’s phone number.

Description

Message text.

Description

The current message status.

For more information on possible statuses, seebelow.

 

Possible message statuses

Status value

Description

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.

failed

Message was not delivered to the recipient.

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

Description

Message is going to be sent.

Description

Message was sent.

Description

Message was received by your Apifonica number.

Works only for inbound messages.

Description

Message was delivered to the recipient.

Description

Message was not delivered to the recipient.

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

msg_controller.PNGExample of the message statuses in the controller