Send an SMS
Use the API to send an SMS message to a recipients mobile device.https://api-eu1.stannp.com/v1/sms/create
Parameters
test | optional | If test is set to true then the SMS message will not be sent and there will be no charge. |
phone_number | optional | The recipients phone number. (Required if recipient_id is not provided) |
recipient_id | optional | An ID of a recipient that has already been added to your account. (Required if a phone_number is not provided) |
message | mandatory | The message to be sent. If using a recipient_id you can make use of our template tags. For example Hi {firstname}. |
country | optional | A 2 chracter country code. eg: GB,FR,DE. Defaults to your account region. |
Request
$ curl https://api-eu1.stannp.com/v1/sms/create \ -u {API_KEY}: \ -d "phone_number=12345678901" \ -d "message=Hello World"
$curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api-eu1.stannp.com/v1/sms/create?api_key={API_KEY}', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => array( 'phone_number' => "12345678901", 'message' => "Hello World" ), )); $response = curl_exec($curl); curl_close($curl); print_r($response);
import requests data = { 'phone_number': '12345678901', 'message': 'Hello World' } response = requests.post('https://api-eu1.stannp.com/v1/sms/create?api_key={API_KEY}', data=data) print(response.text)
var client = new RestClient("https://api-eu1.stannp.com/v1/sms/create?api_key={API_KEY}"); var request = new RestRequest(Method.POST); request.AddParameter("phone_number", "12345678901"); request.AddParameter("message", "Hello World"); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content)Response
{ "success": true, "data": { "id": 0, "recipient_id": 0, "phone_number": "01234567890", "from": "STANNP", "profile_id": 3, "usage_campaign_id": 0, "profile_type": "sender_id", "message": "Hello World", "message_parts": 1, "cost": 0.058, "destination_country": "GB", "status": "test", "campaign_id": 0, "created": "2024-07-25T16:16:28+00:00", "updated": "" } }