Book a meeting with usBook a meeting

SMS messaging API documentation

Create SMS account, connect your payment card, generate SMS API KEY and start using SMS messaging API within minutes.

Bulk SMS

Text2reach API has simple HTTP GET request interface and also JSON-RPC interface. To use JSON-RPC interface, please read the JSON-RPC Specification.

API rate limits

To ensure fair usage and system stability, we enforce rate limits on all API requests.
Requests Allowed: 300 per 10 seconds (per client).
Exceeding these limits will result in a 429 Too Many Requests HTTP error response.
If your application receives a 429 error, you must stop sending requests immediately and wait until the limit resets.
The response will include a standard HTTP header to indicate the required wait time: Retry-After. The time, in seconds, the client should wait before making a new request.
Best Practice: Implement logic in your application that reads the Retry-After header and dynamically pauses subsequent requests for the specified duration.

1. Send SMS

1.1 HTTP interface

To send a bulk message, SP must make a HTTP GET request to address: https://api.text2reach.com/sms/send query string values are specified below in the parameters table. All parameters should be properly url-encoded. The returned HTML body for the request will be a message ID or an error code in plain text format (or a detailed JSON object if requested).

Example: https://api.text2reach.com/sms/send?api_key=XXXXXXXXXXXXX &phone=37126378162&from=29180083&message=Hello+world

1.2 JSON-RPC interface

To send a bulk message, SP must make a JSON-RPC request to address: https://api.text2reach.com/sms/?api_key=XXXXXXXXXXXXXX

Method:

send( from, phone, message, type, unicode, timestamp, report_url, expires, schedule, blacklist )

Example:

<?php
    require_once 'jsonRPCClient.php';
    define("API_KEY", "XXXXXXXXXXXX");

    $j = new jsonRPCClient("https://api.text2reach.com/sms/?api_key=" . API_KEY);
    $msg_id = $j->send(
            'aaaaaaaaaa',
            '37125924564',
            'Hello world!',
            'txt',
            false,
            0,
            'http://www.yoursite.com/sms/report/handler/',
            0,
            0,
            false
    );
    // save the $msg_id in DB and use it for report requests
?>
                            

1.3 Custom fields

NameDescription
{sms_unsubscribe_link}Unsubscribe link – This custom field will include a unique link in the message for each recipient where the recipient can unsubscribe from future SMS. The link will take the recipient to a landing page where they will be asked to confirm the unsubscribe process. If the recipient confirms the unsubscribe process, the recipient’s number will be added to the client account blacklist, and future SMS sending to this number will be rejected until the number is removed from the blacklist. Numbers in the blacklist are added as recipient number + sender name, which means that the recipient unsubscribes only from specific sender name / brand messages.
{pin:*:6:3600}PIN / Verification code – this custom field will include unique code in message body which will be sent to recipient. Sent code can be validated over API request. More information about PIN code variables and verification process see section 8. PIN / Verification code

1.4 Parameters

NameRequiredDefault valueDescription
api_keyyesYour registered Bulk API key
fromyessource address of the message
phoneyesdestination address in international form
messageyesplain text message up to 160 (1071) characters, Unicode message up to 70 (469) characters
typenotxtmessage type (“txt” for text, “bin” for binary)
unicodenotrueif set to false, characters not in GSM 7bit alphabet will be converted (ā => a) or removed
timestampno0Unix timestamp of a time when end user opted in to receive messages. If parameter is not set the current timestamp is used.
report_urlnofalseURL for delivery reports
expiresno0Delivery time in seconds
schedulenoUnix timestamp of a time when the message is scheduled for delivery
blacklistnofalseChecks if the number is in blacklist before sending. Returns error -503 if found
formatnoResponse format. If not set, the response will be a message ID or an error code in plain text format. If set to “json”, the response will be in JSON format. If the request was not successful or in case of an error, the ‘success’ field will be set to 0.
JSON format:
{ ‘success’: 1|0, ‘message’: ‘ok’|’error’, ‘data’: { ‘msg_id’: 1234567890, ‘status’: ‘submitted’|’error’, ‘error’: ‘error message’ } }

