Creates an SMS campaign

Code Examples

You can use as reference the code below to implement this call in your preferred language.
Check all our official API clients here

const SibApiV3Sdk = require('sib-api-v3-sdk');
const defaultClient = SibApiV3Sdk.ApiClient.instance;

let apiKey = defaultClient.authentications['api-key'];
apiKey.apiKey = 'YOUR API KEY';

let apiInstance = new SibApiV3Sdk.SMSCampaignsApi();

let createSmsCampaign = new SibApiV3Sdk.CreateSmsCampaign();

createSmsCampaign = {
    name = 'string',
    sender = 'string',
    content = 'string',
    recipients = {
        'listIds' : [1]
    },
    scheduledAt = new Date('YYYY-MM-DDTHH:MM:ss+00:00')
}

apiInstance.createSmsCampaign(createSmsCampaign).then(function(data) {
    console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}, function(error) {
    console.error(error);
});
<?php
require_once(__DIR__ . '/vendor/autoload.php');

$config = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOUR API KEY');

$apiInstance = new SendinBlue\Client\Api\SMSCampaignsApi(
    new GuzzleHttp\Client(),
    $config
);
$createSmsCampaign = new \SendinBlue\Client\Model\CreateSmsCampaign();
$createSmsCampaign['name'] = 'My First Campaign';
$createSmsCampaign['sender'] = 'senderName';
$createSmsCampaign['content'] = 'This is a transactional SMS';
$createSmsCampaign['recipients'] = array('listIds' => array(1));
$createSmsCampaign['scheduledAt'] = new \DateTime('2021-01-01T00:00:00+00:00');

try {
    $result = $apiInstance->createSmsCampaign($createSmsCampaign);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling SMSCampaignsApi->createSmsCampaign: ', $e->getMessage(), PHP_EOL;
}
?>
from __future__ import print_function
import time
import sib_api_v3_sdk
from sib_api_v3_sdk.rest import ApiException
from pprint import pprint

configuration = sib_api_v3_sdk.Configuration()
configuration.api_key['api-key'] = 'YOUR API KEY'

api_instance = sib_api_v3_sdk.SMSCampaignsApi(sib_api_v3_sdk.ApiClient(configuration))
name = "string"
sender = "string"
content = "string"
recipients = {"listIds": [1]}
scheduled_at = "YYYY-MM-DDTHH:MM:ss+00:00"
create_sms_campaign = sib_api_v3_sdk.CreateSmsCampaign(name=name, sender=sender, content=content, recipients=recipients, scheduled_at=scheduled_at)

try:
    api_response = api_instance.create_sms_campaign(create_sms_campaign)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling SMSCampaignsApi->create_sms_campaign: %s\n" % e)
const SibApiV3Sdk = require('sib-api-v3-typescript');
 
let apiInstance = new SibApiV3Sdk.SMSCampaignsApi()

let apiKey = apiInstance.authentications['apiKey'];
apiKey.apiKey = 'YOUR API KEY';

let createSmsCampaign = new SibApiV3Sdk.CreateSmsCampaign();

createSmsCampaign.name = 'My First Campaign';
createSmsCampaign.sender = 'senderName';
createSmsCampaign.content = 'This is a transactional SMS';
createSmsCampaign.recipients = {'listIds' : [1]}
createSmsCampaign.scheduledAt = new Date('2021-01-01T00:00:00+00:00');

apiInstance.createSmsCampaign(createSmsCampaign).then(function(data) {
  console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}, function(error) {
  console.error(error);
});
using sib_api_v3_sdk.Api;
using sib_api_v3_sdk.Client;
using sib_api_v3_sdk.Model;
using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace Sendinblue
{
    class Program
    {
        static void Main(string[] args)
        {
            Configuration.Default.ApiKey.Add("api-key", "YOUR API KEY");

            var apiInstance = new SMSCampaignsApi();
            string name = "My First Campaign";
            string sender = "senderName";
            string content = "This is a transactional SMS";
            List<long?> listIds = new List<long?>();
            listIds.Add(12);
            List<long?> exclusionListIds = new List<long?>();
            exclusionListIds.Add(1);
            CreateSmsCampaignRecipients recipients = new CreateSmsCampaignRecipients(listIds, exclusionListIds);
            string scheduledAt = "2021-01-01T00:00:00.000+05:30";
            try
            {
                var createSmsCampaign = new CreateSmsCampaign(name, sender, content, recipients, scheduledAt);
                CreateModel result = apiInstance.CreateSmsCampaign(createSmsCampaign);
                Debug.WriteLine(result.ToJson());
                Console.WriteLine(result.ToJson());
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                Console.WriteLine(e.Message);
                Console.ReadLine();
            }
        }
    }
}
# load the gem
require 'sib-api-v3-sdk'
# setup authorization
SibApiV3Sdk.configure do |config|
  # Configure API key authorization: api-key
  config.api_key['api-key'] = 'YOUR API KEY'
end

api_instance = SibApiV3Sdk::SMSCampaignsApi.new

create_sms_campaign = SibApiV3Sdk::CreateSmsCampaign.new # CreateSmsCampaign | Values to create an SMS Campaign

create_sms_campaign = {
  'name'=> 'string',
  'sender'=> 'string',
  'content'=> 'string',
  'recipients'=> {
    'listIds'=> [1]
  },
  'scheduledAt'=> DateTime.iso8601('2021-02-03T04:05:06+07:00')
}

begin
  #Creates an SMS campaign
  result = api_instance.create_sms_campaign(create_sms_campaign)
  p result
rescue SibApiV3Sdk::ApiError => e
  puts "Exception when calling SMSCampaignsApi->create_sms_campaign: #{e}"
end
Language
Credentials
Header
Click Try It! to start a request and see the response here!