Integrating our technology into your application or software offers you a true communication extension; it works seamlessly with the technology you and your employees are already familiar with.
Designed to deal with high volumes of business texts, customers connected through our API can:
Have a SMS API with someone else?
Forget redevelopment, move over to Faretext by only having to change your credentials and end point details.
No matter who you’re with, we convert your existing API code to match ours.
Once you’ve been provided your account credentials, you need to generate a GET or POST request.
This you can do in your preferred programming language.
Please note that if you are using the economy service this has a fixed sender ID (the originator will be ignored). Only the direct and international routes support a dynamic sender ID.
Use the information below for single or multiple messages, when using an API-key. Simply change the fields highlighted in red to your relevant information.
Or, for those that wish to use the standard username and password, please click the button below to view the example code and different programming languages, specifically when using the legacy format.
https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage&apikey=APIKEY&recipient=447xxxxxxxxx&originator=SENDERID
&messagedata=MESSAGE
https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage&apikey=APIKEY&originator=SENDERID&recipient=447xxxxxxxxx;447xxxxxxxxx&messagedata=MESSAGE
<form action=https://apikey.faretext-api.co.uk:9443/apikey method=post><br>
action: <input type=text name=action value=sendmessage><br>
apikey: <input type=text name=username value=APIKEY><br>
originator: <input type=text name=originator value=SENDERID><br>
recipient: <input type=text name=recipient value=447xxxxxxxxx><br>
messagedata: <input type=text name=messagedata value=’MESSAGE’><br>
<input type=submit value=OK>
</form>
<form action=https://apikey.faretext-api.co.uk:9443/apikey method=post><br>
action: <input type=text name=action value=sendmessage><br>
apikey: <input type=text name=username value=APIKEY><br>
originator: <input type=text name=originator value=SENDERID><br>
recipient: <input type=text name=recipient value=447xxxxxxxxx;447xxxxxxxxx><br>
messagedata: <input type=text name=messagedata value=’MESSAGE‘><br>
<input type=submit value=OK>
</form>
Once armed with your API-key, copy, and paste the example codes below to start using our API in your preferred format. If you prefer to use the legacy API, with a username and password, code examples in popular languages can be found by clicking the ‘api legacy view‘ button above.
<% address = "https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage" apikey = "your_apikey" originator = "your_originator/senderid" messagedata = "Hello this is a test from Faretext" messagedata = Server.urlencode(messagedata) recipient = "telephone_number" url = address & "&apikey=" & apikey & "&originator=" & originator & "&messagedata=" & messagedata & "&recipient=" & recipient set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP") xmlhttp.open "GET", url, false xmlhttp.send "" msg = xmlhttp.responseText response.write(msg) set xmlhttp = nothing %>
<% address = "https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage" apikey = "your_apikey" originator = "your_originator/senderid" messagedata = "Hello this is a test from Faretext" messagedata = Server.urlencode(messagedata) recipient = "telephone_number" url = address & "&apikey=" & apikey & "&originator=" & originator & "&messagedata=" & messagedata & "&recipient=" & recipient set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP") xmlhttp.open "POST", url, false xmlhttp.send "" msg = xmlhttp.responseText response.write(msg) set xmlhttp = nothing %>
<%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %>
using System; using System.Collections.Generic; using System.Net; using System.Collections.Specialized; namespace send { class send { public string send() { String MessageData = HttpUtility.UrlEncode("Hello this is a test from Faretext"); using (var wb = new WebClient()) { byte[] response = wb.UploadValues("https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage", new NameValueCollection() { {"ApiKey" , "your_apikey"}, {"Originator" , "your_originator/senderid"} {"Recipient" , "telephone_number"}, {"MessageData" , MessageData}, }); string result = System.Text.Encoding.UTF8.GetString(response); return result; } } } }
using System; using System.Collections.Generic; using System.Net; using System.Collections.Specialized; using System.IO; namespace send { class send { public string send() { String result; string ApiKey = "your_apikey; string Originator = "your_originator/senderid"; string Recipient = "telephone_number"; string MessageData = "Hello this is a test from Faretext"; String url = “https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage&ApiKey” + ApiKey + "&Originator=" + Originator + "&Recipient=" + Recipient + "&MessageData=" + MessageData; StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentLength = Encoding.UTF8.GetByteCount(url); objRequest.ContentType = "application/x-www-form-urlencoded"; try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(url); } catch (Exception e) { return e.Message; } finally { myWriter.Close(); } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { result = sr.ReadToEnd(); sr.Close(); } return result; } } }
function Send(ApiKey, Originator, Recipient, MessageData: String):string; const URL = 'https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage&ApiKey=%s&Originator=%s&Recipient=%s&MessageData=%s'; ResponseSize = 1024; var hSession, hURL: HInternet; Request: String;
ResponseLength: Cardinal; begin hSession := InternetOpen('DrBob42', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); try Request := Format(URL,[Username,Password,Originator,Recipient,HttpEncode(MessageData)]); hURL := InternetOpenURL(hSession, PChar(Request), nil, 0,0,0); try SetLength(Result, ResponseSize); InternetReadFile(hURL, PChar(Result), ResponseSize, ResponseLength); SetLength(Result, ResponseLength) finally InternetCloseHandle(hURL) end finally InternetCloseHandle(hSession) end end;
function send(const Url: string): string; var NetHandle: HINTERNET; UrlHandle: HINTERNET; Buffer: array[0..1024] of Char; BytesRead: dWord; begin Result := ''; NetHandle := InternetOpen('Delphi 5.x', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
if Assigned(NetHandle) then begin UrlHandle := InternetOpenUrl(NetHandle, PChar(Url), nil, 0, INTERNET_FLAG_RELOAD, 0);
if Assigned(UrlHandle) then { UrlHandle valid? Proceed with download } begin FillChar(Buffer, SizeOf(Buffer), 0); repeat Result := Result + Buffer; FillChar(Buffer, SizeOf(Buffer), 0); InternetReadFile(UrlHandle, @Buffer, SizeOf(Buffer), BytesRead); until BytesRead = 0; InternetCloseHandle(UrlHandle); end else { UrlHandle is not valid. Raise an exception. } raise Exception.CreateFmt('Error: Cannot open URL %s', [Url]);
InternetCloseHandle(NetHandle); end else { NetHandle is not valid. Raise an exception } raise Exception.Create('Error:'); end;
url := 'https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage' + '&ApiKey=your_apikey' +'&Originator=your_originator/senderid' + '&Recipient=telephone_number' + '&MessageData=Hello+this+is+a+test+from+Faretext'; send(url);
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; public class send { public String send() { try { String ApiKey = "&ApiKey=" + URLEncoder.encode("your_apikey", "UTF-8"); String Originator = "&Originator=" + URLEncoder.encode("your_originator/senderid", "UTF-8"); String Recipient = "&Recipient=" + URLEncoder.encode("telephone_number", "UTF-8"); String MessageData = "&MessageData=" + URLEncoder.encode("Hello this is a test from Faretext", "UTF-8"); String data = "https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage " + ApiKey + Originator + Recipient + MessageData; URL url = new URL(data); URLConnection conn = url.openConnection(); conn.setDoOutput(true); BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; String sResult=""; while ((line = rd.readLine()) != null) { sResult=sResult+line+" "; } rd.close(); return sResult; } catch (Exception e) { System.out.println("Error:"+e); return "Error:"+e; } } }
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; public class send { public String send() { try { String ApiKey = "&ApiKey=" + "your_apikey"; String Originator = "&Originator=" + "your_originator/senderid"; String Recipient = "&Recipient=" + "telephone_number"; String MessageData = "&MessageData=" + "Hello this is a test from Faretext"; HttpURLConnection conn = (HttpURLConnection) new URL("https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage").openConnection(); String data = Username + Password + Originator + Recipient + MessageData; conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Length", Integer.toString(data.length())); conn.getOutputStream().write(data.getBytes("UTF-8")); final BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); final StringBuffer stringBuffer = new StringBuffer(); String line; while ((line = rd.readLine()) != null) { stringBuffer.append(line); } rd.close(); return stringBuffer.toString(); } catch (Exception e) { System.out.println("Error"+e); return "Error"+e; } } }
use LWP::Simple; my $ApiKey = "&ApiKey=" . 'your_apikey'; my $Originator = "&Orginator=" . "your_originator/senderid"; my $Recipient = "&Recipient=" . "telephone_number"; my $MessageData = "&MessageData=" . "Hello+this+is+a+test+from+Faretext"; my $String = join "", "https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage", $ApiKey, $Originator, $Recipient, $MessageData; my $URL = get($String); print "$URL";
use strict; use LWP::UserAgent; use HTTP::Request::Common; my $ApiKey = "&ApiKey=" . 'your_apikey'; my $Originator = "&Orginator=" . "your_originator/senderid"; my $Recipient = "&Recipient=" . "telephone_number"; my $MessageData = "&MessageData=" . "Hello this is a test from Faretext"; my $send = LWP::UserAgent->new(); my $url = $send->request ( POST 'https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage', Content_Type => 'application/x-www-form-urlencoded', Content => [ 'ApiKey' => $ApiKey, 'Password' => $Password, 'Originator' => $Originator, 'Recipient' => $Recipient, 'MessageData' => $MessageData ] ); if ($url->is_error) { die "HTTP: Error"; } print "Response:nn" . $url->content . "nn";
import urllib.request import urllib.parse def send(ApiKey, Originator, Recipient, MessageData): params = {'ApiKey': your_apikey, 'Originator': your_originator/senderid, 'Recipient' : telephone_number, 'MessageData': MessageData} f = urllib.request.urlopen('https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage' + urllib.parse.urlencode(params)) return (f.read(), f.code) resp, code = send('your_apikey', 'your_originator/senderid', 'telephone_number', 'Hello this is a test from Faretext') print (resp)
import urllib.request import urllib.parse def send(ApiKey, Originator, Recipient, MessageData): data = urllib.parse.urlencode({'ApiKey': your_apikey, 'Originator': your_originator/senderid, 'Recipient': telephone_number, 'MessageData': MessageData}) data = data.encode('utf-8') request = urllib.request.Request("https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage") f = urllib.request.urlopen(request, data) fr = f.read() return(fr) resp = send('your_apikey', 'your_originator/senderid', 'telephone_number', 'Hello this is a test from Faretext') print (resp)
require "rubygems" require "net/https" require "uri" require "json" ApiKey = "your_apikey" Originator = "your_originator/senderid" Recipient = "telephone_number" MessageData = "Hello this is a test from Faretext" requested_url = 'https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage' + "&ApiKey=" + ApiKey + "&Originator=" + Originator + "&Recipient=" + Recipient "&MessageData=" + URI.escape(MessageData) uri = URI.parse(requested_url) http = Net::HTTP.start(uri.host, uri.port) request = Net::HTTP::Get.new(uri.request_uri) res = http.request(request) response = JSON.parse(res.body) puts (response)
require "rubygems" require "net/https" require "uri" require "json" requested_url = 'https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage' uri = URI.parse(requested_url) http = Net::HTTP.start(uri.host, uri.port) request = Net::HTTP::Get.new(uri.request_uri) res = Net::HTTP.post_form(uri, 'ApiKey' => 'your_apikey', 'Originator' => 'your_originator/senderid', 'Recipient' => 'telephone_number', 'MessageData' => 'Hello this is a test from Faretext') response = JSON.parse(res.body) puts (response)
Public Sub Send() Dim ApiKey As String ApiKey = "&ApiKey=" + "your_apikey" Dim Originator As String Originator = "&Originator=" + "your_originator/senderid" Dim Recipient As String Recipient = "&Recipient=" + "telephone_number" MessageData As String MessageData = "&MessageData=" + "Hello this is a test from Faretext" Set MyRequest = CreateObject("WinHttp.WinHttpRequest.5.1") MyRequest.Open "GET", "https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage" + ApiKey + Originator + Recipient + MessageData MyRequest.Send MsgBox MyRequest.ResponseText End Sub
Public Sub Send() Dim Apikey As String Dim Originator As String Dim Recipient As String Dim MessageData As String Dim URL As String Dim postData As String Dim winHttpReq As Object ApiKey = "your_apikey" Originator = "your_originator/senderid" Recipient = "telephone_number" MessageData = "Hello this is a test from Faretext" URL = "https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage" Set winHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1") postData = "&ApiKey=" + ApiKey + "&Originator=" + Originator "&Recipient=" + Recipient + "&MessageData=" + MessageData winHttpReq.Open "POST", myURL, False winHttpReq.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded" winHttpReq.Send (postData) SendSMS = winHttpReq.responseText End Sub
Imports System.Net Imports System.Web Imports System.Collections.Specialized Imports System.IO Imports System.Text Public Class send Public Function send() Dim ApiKey = "your_apikey" Dim Originator = "your_originator/senderid" Dim Recipient = "telephone_number" Dim Messagedata = "Hello this is a test from Faretext" Dim strGet As String Dim url As String = "https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage" strGet = url + "&ApiKey=" + ApiKey _ + "&Originator=" + Originator _ + "&Recipient=" + Recipient _ + "&MessageData=" + WebUtility.UrlEncode(MessageData) Dim webClient As New System.Net.WebClient Dim result As String = webClient.DownloadString(strGet) Console.WriteLine(result) Return result End Function End Class
Imports System.Web Imports System.IO Imports System.Net Imports System.Text Imports System.Resources Public Class send Public Function send() Dim ApiKey = "your_apikey" Dim Originator = "your_originator/senderid" Dim Recipient = "telephone_number" Dim Messagedata = "Hello this is a test from Faretext" Dim strPost As String Dim url As String = "https://apikey.faretext-api.co.uk:9443/apikey?action=sendmessage" strPost = url + "&ApiKey=" + ApiKey _ + "&Originator=" + Originator _ + "&Recipient=" + Recipient _ + "&MessageData=" + WebUtility.UrlEncode(MessageData) Dim request As WebRequest = WebRequest.Create(strPost) request.Method = "POST" Dim byteArray As Byte() = Encoding.UTF8.GetBytes(strPost) request.ContentType = "application/x-www-form-urlencoded" request.ContentLength = byteArray.Length Dim dataStream As Stream = request.GetRequestStream() dataStream.Write(byteArray, 0, byteArray.Length) dataStream.Close() Dim response As WebResponse = request.GetResponse() dataStream = response.GetResponseStream() Dim reader As New StreamReader(dataStream) Dim responseFromServer As String = reader.ReadToEnd() Console.WriteLine(responseFromServer) Console.ReadLine() reader.Close() dataStream.Close() response.Close() If responseFromServer.Length > 0 Then Return responseFromServer Else Return CType(response, HttpWebResponse).StatusDescription End If End Function End Class
Private Sub send() Dim DataToSend As String Dim objXML As Object Dim Messagedata As String Dim ApiKey As String Dim Recipient As String Dim Originator As String Dim URL As String ApiKey = "your_apikey"; Originator = "your_originator/senderid" Recipient = "telephone_number" URL = "http://apikey.faretext-api.co.uk:9501/apikey?action=sendmessage" Messagedata = URLEncode("Hello this is a test from Faretext") Set objXML = CreateObject("Microsoft.XMLHTTP") objXML.Open "POST", URL , False objXML.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" objXML.send "&ApiKey=" + ApiKey + "&Recipient=" + Recipient + "&Messagedata=" + Messagedata + "&Originator=" + Originator If Len(objXML.responseText) > 0 Then MsgBox objXML.responseText End If End Sub Function URLEncode(ByVal Text As String) As String Dim i As Integer Dim acode As Integer Dim char As String URLEncode = Text For i = Len(URLEncode) To 1 Step -1 acode = Asc(Mid$(URLEncode, i, 1)) Select Case acode Case 48 To 57, 65 To 90, 97 To 122 Case 32 Mid$(URLEncode, i, 1) = "+" Case Else URLEncode = Left$(URLEncode, i - 1) & "%" & Hex$(acode) & Mid$ _ (URLEncode, i + 1) End Select Next End Function
Private Sub send() Dim DataToSend As String Dim objXML As Object Dim Messagedata As String Dim ApiKey As String Dim Recipient As String Dim Originator As String Dim URL As String ApiKey = "your_apikey"; Originator = "your_originator/senderid" Recipient = "telephone_number" URL = "http://apikey.faretext-api.co.uk:9501/apikey?action=sendmessage" Messagedata = URLEncode("Hello this is a test from Faretext") Set objXML = CreateObject("Microsoft.XMLHTTP") objXML.Open "POST", URL , False objXML.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" objXML.send "&ApiKey=" + ApiKey + "&Recipient=" + Recipient + "&Messagedata=" + Messagedata + "&Originator=" + Originator If Len(objXML.responseText) > 0 Then MsgBox objXML.responseText End If End Sub Function URLEncode(ByVal Text As String) As String Dim i As Integer Dim acode As Integer Dim char As String URLEncode = Text For i = Len(URLEncode) To 1 Step -1 acode = Asc(Mid$(URLEncode, i, 1)) Select Case acode Case 48 To 57, 65 To 90, 97 To 122 Case 32 Mid$(URLEncode, i, 1) = "+" Case Else URLEncode = Left$(URLEncode, i - 1) & "%" & Hex$(acode) & Mid$ _ (URLEncode, i + 1) End Select Next End Function
Can’t see your programming language? Please get in touch by using the form at the bottom of the page.
Check the reliability and speed of our route for free.
Simply insert your UK mobile number and click Go.
Instead of connecting via our SMS API, customers have an alternative method to connect to Faretext, via our SMS SMPP service.
Standing for Short Message Peer-to-Peer, this type of integration is used for broadcasting high-volumes of messages very
quickly and directly to both, text aggregators and mobile network operators.
Our server supports the industry-standard SMPP 3.4 and can process up to 600 messages per second.
Simultaneously the system can also receive delivery receipts, ensuring real-time delivery results of your bulk
text campaigns.
To find out more about Faretext’s SMPP service, please get in touch, by filling in the form below or calling:
0114 945 993.