1.5 Description

This bulk API call will send the text message to the provided phone number. Your account will be checked for the required funds. If the message cannot be sent, the response will be a negative integer representing the error.

The message will be considered as plain if all the characters are present in the GSM 7bit alphabet (see the table below). It is possible to send up to 1071 characters which will be split into seven parts, 153 characters per part. You will be charged for each part accordingly. 7 characters out of 160 are reserved to identify and concatenate multiple parts and applies only to messages having more than one part. If the message contains unicode characters then you can send up to 469 characters, 63 characters per part, max 7 parts. 7 characters out of 63 are reserved to identify and concatenate multiple parts and applies only to messages having more than one part.

The mandatory parameter “from” can be a telephone number in international format, a short code or a textual sender name. Maximum length of an international number is 15 digits not including “+” or “00” prefix. Maximum length of a textual sender name is 11 alphanumeric characters.

The optional parameter “type” specifies the format of the parameter “message”. In case the type is set to “bin”, parameter “message” should be in hexadecimal format.

The optional parameter “unicode” specifies the encoding used for parameter “message”. If it is set to “false”, then the message will be checked against GSM 7bit alphabet (see the table below) and all the symbols not in the table will be converted to the respective latin characters or completely removed. If the parameter “unicode” is set to “true” and the message contains characters not in the GSM 7bit alphabet, then the message will be considered as utf-8 and reduce the length of the message to 70 (469) characters.

The optional parameter “timestamp” specifies the time when the user opted in to receive the message. If an end user has signed up for your service and has provided a mobile phone number to receive advertisements or informational messages, then you should provide “timestamp” parameter with the sign-up time. If an owner of a mobile phone number is changed, number is closed or operator is changed, then the message will not be sent. If the new owner of a number opts in to receive messages, a new timestamp should be used.

The “report_url” parameter should be used to receive delivery reports for sent messages. Please see below for detailed request specification.

If the “expire” parameter is not specified, the operator default expire time is used. If specified and the message is not delivered in the specified amount of seconds, you will received “expired” status. Exact behavior depends on the end user mobile phone operator validity period of the message and is not guaranteed to match the expire time specified in the parameter.

The “schedule” parameter should be set if you want to delay the delivery of the message. The parameter must be in two weeks range from the current time.

2. Manual delivery reports

You can request a status of the sent message by an api call.

2.1 HTTP interface

To request a status, SP must make a HTTP GET request to address: https://api.text2reach.com/sms/status query string values are specified below in the parameters table. The returned HTTP body will contain a status of the message.

Example:
https://api.text2reach.com/sms/status?api_key=XXXXXXXXXXXX&msg_id=1234567

2.2 JSON-RPC interface

To request a status, SP must make a JSON-RPC request to address: https://api.text2reach.com/sms/?api_key=XXXXXXXXXXXX

Method:

status( msg_id )

Example:

<?php
    require_once 'jsonRPCClient.php';
    define("API_KEY", "XXXXXXXXXXXX");

    $j = new jsonRPCClient("https://api.text2reach.com/sms/?api_key=" . API_KEY);
    $status = $j->status(1234567);

    // save the status in DB for the msg_id=1234567
?>
                            

2.3 Parameters

NameRequiredDefault valueDescription
api_keyyesyour registered Bulk API key
msg_idyesmessage ID from “bulk send” api call

3. Automatic delivery reports

Alternatively reports will be delivered to the “report_url” if it is provided in the send bulk api call. Delivery interface will be the same as used in the sending, e.g., if you used json-rpc interface to send a message, then the delivery report will be sent through json-rpc interface, too.

3.1 HTTP interface

SMSGW makes a HTTP GET request to a “report_url” address provided by SP with the parameters found below. The SP handler script must respond with text “OK” or else the report will be retried for a total of 10 times with 2n minutes interval (n – retries counter) and then discarded.

