Signup Login

Send a Text Message

API Method: send_text_message


Sends a text message (SMS) to a mobile telephone number. The message may be longer than the maximum SMS length of 160 characters; your account is charged for each block of up to 160 characters.

If a character outside of the range 0-127 is detected in the message text, the message is sent as Unicode.

The message is sent as quickly as possible; delivery is normally within a few seconds.

Mandatory Parameters

Name Description
api_key or javascript_key Use your API key if invoking server-side. If invoking from the browser via JavaScript, generate a JavaScript key using the javascript_key method.
telephone_number The mobile telephone number. If no country code is included, we assume this to be a UK mobile number. The method takes care of the formatting of the number.
from A text description of the source of the message; this may be up to 11 characters.
message The message text. If a character outside of the range 0-127 is present, the message is sent as Unicode.

Optional Parameters

Name Description
client You can optionally include an identifier for your final client or user. This is logged in your usage log and you will be able to view your usage statistics by client.
output Set to json for a JSON response; the default response is XML. Not applicable to the SOAP API.
callback When using JSON, specify a JSONP wrapper in which the JSON response is to be wrapped.

Returned Values

The XML response is contained within a <send_text_message_res> element.

Name Description
status Returns ok if the operation has succeeded, or error if an error has occurred; Returns the error_code for error details.
error_code Returns the error code when the status is error. See below for error codes.
t2a_version_number The current API version number.
credit_used The number of credits used in order to execute the request.
mode Returns normal or test when executed in the free test mode.

Error Codes

Name Description
invalid_from The from parameter is limited to 11 characters.

See also the common error codes.

Free Test Mode

When operating in the free test mode errors are returned if mandatory parameters are missing, or it returns a dummy data response, in an identical format to a real response.

Note that the mode is returned as test when the method is operating in the free test mode.