Unit sending
- Home
- Unit sending
Send SMS messages
This request is used to send real-time or delayed SMS messages.
URLs
POST https://api.smspartner.fr/v1/send
Parameters
Each API request supports the following parameters:
- The platform does not send commercial SMS messages between 10pm and 8am during the week and on Sundays and public holidays (legal restriction). In case of sending, the SMS messages are on pause until the next business day at 8am.
- You do not send commercial SMS messages? Contact us: help@smspartner.fr
apiKey | API key of your account. You get it in your SMS Partner account. |
---|---|
phoneNumbers | Telephone numbers of the recipients. When sending several SMS messages, the numbers must be separated by commas. They can be:
|
message | SMS content. 160 characters maximum per SMS (beyond that, you will be charged one additional SMS per 153 characters).
Be careful, some special and accented characters will be replaced when sending:
|
Optional parameters | |
gamme | SMS range, its value must be:
If this parameter is omitted, SMS will be sent in the Premium range. |
sender | Name of the sender of the message. If the sender is left empty, your SMS messages will be sent with an operator shortcode as sender (example: 36xxx).
The number of characters for the transmitter name must be between 3 and 11 inclusive and must not contain any special characters. Some mobile phone models do not interpret spaces. |
scheduledDeliveryDate | Date of sending of the SMS, in dd/mm/YYYY format. To be defined only if you want SMS to be sent offline. |
time | SMS sending time (format 0-24), mandatory if scheduledDeliveryDate is set. |
minute | SMS sending time regarding minutes units (format 0-55, per five-minute interval), mandatory if scheduledDeliveryDate is defined. |
isStopSms | Premium range: 1 to add the mention STOP at the end of the SMS (mandatory for commercial SMS).
Low Cost range: This parameter is not applicable for this range, it is necessary to manually add the mention NoPub=STOP for commercial SMS. |
sandbox | To test sending SMS, you can use thesandbox :
No SMS will be sent, and there will be no debit to your account, these SMS will be deleted from your mailing lists automatically every day. |
_format | Response format. You can choose between JSON or XML . By default, the response format is JSON . |
Request
Request example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<?php // Prepare data for POST request $fields = array( 'apiKey'=> 'YOUR API KEY', 'phoneNumbers'=> '+336xxxxxxxx', 'message'=> 'This is your message', 'sender' => 'mycompany', 'scheduledDeliveryDate'=> '21/10/2014', 'time'=> 9, 'minute'=> 0 ); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,'https://api.smspartner.fr/v1/send'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 10); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS,json_encode($fields)); $result = curl_exec($curl); curl_close($curl); // Process your response here echo $result; ?> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
Imports System.IO Imports System.Net Module Module1 Sub Main() Dim base_url As String = "http://api.smspartner.fr/v1/" Dim apiKey As String = "VOTRE_APIKEY" #send sms url = base_url & "send" #note : utiliser une librairie JSON en production, par exemple : #https//www.nuget.org/packages/Newtonsoft.Json/ Dim parameters As String = String.Format( "{{""apiKey"":""{0}"",""phoneNumbers"":""{1}"",""message"":""{2}""}}", apiKey, "+33XXXXXXXXX", "message de test") Console.Write(parameters) apiRequest("POST", url, parameters) End Sub Function apiRequest(method As String, url As String, parameters As String) As String Dim request As HttpWebRequest request = WebRequest.Create(url) request.Method = method request.Timeout = 10000 # timeout in ms request.ContentType = "application/json; charset=utf-8" request.ContentLength = 0 #set POST data If Not String.IsNullOrEmpty(parameters) Then request.ContentLength = parameters.Length Using reqStream As StreamWriter = New StreamWriter(request.GetRequestStream()) reqStream.Write(parameters) End Using End If #get response Dim returnValue As String = Nothing Using response As HttpWebResponse = request.GetResponse() If response.StatusCode = HttpStatusCode.OK Then Using resStream = response.GetResponseStream() If resStream IsNot Nothing Then Using reader As New StreamReader(resStream) returnValue = reader.ReadToEnd() End Using End If End Using End If End Using apiRequest = returnValue End Function End Module |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# std import logging import json from collections import OrderedDict # 3p import requests API_KEY = "MY API KEY" URL = "https://api.smspartner.fr/v1" class SMSPartner(): def send_sms(self,phone_numbers, msg, sender = "SMSPartner"): #sender = "DEMOSMS" print(phone_numbers) data = OrderedDict([ ("apiKey", API_KEY), ("phoneNumbers", phone_numbers), ("message", msg), ("sender", sender) ]) url = URL + "/send" r = requests.post(url, data=json.dumps(data), verify=False) r_json = r.json() if r_json.get("success") == True: print(r_json) status = True else: print("SMS msg {} not delivered to {}".format(msg, phone_numbers)) status = False return status |
1 |
curl -H "Content-Type: application/json" -X POST -d '{"apiKey":"xxxxx","phoneNumbers":"xxxx","message":"test","sender":"mycompany"}' https://api.smspartner.fr/v1/send |
Answers
1 2 3 4 5 6 7 8 |
{ "success":true, "code":200, "message_id":307, "nb_sms": 1, "cost": 0.038, "currency": "EUR" } |
1 2 3 4 5 6 7 8 9 10 11 |
<?xml version='1.0' encoding='UTF-8'?> <result> <entry>true</entry> <entry>200</entry> <entry>306</entry> <entry>1</entry> <entry>0.038</entry> <entry> <![CDATA[EUR]]> </entry> </result> |
Errors
Error messages examples:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
{ "success": false, "code":9, "error": [{ "elementId": "children[message].data", "message": "Le message est requis" }, { "elementId": "children[phoneNumbers].data", "message": "Ce numero de telephone n'est pas valide (922264)" }, { "elementId": "children[sender].data", "message": "L'emetteur ne peut pas etre plus long que 11 caracteres" }, { "elementId": "children[scheduledDeliveryDate].data", "message": "La date (21/11/2014 \u00e0 :) est anterieure a la date actuelle." }, { "elementId": "children[minute].data", "message": "La minute est requise" }, { "elementId": "children[time].data", "message": "L'heure est requise" }] } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
<?xml version='1.0' encoding='UTF-8'?> <result> <entry>false</entry> <entry>9</entry> <entry> <entry> <entry>children[message].data</entry> <entry>Le message est requis</entry> </entry> <entry> <entry>children[phoneNumbers].data</entry> <entry>Ce numéro de téléphone n'est pas valide (922264)</entry> </entry> <entry> <entry>children[sender].data</entry> <entry>L'émetteur ne peut pas être plus long que 11 caractères</entry> </entry> <entry> <entry>children[scheduledDeliveryDate].data</entry> <entry>La date (21/11/2014 à :) est anterieure à la date actuelle. Si vous souhaitez l'envoyer maintenant vous devez sélectionner [Envoi immédiat]</entry> </entry> <entry> <entry>children[minute].data</entry> <entry>La minute est requise</entry> </entry> <entry> <entry>children[time].data</entry> <entry>L'heure est requise</entry> </entry> </entry> </result> |
Control Code
Error Codes | ||
---|---|---|
1 | The API Key is required | |
2 | The telephone number is required | |
9 | At least one constraint was not respected during the sending:
|
|
10 | Invalid API Key | |
11 | Lack of funds |