3.2  JSON-RPC interface

To handle report requests through JSON-RPC interface, you must have the minimum implementation as provided below:

<?php
    require_once 'jsonRPCServer.php';

    class handler {
            public function report($msg_id, $status, $retries) {
                    // handle the report
                    return true;
            }
    }

    $server = new handler();
    jsonRPCServer::handle($server) or die('Invalid request');
?>
                            

3.3 Parameters

NameDescription
msg_idmessage id of the message this report belongs to, provided as a result of sending the message
statusstatus of the sent message,
delivered – the message was delivered successfully
undelivered – the message was not delivered
expired – the delivery reached time limit and was considered undelivered
canceled – the message was canceled before scheduled sendout
rejected – the message was rejected by SMSGW and was not charged
pending – the message is not jet delivered (this status is only reported using manual delivery checking)
unknown – message status is not known
retrieshow many times platform tried to deliver report to the “report_url”

4. Extended delivery report

You can request a details of the sent message by an api call.

4.1 HTTP interface

To request a details, SP must make a HTTP GET request to address: https://api.text2reach.com/sms/details query string values are specified below in the parameters table. The returned HTTP body will contain a status of the message.

4.2 JSON-RPC interface

To request a detailed status, SP must make a JSON-RPC request to address:https://api.text2reach.com/sms/?api_key=XXXXXXXXXXXX

Method:

details( msg_id )

Example:

<?php
    require_once 'jsonRPCClient.php';
    define("API_KEY", "XXXXXXXXXXXX");

    $j = new jsonRPCClient("https://api.text2reach.com/sms/?api_key=" . API_KEY);
    $status = $j->status(1234567);

    // save the status in DB for the msg_id=1234567
?>
                                

4.3 Parameters

NameRequiredDefault valueDescription
api_keyyesyour registered Bulk API key
msg_idyesmessage ID from “bulk send” api call

4.4 Returns

Error:

{
    "success" : 0,
    "message" : "Unknown msg_id",
    "data" : []
}

Successfull:

{
    "success" : 1,
    "message" : "ok",
    "data" : {
        "msg_id" : "1234567",
        "source" : "info",  // from number/alpha
        "destination" : "37129123456", // to number
        "country" : {
            "name" : "Latvia",
            "iso" : "lv",
            "mcc" : "247"
        },
        "operator" : {
            "name":"Best Mobile Operator",
            "mnc":"10"
        },
        "created" : "2017-01-01 10:00:00",
        "delivered" : "2017-01-01 10:00:03",
        "schedule" : "N",
        "scheduled" : null,
        "message" : "Hello World!",
        "multipart" : "N",
        "parts" : 1,
        "price: : 0.0232,
        "sum" : 0.0232,
        "status" : "delivered" // statuses: delivered | undelivered | expired | canceled | rejected | pending
    }
}

5. Cancel SMS

You can cancel pending/scheduled message by an api call.

5.1 HTTP interface

Example:
https://api.text2reach.com/sms/cancel?api_key=XXXXXXXXXXXX&msg_id=1234567

To cancel message sending, SP must make a HTTP GET request to address: https://api.text2reach.com/sms/cancel query string values are specified below in the parameters table. The returned HTTP body will contain a status of the message.

5.2 JSON-RPC interface

To cancel message sending, SP must make a JSON-RPC request to address:https://api.text2reach.com/sms/?api_key=XXXXXXXXXXXX

Method:

cancel( msg_id )

Example:

<?php
    require_once 'jsonRPCClient.php';
    define("API_KEY", "XXXXXXXXXXXX");

    $j = new jsonRPCClient("https://api.text2reach.com/sms/?api_key=" . API_KEY);
    $result = $j->cancel(1234567);

    // result = ok | forbidden | error | unknown
?>
                                

5.3 Parameters

