Docs

Send message

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

Overview

This request sends an SMS message to a phone number. Only phone numbers rented from Apifonica can be used as senders’ numbers.

For message status control please refer to the article Message controller

XML command: sendMessage

Input parameters

Parameter

Required?

Description

Default value

from

yes

A phone number to be used as a message sender. This number must be acquired from Apifonica.

N/A

to

yes

Recipient’s phone number.

Phone numbers should be formatted with a country code (without + sign).

For example, 35315313424.

N/A

text

yes

Text of the message.

Max 160 Latin characters or 70 Unicode characters.

N/A

msg_app_sid

no

Existing application SID, which is used for Message operations.

default_msg_app_sid

channel

no

Can be one of the following: smstelegram, facebook

sms

type

no

Type of content for Telegram/Facebook. Can be one of the following: image, gif, text, document

N/A

url

no

URL where media content should be uploaded from

N/A

tag

no

Custom optional string field; can be used for custom client message filtering

N/A

Required

yes

Description

A phone number to be used as a message sender. This number must be acquired from Apifonica.

Default value

N/A

Required

yes

Description

Recipient’s phone number.

Phone numbers should be formatted with a country code.

For example, 35315313424.

Default value

N/A

Required

yes

Description

Text of the message.

Max 160 Latin characters or 70 Unicode characters.

Default value

N/A

Required

no

Description

Existing application SID, which is used for Message operations.

Default value

default_msg_app_sid

Required

no

Description

Custom optional string field; can be used for custom client message filtering

Default value

N/A

Required

no

Description

Can be one of the following: sms, telegram, facebook

Default value

sms

Required

no

Description

Type of content for Telegram. Can be one of the following: image, gif, text, document

Default value

N/A

Required

no

Description

URL where media content should be uploaded from

Default value

N/A

Request example

The following cURL example demonstrates sending an SMS:

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

The following cURL example demonstrates sending a message to Telegram:

curl –X POST ‘https://api.apifonica.com/v2/accounts/{accountSID}/messages’ \
-H ‘Content-Type: application/json’ \
-d ‘{ \
     "from": "35315313424", \
     "to": "447860041755", \
     "channel": "telegram", \
     "type": "gif", \
     "url": "https://media.giphy.com/media/ya4eevXU490Iw/giphy.gif", \
     "text": "Apifonica API provides a really cool SMS messaging service" \
    }' \
-u {accountSID}:{authToken}

Response example

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