NameRequiredDefault valueDescription
api_keyyesyour registered Bulk API key
msg_idyesmessage ID from “bulk send” api call

6. Credits balance

Prepaid customers can request remains of credits on account.

6.1 HTTP interface

To request a balance, SP must make a HTTP GET request to address: https://api.text2reach.com/sms/credit The returned HTTP body will contain a amount of credits.

Example:
https://api.text2reach.com/sms/credit?api_key=XXXXXXXXXXXX

6.2 JSON-RPC interface

To request a status, SP must make a JSON-RPC request to address:https://api.text2reach.com/sms/?api_key=XXXXXXXXXXXX

Method:

credit()

Example:

<?php
    require_once 'jsonRPCClient.php';
    define("API_KEY", "XXXXXXXXXXXX");

    $j = new jsonRPCClient("https://api.text2reach.com/sms/?api_key=" . API_KEY);
    $prices = $j->credit();
?>

6.3 Parameters

NameRequiredDefault valueDescription
api_keyyesyour registered Bulk API key

7. Prices

7.1 HTTP interface

To get all available prices by countries, SP must make a HTTP GET request to address: https://api.text2reach.com/sms/prices query string values are specified below in the parameters table. The returned HTTP body will contain an json structure.

Example:
https://api.text2reach.com/sms/prices?api_key=XXXXXXXXXXXX&format=json

Are available follows formats (only HTTP interface):
json – Price in JSON format. This is default format.
csv – prices in csv-file with comma delimeter
xls – prices in Excel format file

7.2 JSON-RPC interface

To get all available prices by countries, SP must make a JSON-RPC request to address:https://api.text2reach.com/sms/?api_key=XXXXXXXXXXXX

Method:

prices()

Example:

<?php
    require_once 'jsonRPCClient.php';
    define("API_KEY", "XXXXXXXXXXXX");

    $j = new jsonRPCClient("https://api.text2reach.com/sms/?api_key=" . API_KEY);
    $prices = $j->prices();
?>
                                

7.3 Parameters

NameRequiredDefault valueDescription
api_keyyesyour registered Bulk API key

7.4 Returns

Example:

[
    ...
    {
        country : "Belgium",
        iso     : "be",
        code    : 32,
        operator: "Proximus",
        mcc	    : 206,
        mnc     : 1,
        type    : "all",
        price   : 0.123456,
        note    : null
    },
    ...
]

8. PIN / Verification code

Text2Reach API provides functionality to generate PIN code using custom fields in message body. To generate unique PIN code, you need to include custom field in any place of message body when sending SMS.

8.1 Custom field template

{PIN:<TYPE>:<length>:<validity_period>}

8.2 Custom field variables

VariableMandatoryDescription
Typeyes* – Alpha + numeric PIN code (A1B2)
N – Only Numeric PIN code (1234)
A – Only Alpha PIN code (ABCD)
LengthyesSymbol count in numeric value
Validity periodyesValidity period in seconds

8.3 Custom field example

To send PIN code that consists of Alpha and Numeric values, is 8 characters long and is valid for one hour you need to insert following custom fields in any place in message body

{PIN:*:8:3600}

8.4 Custom API endpoint

https://api.text2reach.com/sms/pin

8.5 Request parameters

ParameterDescription
api_keyAPI key that was used to request pin code generation
phonePhone number to verify
pinPIN code to verify

8.6 Request example

https://api.text2reach.com/sms/pin?api_key=XXXXXXXXXXXX&phone=3712123123&pin=A1B2

8.7 Response codes

ResponseDescription
VALIDPIN code is valid and matches to the one that was sent to phone number.
UNKNOWNPIN code does not match to the one that was sent to phone number.
EXPIREDPIN code has expired

Error codes

If the message cannot be sent, the return value for msg_id will contain a negative integer which represents an error from the table below:

ValueDescription
-10Geneal system error
-11Wrong API KEY for the request
-12Wrong Message ID
-14Wrong source address
-15Wrong destination address
-16Wrong “type”, must be “txt” or “bin”
-17Wrong message length (empty)
-18Wrong message length (too long)
-19Wrong “schedule” value
-20Wrong “expires” value
-21Phone in blacklist
-22No route destination
-34Message failed
-35Client undefined

GSM 7bit characters

HexDecimalCharacter nameSupported character
0x000COMMERCIAL AT@
0x011POUND SIGN£
0x022DOLLAR SIGN$
0x033YEN SIGN¥
0x044LATIN SMALL LETTER E WITH GRAVEè
0x055LATIN SMALL LETTER E WITH ACUTEé
0x066LATIN SMALL LETTER U WITH GRAVEù
0x077LATIN SMALL LETTER I WITH GRAVEì
0x088LATIN SMALL LETTER O WITH GRAVEò
0x099LATIN CAPITAL LETTER C WITH CEDILLAÇ
0x0A10LINE FEED
0x0B11LATIN CAPITAL LETTER O WITH STROKEØ
0x0C12LATIN SMALL LETTER O WITH STROKEø
0x0D13CARRIAGE RETURN
0x0E14LATIN CAPITAL LETTER A WITH RING ABOVEÅ
0x0F15LATIN SMALL LETTER A WITH RING ABOVEå
0x1016GREEK CAPITAL LETTER DELTAΔ
0x1117LOW LINE_
0x1218GREEK CAPITAL LETTER PHIΦ
0x1319GREEK CAPITAL LETTER GAMMAΓ
0x1420GREEK CAPITAL LETTER LAMBDAΛ
0x1521GREEK CAPITAL LETTER OMEGAΩ
0x1622GREEK CAPITAL LETTER PIΠ
0x1723GREEK CAPITAL LETTER PSIΨ
0x1824GREEK CAPITAL LETTER SIGMAΣ
0x1925GREEK CAPITAL LETTER THETAΘ
0x1A26GREEK CAPITAL LETTER XIΞ
0x1B27ESCAPE TO EXTENSION TABLE
0x1C28LATIN CAPITAL LETTER AEÆ
0x1D29LATIN SMALL LETTER AEæ
0x1E30LATIN SMALL LETTER SHARP S(German)ß
0x1F31LATIN CAPITAL LETTER E WITH ACUTEÉ
0x2032SPACE
0x2133EXCLAMATION MARK!
0x2234QUOTATION MARK
0x2335NUMBER SIGN#
0x2436CURRENCY SIGN¤
0x2537PERCENT SIGN%
0x2638AMPERSAND&
0x2739APOSTROPHE
0x2840LEFT PARENTHESIS(
0x2941RIGHT PARENTHESIS)
0x2A42ASTERISK*
0x2B43PLUS SIGN+
0x2C44COMMA,
0x2D45HYPHEN-MINUS
0x2E46FULL STOP.
0x2F47SOLIDUS(SLASH)/
0x3048DIGIT ZERO0
0x3149DIGIT ONE1
0x3250DIGIT TWO2
0x3351DIGIT THREE3
0x3452DIGIT FOUR4
0x3553DIGIT FIVE5
0x3654DIGIT SIX6
0x3755DIGIT SEVEN7
0x3856DIGIT EIGHT8
0x3957DIGIT NINE9
0x3A58COLON:
0x3B59SEMICOLON;
0x3C60LESS-THAN SIGN<
0x3D61EQUALS SIGN=
0x3E62GREATER-THAN SIGN>
0x3F63QUESTION MARK?
0x4064INVERTED EXCLAMATION MARK¡
0x4165LATIN CAPITAL LETTER AA
0x4266LATIN CAPITAL LETTER BB
0x4367LATIN CAPITAL LETTER CC
0x4468LATIN CAPITAL LETTER DD
0x4569LATIN CAPITAL LETTER EE
0x4670LATIN CAPITAL LETTER FF
0x4771LATIN CAPITAL LETTER GG
0x4872LATIN CAPITAL LETTER HH
0x4973LATIN CAPITAL LETTER II
0x4A74LATIN CAPITAL LETTER JJ
0x4B75LATIN CAPITAL LETTER KK
0x4C76LATIN CAPITAL LETTER LL
0x4D77LATIN CAPITAL LETTER MM
0x4E78LATIN CAPITAL LETTER NN
0x4F79LATIN CAPITAL LETTER OO
0x5080LATIN CAPITAL LETTER PP
0x5181LATIN CAPITAL LETTER QQ
0x5282LATIN CAPITAL LETTER RR
0x5383LATIN CAPITAL LETTER SS
0x5484LATIN CAPITAL LETTER TT
0x5585LATIN CAPITAL LETTER UU
0x5686LATIN CAPITAL LETTER VV
0x5787LATIN CAPITAL LETTER WW
0x5888LATIN CAPITAL LETTER XX
0x5989LATIN CAPITAL LETTER YY
0x5A90LATIN CAPITAL LETTER ZZ
0x5B91LATIN CAPITAL LETTER A WITH DIAERESISÄ
0x5C92LATIN CAPITAL LETTER O WITH DIAERESISÖ
0x5D93LATIN CAPITAL LETTER N WITH TILDEÑ
0x5E94LATIN CAPITAL LETTER U WITH DIAERESISÜ
0x5F95SECTION SIGN§
0x6096INVERTED QUESTION MARK¿
0x6197LATIN SMALL LETTER Aa
0x6298LATIN SMALL LETTER Bb
0x6399LATIN SMALL LETTER Cc
0x64100LATIN SMALL LETTER Dd
0x65101LATIN SMALL LETTER Ee
0x66102LATIN SMALL LETTER Ff
0x67103LATIN SMALL LETTER Gg
0x68104LATIN SMALL LETTER Hh
0x69105LATIN SMALL LETTER Ii
0x6A106LATIN SMALL LETTER Jj
0x6B107LATIN SMALL LETTER Kk
0x6C108LATIN SMALL LETTER Ll
0x6D109LATIN SMALL LETTER Mm
0x6E110LATIN SMALL LETTER Nn
0x6F111LATIN SMALL LETTER Oo
0x70112LATIN SMALL LETTER Pp
0x71113LATIN SMALL LETTER Qq
0x72114LATIN SMALL LETTER Rr
0x73115LATIN SMALL LETTER Ss
0x74116LATIN SMALL LETTER Tt
0x75117LATIN SMALL LETTER Uu
0x76118LATIN SMALL LETTER Vv
0x77119LATIN SMALL LETTER Ww
0x78120LATIN SMALL LETTER Xx
0x79121LATIN SMALL LETTER Yy
0x7A122LATIN SMALL LETTER Zz
0x7B123LATIN SMALL LETTER A WITH DIAERESISä
0x7C124LATIN SMALL LETTER O WITH DIAERESISö
0x7D125LATIN SMALL LETTER N WITH TILDEñ
0x7E126LATIN SMALL LETTER U WITH DIAERESISü
0x7F127LATIN SMALL LETTER A WITH GRAVEà

Extended GSM 7bit characters 1

HexDecimalCharacter nameSupported character
0x1B6527 101EURO SIGN
0x1B0A27 10FORM FEED<FF>
0x1B3C27 60LEFT SQUARE BRACKET[
0x1B2F27 47REVERSE SOLIDUS(BACKSLASH)\
0x1B3E27 62RIGHT SQUARE BRACKET]
0x1B1427 20CIRCUMFLEX ACCENT^
0x1B2827 40LEFT CURLY BRACKET{
0x1B4027 64VERTICAL BAR|
0x1B2927 41RIGHT CURLY BRACKET}
0x1B3D27 61TILDE~

1 – These additional characters, known as the Extended GSM character set, require two standard GSM characters for each extended GSM character because they use the escape character prefix.