### Get All Inbound Fax Automations (Python) Source: https://developers.clicksend.com/docs/_spec/automations/fax.json?download= This Python example shows how to fetch inbound fax automations. Ensure you have the ClickSend client library installed and configured with your API credentials. ```python from __future__ import print_function import ClickSend from ClickSend.rest import ApiException from pprint import pprint # configure_authentication configuration = ClickSend.Configuration() configuration.username = "USERNAME" configuration.password = "API_KEY" # create an instance of the API class api_instance = ClickSend.InboundFAXRulesApi(ClickSend.ApiClient(configuration)) page = 1 # Integer | Page number limit = 10 # Integer | Number of records per page q = "q_example" try: # Get all inbound fax automations api_response = api_instance.fax_inbound_automations_get(q, page, limit) pprint(api_response) except ApiException as e: print("Exception when calling InboundFAXRulesApi->fax_inbound_automations_get: %s\n" % e) ``` -------------------------------- ### Download Voice Statistics (Python) Source: https://developers.clicksend.com/docs/_spec/messaging/statistics.json?download= This Python example demonstrates fetching voice statistics. Ensure you have the clicksend_client library installed and configure your credentials. ```python from __future__ import print_function import clicksend_client # Configure HTTP basic authorization: BasicAuth configuration = clicksend_client.Configuration() configuration.username = 'USERNAME' configuration.password = 'API_KEY' # create an instance of the API class api_instance = clicksend_client.StatisticsApi(clicksend_client.ApiClient(configuration)) try: # Get voice statistics api_response = api_instance.statistics_voice_get() print(api_response) except ApiException as e: print("Exception when calling StatisticsApi->statistics_voice_get: %s\n" % e) ``` -------------------------------- ### Calculate MMS Price - Python Source: https://developers.clicksend.com/docs/_spec/messaging/mms.json?download= This Python example shows how to calculate MMS pricing. Ensure you have the 'clicksend_client' library installed and configured with your credentials. ```Python from __future__ import print_function import clicksend_client from clicksend_client import MmsMessage from clicksend_client.rest import ApiException # Configure HTTP basic authorization: BasicAuth configuration = clicksend_client.Configuration() configuration.username = 'USERNAME' configuration.password = 'API_KEY' # create an instance of the API class api_instance = clicksend_client.MMSApi(clicksend_client.ApiClient(configuration)) MmsMessage=MmsMessage(to='+61437111222', body='This is a test body with special character', subject='This is a subject', _from='test', country='AU') # MmsMessageCollection | MmsMessageCollection model mms_messages = clicksend_client.MmsMessageCollection( media_file='https://test.com/test.gif', messages=[MmsMessage]) try: # Get Price for MMS sent api_response = api_instance.mms_price_post(mms_messages) print(api_response) except ApiException as e: print("Exception when calling MMSApi->mms_price_post: %s\n" % e) ``` -------------------------------- ### Create Email Template in Ruby Source: https://developers.clicksend.com/docs/_spec/messaging/email.json?download= A Ruby example for creating an email template. Ensure the `clicksend_client` gem is installed and configured with your API credentials. ```Ruby # load the gem require 'clicksend_client' require 'json' # setup authorization ClickSendClient.configure do |config| # Configure HTTP basic authorization: BasicAuth config.username = 'USERNAME' config.password = 'API_KEY' end api_instance = ClickSendClient::UserEmailTemplatesApi.new # EmailTemplateNew | Email template model email_template = ClickSendClient::EmailTemplateNew.new( "template_name": "template_name", "template_id_master": 10115 ) begin # Create email template result = api_instance.email_template_post(email_template) p JSON.parse(result) rescue ClickSendClient::ApiError => e puts "Exception when calling UserEmailTemplatesApi->email_template_post: #{e.response_body}" end ``` -------------------------------- ### Download All Master Email Templates (C#) Source: https://developers.clicksend.com/docs/_spec/messaging/email.json?download= This C# example shows how to get master email templates. Set up the API configuration with your username and API key. ```csharp using IO.ClickSend.ClickSend.Api; using IO.ClickSend.Client; using IO.ClickSend.ClickSend.Model; var configuration = new Configuration() { Username = USERNAME, Password = API_KEY }; var masterEmailTemplatesApi = new MasterEmailTemplatesApi(configuration); var response = masterEmailTemplatesApi.MasterEmailTemplatesGet(); ``` -------------------------------- ### Search Available Numbers (C#) Source: https://developers.clicksend.com/docs/_spec/messaging/sender_ids/numbers.json?download= This C# example shows how to search for available numbers. Ensure you have the ClickSend SDK installed and configure your API credentials. ```csharp using IO.ClickSend.ClickSend.Api; using IO.ClickSend.Client; using IO.ClickSend.ClickSend.Model; var configuration = new Configuration() { Username = USERNAME, Password = API_KEY }; var numberApi = new NumberApi(configuration); var response = numberApi.NumbersSearchByCountryGet("CA"); ``` -------------------------------- ### Send Email Campaign in Ruby Source: https://developers.clicksend.com/docs/_spec/messaging/email.json?download= This Ruby example demonstrates sending an email campaign. It requires the 'clicksend_client' gem and proper authentication setup. ```ruby # load the gem require 'clicksend_client' require 'json' # setup authorization ClickSendClient.configure do |config| # Configure HTTP basic authorization: BasicAuth config.username = 'USERNAME' config.password = 'API_KEY' end api_instance = ClickSendClient::EmailMarketingApi.new # EmailCampaign | Email model email_campaign = ClickSendClient::EmailCampaign.new( "schedule": 0, "list_id": 123, "subject": "subject", "from_email_address_id": 1234, "name": "name", "template_id": 6.027456183070403, "body": "body", "from_name": "from_name" ) begin # Send email campaign result = api_instance.email_campaign_post(email_campaign) p JSON.parse(result) rescue ClickSendClient::ApiError => e puts "Exception when calling EmailMarketingApi->email_campaign_post: #{e.response_body}" end ``` -------------------------------- ### Send SMS Campaign using Python Source: https://developers.clicksend.com/docs/_spec/messaging/sms-campaigns.json?download= This Python example shows how to send an SMS campaign. It requires the ClickSend Python SDK and proper authentication setup. ```python from clicksend_api.rest import ApiException from clicksend_api.api import sms_campaign_api from clicksend_api.model.sms_campaign import SmsCampaign # Configure HTTP basic authorization: BasicAuth configuration = clicksend_api.Configuration() configuration.username = "USERNAME" configuration.password = "API_KEY" # create an instance of the API class api_instance = sms_campaign_api.SmsCampaignApi(clicksend_api.ApiClient(configuration)) sms_campaign = SmsCampaign(list_id=185161, name='My Campaign 1', body='This is my new campaign message.') try: # Send sms campaign api_response = api_instance.sms_campaigns_send_post(sms_campaign) print(api_response) except ApiException as e: print("Exception when calling SmsCampaignApi->sms_campaigns_send_post: %s\n" % e) ``` -------------------------------- ### Get Voice Delivery Receipt Automations (Python) Source: https://developers.clicksend.com/docs/_spec/automations/voice.yaml?download= Python example for fetching voice delivery receipt automations. It uses the 'clicksend_client' library and requires authentication credentials. ```python from __future__ import print_function import clicksend_client from clicksend_client.rest import ApiException # Configure HTTP basic authorization: BasicAuth configuration = clicksend_client.Configuration() configuration.username = 'USERNAME' configuration.password = 'API_KEY' # create an instance of the API class api_instance = clicksend_client.VoiceDeliveryReceiptRulesApi(clicksend_client.ApiClient(configuration)) page = 1 # int | Page number (optional) (default to 1) limit = 10 # int | Number of records per page (optional) (default to 10) try: # Get all voice delivery receipt automations api_response = api_instance.voice_delivery_receipt_automations_get(page=page, limit=limit) print(api_response) except ApiException as e: print("Exception when calling VoiceDeliveryReceiptRulesApi->voice_delivery_receipt_automations_get: %s\n" % e) ``` -------------------------------- ### Download Voice Statistics (Node.js) Source: https://developers.clicksend.com/docs/_spec/messaging/statistics.json?download= This Node.js example shows how to get voice statistics. It uses the provided API client and requires your username and API key. ```javascript var api = require('./api.js'); var statisticsApi = new api.StatisticsApi("USERNAME", "API_KEY"); statisticsApi.statisticsVoiceGet().then(function(response) { console.log(response.body); }).catch(function(err){ console.error(err.body); }); ``` -------------------------------- ### Calculate Voice Message Price in Python Source: https://developers.clicksend.com/docs/_spec/messaging/voice-messaging.json?download= This Python example demonstrates how to calculate voice message prices. Ensure you have the ClickSend Python SDK installed and configured. ```Python from __future__ import print_function import ClickSendSDK.api.voice_api from ClickSendSDK.rest import ApiException from pprint import pprint # Configure HTTP basic authorization: BasicAuth configuration = ClickSendSDK.Configuration() configuration.username = "USERNAME" configuration.password = "API_KEY" # create an instance of the API class api_client = ClickSendSDK.ApiClient(configuration) api_instance = ClickSendSDK.api.voice_api.VoiceApi(api_client) # VoiceMessageCollection | VoiceMessageCollection model voice_message = ClickSendSDK.models.voice_message.VoiceMessage() voice_message.to = "+61411111111" voice_message.body = "Jelly liquorice marshmallow candy carrot cake 4Eyffjs1vL" voice_message.voice = "female" voice_message.custom_string = "this is a test" voice_message.country = "US" voice_message.source = "source" voice_message.list_id = 185161 voice_message.lang = "en-au" voice_message.require_input = 1 voice_message.machine_detection = 1 voice_messages = ClickSendSDK.models.voice_message_collection.VoiceMessageCollection() voice_messages.messages = [voice_message] try: # Calculate voice price result = api_instance.voice_price_post(voice_messages) pprint(result) except ApiException as e: print("Exception when calling VoiceApi->voice_price_post: %s\n" % e) ``` -------------------------------- ### Get MMS Campaigns List (PHP) Source: https://developers.clicksend.com/docs/_spec/messaging/mms-campaigns.json?download= PHP example for retrieving MMS campaigns. Requires the ClickSend SDK and basic authentication setup. ```PHP setUsername('USERNAME') ->setPassword('API_KEY'); $apiInstance = new ClickSend\Api\MmsCampaignApi(new GuzzleHttp\Client(),$config); $page = 1; // int | Page number $limit = 10; // int | Number of records per page try { $result = $apiInstance->mmsCampaignsGet($page, $limit); print_r($result); } catch (Exception $e) { echo 'Exception when calling MmsCampaignApi->mmsCampaignsGet: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### Get Fax Receipts (Node.js) Source: https://developers.clicksend.com/docs/_spec/messaging/fax.json?download= Example for retrieving fax receipts using Node.js. This snippet requires the ClickSend Node.js SDK and proper authentication setup. ```javascript const ClickSendClient = require('clicksendsdk'); const client = new ClickSendClient('YOUR_USERNAME', 'YOUR_AUTH_TOKEN'); client.fax.getReceipts(function(error, response) { if (error) { console.error(error); } else { console.log(response.body); } }); ``` -------------------------------- ### Calculate SMS Campaign Price using C# Source: https://developers.clicksend.com/docs/_spec/messaging/sms-campaigns.json?download= This C# example shows how to initialize the ClickSend client and calculate SMS campaign prices. Remember to replace USERNAME and API_KEY with your credentials. ```csharp using IO.ClickSend.ClickSend.Api; using IO.ClickSend.Client; using IO.ClickSend.ClickSend.Model; var configuration = new Configuration() { Username = USERNAME, Password = API_KEY }; var smsCampaignApi = new SmsCampaignApi(configuration); var response = smsCampaignApi.SmsCampaignsPricePost(new SmsCampaign( listId: 1234, name: "Campaign Name", body: "Body" )); ``` -------------------------------- ### Get Specific Master Email Template Category (PHP) Source: https://developers.clicksend.com/docs/_spec/messaging/email.json?download= PHP example for retrieving a specific master email template category. Ensure you have the Clicksend SDK installed and configured with your credentials. ```PHP setUsername('USERNAME') ->setPassword('API_KEY'); $apiInstance = new ClickSend\Api\MasterEmailTemplatesApi(new GuzzleHttp\Client(),$config); $category_id = 4; // int | Email category id try { $result = $apiInstance->masterEmailTemplateCategoryGet($category_id); print_r($result); } catch (Exception $e) { echo 'Exception when calling MasterEmailTemplatesApi->masterEmailTemplateCategoryGet: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### Get Specific Master Email Template Category (Ruby) Source: https://developers.clicksend.com/docs/_spec/messaging/email.json?download= Ruby example for retrieving a specific master email template category. This code uses the Clicksend client gem and requires authentication setup. ```Ruby # load the gem require 'clicksend_client' require 'json' # setup authorization ClickSendClient.configure do |config| # Configure HTTP basic authorization: BasicAuth config.username = 'USERNAME' config.password = 'API_KEY' end api_instance = ClickSendClient::MasterEmailTemplatesApi.new category_id = 56 # Integer | Email category id begin # Get specific master email template category result = api_instance.master_email_template_category_get(category_id) p JSON.parse(result) rescue ClickSendClient::ApiError => e puts "Exception when calling MasterEmailTemplatesApi->master_email_template_category_get: #{e.response_body}" end ``` -------------------------------- ### Get SMS Price Source: https://developers.clicksend.com/docs/_spec/messaging/sms.json?download= This example demonstrates how to get the price for sending SMS messages using the ClickSendClient library in Perl. ```APIDOC ## Get SMS Price ### Description Use this endpoint to get the price of sending an SMS. ### Method POST ### Endpoint /sms/price ### Parameters #### Request Body - **sms_messages** (SmsMessageCollection) - Required - Your message(s) in a collection object. ``` -------------------------------- ### Download All Master Email Templates (Python) Source: https://developers.clicksend.com/docs/_spec/messaging/email.json?download= This Python example shows how to get master email templates using the clicksend_client library. Configure authentication with your username and API key. ```python from __future__ import print_function import clicksend_client from clicksend_client.rest import ApiException # Configure HTTP basic authorization: BasicAuth configuration = clicksend_client.Configuration() configuration.username = 'USERNAME' configuration.password = 'API_KEY' # create an instance of the API class api_instance = clicksend_client.MasterEmailTemplatesApi(clicksend_client.ApiClient(configuration)) page = 1 # int | Page number (optional) (default to 1) limit = 10 # int | Number of records per page (optional) (default to 10) try: # Get all master email templates api_response = api_instance.master_email_templates_get(page=page, limit=limit) print(api_response) except ApiException as e: print("Exception when calling MasterEmailTemplatesApi->master_email_templates_get: %s\n" % e) ``` -------------------------------- ### Get Delivery Issues in Python Source: https://developers.clicksend.com/docs/_spec/messaging/message-delivery.json?download= This Python example shows how to retrieve delivery issues using the clicksend_client library. Set up basic HTTP authentication with your username and password. The API response is printed. ```Python from __future__ import print_function import clicksend_client from clicksend_client.rest import ApiException # Configure HTTP basic authorization: BasicAuth configuration = clicksend_client.Configuration() configuration.username = 'USERNAME' configuration.password = 'API_KEY' # create an instance of the API class api_instance = clicksend_client.DeliveryIssuesApi(clicksend_client.ApiClient(configuration)) page = 1 # int | Page number (optional) (default to 1) limit = 10 # int | Number of records per page (optional) (default to 10) try: # Get all delivery issues api_response = api_instance.delivery_issues_get(page=page, limit=limit) print(api_response) except ApiException as e: print("Exception when calling DeliveryIssuesApi->delivery_issues_get: %s\n" % e) ``` -------------------------------- ### Get Specific Allowed Email Address (Node.js) Source: https://developers.clicksend.com/docs/_spec/messaging/email.json?download= This Node.js example shows how to get a specific allowed email address. Instantiate the `EmailMarketingApi` with your credentials and call the `specificAllowedEmailAddressGet` method. ```javascript var api = require('./api.js'); var emailMarketingApi = new api.EmailMarketingApi("USERNAME", "API_KEY"); var emailAddressId = 4400; emailMarketingApi.specificAllowedEmailAddressGet(emailAddressId).then(function(response) { console.log(response.body); }).catch(function(err){ console.error(err.body); }); ``` -------------------------------- ### Get Specific Inbound SMS Automation (Node.js) Source: https://developers.clicksend.com/docs/_spec/automations/sms.json?download= This Node.js example shows how to get a specific inbound SMS automation rule. It uses the ClickSend Node.js SDK and requires your API credentials. ```Node.js var api = require('./api.js'); var inboundSmsRuleApi = new api.InboundSMSRulesApi("USERNAME", "API_KEY"); var inboundRuleId = 134750; inboundSmsRuleApi.smsInboundAutomationGet(inboundRuleId).then(function(response) { console.log(response.body); }).catch(function(err){ console.error(err.body); }); ``` -------------------------------- ### Create Email Delivery Receipt Automation (Swift) Source: https://developers.clicksend.com/docs/_spec/automations/email.json?download= This Swift example shows how to create an email delivery receipt automation. It includes setting up authentication headers and defining the delivery receipt rule parameters. ```swift import Alamofire if let authHeader = Request.authorizationHeader(user: "USERNAME", password: "PASSWORD") { ClickSendClientAPI.customHeaders = [authHeader.key : authHeader.value] } let deliveryReceiptRule = DeliveryReceiptRule( ruleName: "rulename", matchType: 1, action: "action", actionAddress: "actionAddress", enabled: 1 ) EmailDeliveryReceiptRulesAPI.emailDeliveryReceiptAutomationPost(deliveryReceiptRule: deliveryReceiptRule) { (dataString, error) in guard let dataString = dataString else { print(error!) return } if let data = dataString.data(using: String.Encoding.utf8) { do { if let dictonary = try (JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary) { print(dictonary) } else { print("Cannot convert the String value to JSON") } } catch let error as NSError { print(error) } } } ``` -------------------------------- ### Get SMS History in C# Source: https://developers.clicksend.com/docs/_spec/messaging/sms.json?download= This C# example demonstrates how to retrieve SMS history. Replace 'USERNAME' and 'API_KEY' with your actual credentials. ```csharp using IO.ClickSend.ClickSend.Api; using IO.ClickSend.Client; using IO.ClickSend.ClickSend.Model; var configuration = new Configuration() { Username = USERNAME, Password = API_KEY }; var smsApi = new SMSApi(configuration); var q = "q_example"; var dateFrom = '1436879372'; var dateTo = '1436879372'; var page = 1; var limit = 10; var response = smsApi.SmsHistoryGet(q, dateFrom, dateTo, page, limit); ``` -------------------------------- ### Get Email Template (Swift) Source: https://developers.clicksend.com/docs/_spec/messaging/email.json?download= This Swift example demonstrates fetching an email template using the ClickSend Swift SDK. It includes setting up authentication headers and handling the response. ```swift import Alamofire if let authHeader = Request.authorizationHeader(user: "USERNAME", password: "PASSWORD") { ClickSendClientAPI.customHeaders = [authHeader.key : authHeader.value] } UserEmailTemplatesAPI.emailTemplateGet(templateId: 1) { (dataString, error) in guard let dataString = dataString else { print(error!) return } if let data = dataString.data(using: String.Encoding.utf8) { do { if let dictonary = try (JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary) { print(dictonary) } else { print("Cannot convert the String value to JSON") } } catch let error as NSError { print(error) } } } ``` -------------------------------- ### Get MMS Campaigns List (Node.js) Source: https://developers.clicksend.com/docs/_spec/messaging/mms-campaigns.json?download= Node.js example for retrieving MMS campaigns. Authenticate using your username and API key. ```Node.js var api = require('./api.js'); var mmsCampaignApi = new api.MmsCampaignApi("USERNAME", "API_KEY"); var page = 1; var limit = 10; mmsCampaignApi.mmsCampaignsGet(page, limit).then(function(response) { console.log(response.body); }).catch(function(err){ console.error(err.body); }); ``` -------------------------------- ### Get MMS History (Node.js) Source: https://developers.clicksend.com/docs/_spec/messaging/mms.json?download= Node.js example to fetch MMS history. This requires the ClickSend Node.js SDK and your API credentials. ```javascript var api = require('./api.js'); var mmsApi = new api.MMSApi("USERNAME", "API_KEY"); var q = "q_example"; var dateFrom = '1436879372'; var dateTo = '1436879372'; var page = 1; var limit = 10; mmsApi.mmsHistoryGet(q, dateFrom, dateTo, page, limit).then(function(response) { console.log(response.body); }).catch(function(err){ console.error(err.body); }); ``` -------------------------------- ### Get MMS History (PHP) Source: https://developers.clicksend.com/docs/_spec/messaging/mms.json?download= PHP example for retrieving MMS history. Requires the ClickSend SDK and basic HTTP authentication. ```php setUsername('USERNAME') ->setPassword('API_KEY'); $apiInstance = new ClickSend\Api\MMSApi(new GuzzleHttp\Client(),$config); $q = "q_example"; // string | Custom query Example: from:{number},status_code:201. $date_from = '1436879372'; // int | Start date $date_to = '1436879372'; // int | End date $page = 1; // int | Page number $limit = 10; // int | Number of records per page try { $result = $apiInstance->mmsHistoryGet($q, $date_from, $date_to, $page, $limit); print_r($result); } catch (Exception $e) { echo 'Exception when calling MMSApi->mmsHistoryGet: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### Create Email Delivery Receipt Rule (C#) Source: https://developers.clicksend.com/docs/_spec/automations/email.json?download= This C# example demonstrates how to create an email delivery receipt rule. Ensure you have the ClickSend client library installed and configured with your credentials. ```C# using IO.ClickSend.ClickSend.Api; using IO.ClickSend.Client; using IO.ClickSend.ClickSend.Model; var configuration = new Configuration() { Username = USERNAME, Password = API_KEY }; var deliveryIssuesApi = new DeliveryIssuesApi(configuration); var response = emailDeliveryReceiptRulesApi.EmailDeliveryReceiptAutomationPost(new DeliveryReceiptRule( ruleName: "RULE_NAME", matchType: 0, action: "URL", actionAddress: "http://yourdomain.com", enabled: 1 )); ``` -------------------------------- ### Get List of Fax Receipts - Swift Source: https://developers.clicksend.com/docs/_spec/messaging/fax.json?download= Fetch fax receipts in Swift. This example demonstrates setting up authentication headers and handling the response. ```swift import Alamofire if let authHeader = Request.authorizationHeader(user: "USERNAME", password: "PASSWORD") { ClickSendClientAPI.customHeaders = [authHeader.key : authHeader.value] } FAXAPI.faxReceiptsGet { (dataString, error) in if let error = error { print(error) } else { if let data = dataString!.data(using: String.Encoding.utf8) { do { if let dictonary = try (JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary) { print(dictonary) } else { print("bad json") } } catch let error as NSError { print(error) } } } } ``` -------------------------------- ### Get SMS Statistics - Objective-C Source: https://developers.clicksend.com/docs/_spec/messaging/statistics.json?download= Fetch SMS statistics in Objective-C. This example demonstrates setting up the API configuration and handling the completion handler. ```objc #import "CSStatisticsApi.h" #import "CSDefaultConfiguration.h" CSDefaultConfiguration *apiConfig = [CSDefaultConfiguration sharedConfig]; [apiConfig setUsername:@"USERNAME"]; [apiConfig setPassword:@"PASSWORD"]; CSStatisticsApi *statisticsApiInstance = [[CSStatisticsApi alloc] init]; [statisticsApiInstance statisticsSmsGetWithCompletionHandler:^(NSString *output, NSError *error) { if (error) { NSLog(@"Error: %@", error); } else { NSLog(@"%@", output); } }]; ``` -------------------------------- ### Get All Email Campaigns (Python) Source: https://developers.clicksend.com/docs/_spec/messaging/email.json?download= This Python example demonstrates how to retrieve all email campaigns using the ClickSend SDK. It requires setting up the API client with your credentials and handling potential API errors. ```python from __future__ import print_function import time import clicksend_marketing from clicksend_marketing.rest import ApiException from pprint import pprint # Configure HTTP basic authorization: BasicAuth configuration = clicksend_marketing.Configuration() configuration.username = 'USERNAME' configuration.password = 'API_KEY' # create an instance of the API class api_instance = clicksend_marketing.EmailMarketingApi(clicksend_marketing.ApiClient(configuration)) page = 1 # int | Page number limit = 10 # int | Number of records per page try: # Get all email campaigns api_response = api_instance.email_campaigns_get(page, limit) pprint(api_response) except ApiException as e: print("Exception when calling EmailMarketingApi->email_campaigns_get: %s\n" % e) ``` -------------------------------- ### Download Voice Statistics (C#) Source: https://developers.clicksend.com/docs/_spec/messaging/statistics.json?download= This C# example demonstrates how to fetch voice statistics using the ClickSend API client. Set your username and API key for authentication. ```csharp using IO.ClickSend.ClickSend.Api; using IO.ClickSend.Client; using IO.ClickSend.ClickSend.Model; var configuration = new Configuration() { Username = USERNAME, Password = API_KEY }; var statisticsApi = new StatisticsApi(configuration); var response = statisticsApi.StatisticsVoiceGet(); ``` -------------------------------- ### Get SMS History in PHP Source: https://developers.clicksend.com/docs/_spec/messaging/sms.json?download= Use this PHP snippet to fetch your SMS history. Ensure you have the ClickSend SDK installed and configured with your credentials. ```php setUsername('USERNAME') ->setPassword('API_KEY'); $apiInstance = new ClickSend\Api\SMSApi(new GuzzleHttp\Client(),$config); $q = "q_example"; // string | Custom query Example: from:{number},status_code:201. $date_from = '1436879372'; // int | Start date $date_to = '1436879372'; // int | End date $page = 1; // int | Page number $limit = 10; // int | Number of records per page try { $result = $apiInstance->smsHistoryGet($q, $date_from, $date_to, $page, $limit); print_r($result); } catch (Exception $e) { echo 'Exception when calling SMSApi->smsHistoryGet: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### Get Specific SMS Campaign - Ruby Source: https://developers.clicksend.com/docs/_spec/messaging/sms-campaigns.json?download= Retrieve a specific SMS campaign by its ID. Ensure the `clicksend_client` gem is installed and authentication is configured. ```Ruby # load the gem require 'clicksend_client' require 'json' # setup authorization ClickSendClient.configure do |config| # Configure HTTP basic authorization: BasicAuth config.username = 'USERNAME' config.password = 'API_KEY' end api_instance = ClickSendClient::SmsCampaignApi.new sms_campaign_id = 56 # Integer | ID of SMS campaign to retrieve begin # Get specific sms campaign result = api_instance.sms_campaign_by_sms_campaign_id_get(sms_campaign_id) p JSON.parse(result) rescue ClickSendClient::ApiError => e puts "Exception when calling SmsCampaignApi->sms_campaign_by_sms_campaign_id_get: #{e.response_body}" end ``` -------------------------------- ### Create Email Template using C# Source: https://developers.clicksend.com/docs/_spec/messaging/email.json?download= Provides a C# example for creating an email template with the ClickSend SDK. Requires username and API key for authentication. ```csharp using IO.ClickSend.ClickSend.Api; using IO.ClickSend.Client; using IO.ClickSend.ClickSend.Model; var configuration = new Configuration() { Username = USERNAME, Password = API_KEY }; var userEmailTemplatesApi = new UserEmailTemplatesApi(configuration); var response = userEmailTemplatesApi.EmailTemplatePost(new EmailTemplateNew( templateName: "Template Name", templateIdMaster: TEMPLATE_MASTER_ID )); ``` -------------------------------- ### Calculate SMS Campaign Price in Swift Source: https://developers.clicksend.com/docs/_spec/messaging/sms-campaigns.json?download= Swift example demonstrating how to calculate SMS campaign prices using the ClickSendClientAPI. It includes setting up authentication headers and handling the API response. ```swift import Alamofire if let authHeader = Request.authorizationHeader(user: "USERNAME", password: "PASSWORD") { ClickSendClientAPI.customHeaders = [authHeader.key : authHeader.value] } let campaign = SmsCampaign( listId: 258, name: "name", body: "body" ) SmsCampaignAPI.smsCampaignsPricePost(campaign: campaign) { (dataString, error) in if let error = error { print(error) } else { if let data = dataString!.data(using: String.Encoding.utf8) { do { if let dictonary = try (JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary) { print(dictonary) } else { print("Cannot convert the String value to JSON") } } catch let error as NSError { print(error) } } } } ``` -------------------------------- ### Send SMS Campaign using C# Source: https://developers.clicksend.com/docs/_spec/messaging/sms-campaigns.json?download= This C# example shows how to send an SMS campaign using the ClickSend client library. You need to configure your username and API key, then instantiate the SmsCampaignApi. ```csharp using IO.ClickSend.ClickSend.Api; using IO.ClickSend.Client; using IO.ClickSend.ClickSend.Model; var configuration = new Configuration() { Username = USERNAME, Password = API_KEY }; var smsCampaignApi = new SmsCampaignApi(configuration); var response = smsCampaignApi.SmsCampaignsSendPost(new SmsCampaign( listId: LIST_ID, name: "Campaign Name", body: "Body" )); ``` -------------------------------- ### Get Email History in Node.js Source: https://developers.clicksend.com/docs/_spec/messaging/email.json?download= Fetch email history using the TransactionalEmailApi. This example requires the api.js file and proper API key configuration. ```Node.js var api = require('./api.js'); var emailTransactionalApi = new api.TransactionalEmailApi("USERNAME", "API_KEY"); var dateFrom = '1546913229'; var dateTo = '1546923229'; var page = 1; var limit = 10; emailTransactionalApi.emailHistoryGet(dateFrom, dateTo, page, limit).then(function(response) { console.log(response.body); }).catch(function(err){ console.error(err.body); }); ``` -------------------------------- ### Send MMS Campaign using C# Source: https://developers.clicksend.com/docs/_spec/messaging/mms-campaigns.json?download= This C# example shows how to send an MMS campaign using the ClickSend SDK. Replace placeholders like USERNAME, API_KEY, LIST_ID, and TimeStamp with your specific values. ```csharp using IO.ClickSend.ClickSend.Api; using IO.ClickSend.Client; using IO.ClickSend.ClickSend.Model; var configuration = new Configuration() { Username = USERNAME, Password = API_KEY }; var mmsCampaignApi = new MmsCampaignApi(configuration); var response = mmsCampaignApi.MmsCampaignsSendPost(new MmsCampaign() { ListId = LIST_ID, Name = "Name", Body = "This is test body", From = "+11231231234", Schedule = TimeStamp, Subject = "Test subject", MediaFile = "https://yourdomain.com/file.jpg" }); ``` -------------------------------- ### Get Voice History (PHP) Source: https://developers.clicksend.com/docs/_spec/messaging/voice-messaging.json?download= PHP example for retrieving voice call history. This requires the ClickSend SDK and proper configuration of authentication credentials. ```php setUsername('USERNAME') ->setPassword('API_KEY'); $apiInstance = new ClickSend\Api\VoiceApi(new GuzzleHttp\Client(),$config); $date_from = '2018-01-01'; // int | Timestamp (from) used to show records by date. $date_to = '2019-01-01'; // int | Timestamp (to) used to show records by date $page = 1; // int | Page number $limit = 10; // int | Number of records per page try { $result = $apiInstance->voiceHistoryGet($date_from, $date_to, $page, $limit); print_r($result); } catch (Exception $e) { echo 'Exception when calling VoiceApi->voiceHistoryGet: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### Calculate Email Price with C# Source: https://developers.clicksend.com/docs/_spec/messaging/email.json?download= This C# example shows how to calculate email sending costs. It requires the ClickSend SDK and your API credentials. ```C# using IO.ClickSend.ClickSend.Api; using IO.ClickSend.Client; using IO.ClickSend.ClickSend.Model; var configuration = new Configuration() { Username = USERNAME, Password = API_KEY }; var transactionalEmailApi = new TransactionalEmailApi(configuration); var listOfRecipients = new List(); listOfRecipients.Add(new EmailRecipient( email: "john@doe.com", name: "John Doe" )); var listOfCC = new List(); listOfCC.Add(new EmailRecipient( email: "john@doe.com", name: "John Doe" )); var listOfBCC = new List(); listOfBCC.Add(new EmailRecipient( email: "john@doe.com", name: "John Doe" )); var listOfAttachments = new List(); listOfAttachments.Add(new Attachment( content: "content", type: "type", filename: "filename", disposition: "disposition", contentId: "contentId" )); var emailFrom = new EmailFrom( emailAddressId: FROM_EMAIL_ID_GOES, name: "John Doe" ); var response = transactionalEmailApi.EmailPricePost(new Email( to: listOfRecipients, cc: listOfCC, bcc: listOfBCC, from: emailFrom, subject: "Test Subject", body: "Test Body", attachments: listOfAttachments )); ``` -------------------------------- ### Get All Inbound Fax Automations (Node.js) Source: https://developers.clicksend.com/docs/_spec/automations/fax.json?download= This Node.js example fetches inbound fax automations. Provide your API credentials and call the faxInboundAutomationsGet method. ```javascript var api = require('./api.js'); var inboundFaxRuleApi = new api.InboundFAXRulesApi("USERNAME", "API_KEY"); var q = "q_example"; var page = 1; var limit = 10; inboundFaxRuleApi.faxInboundAutomationsGet(q, page, limit).then(function(response) { console.log(response.body); }).catch(function(err){ console.error(err.body); }); ``` -------------------------------- ### Create Voice Delivery Receipt Automation (Swift) Source: https://developers.clicksend.com/docs/_spec/automations/voice.yaml?download= This Swift example illustrates creating a voice delivery receipt automation. It includes setting up authentication headers and defining the rule parameters before making the API call. ```swift import Alamofire if let authHeader = Request.authorizationHeader(user: "USERNAME", password: "PASSWORD") { ClickSendClientAPI.customHeaders = [authHeader.key : authHeader.value] } let deliveryReceiptRule = DeliveryReceiptRule(ruleName: "ruleName", matchType: 1, action: "action", actionAddress: "actionAddress", enabled: 1) VoiceDeliveryReceiptRulesAPI.voiceDeliveryReceiptAutomationPost(deliveryReceiptRule: deliveryReceiptRule) { (dataString, error) in guard let dataString = dataString else { print(error!) return } if let data = dataString.data(using: String.Encoding.utf8) { do { if let dictonary = try (JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary) { print(dictonary) } else { print("Cannot convert the String value to JSON") } } catch let error as NSError { print(error) } } } ``` -------------------------------- ### Create Allowed Email Address using C# Source: https://developers.clicksend.com/docs/_spec/messaging/email.json?download= This C# example shows how to create an allowed email address using the ClickSend client library. Replace USERNAME and API_KEY with your credentials. ```csharp using IO.ClickSend.ClickSend.Api; using IO.ClickSend.Client; using IO.ClickSend.ClickSend.Model; var configuration = new Configuration() { Username = USERNAME, Password = API_KEY }; var deliveryIssuesApi = new DeliveryIssuesApi(configuration); var response = emailMarketingApi.AllowedEmailAddressPost(new EmailAddress( emailAddress: "john@doe.com" )); ``` -------------------------------- ### Get Allowed Email Addresses (Python) Source: https://developers.clicksend.com/docs/_spec/messaging/email.json?download= Fetches a list of allowed email addresses with pagination options. Requires the clicksend_client library to be installed and configured. ```python from __future__ import print_function import clicksend_client from clicksend_client.rest import ApiException # Configure HTTP basic authorization: BasicAuth configuration = clicksend_client.Configuration() configuration.username = 'USERNAME' configuration.password = 'API_KEY' # create an instance of the API class api_instance = clicksend_client.EmailMarketingApi(clicksend_client.ApiClient(configuration)) page = 1 # int | Page number (optional) (default to 1) limit = 10 # int | Number of records per page (optional) (default to 10) try: # Get all email addresses api_response = api_instance.allowed_email_address_get(page=page, limit=limit) print(api_response) except ApiException as e: print("Exception when calling EmailMarketingApi->allowed_email_address_get: %s\n" % e) ``` -------------------------------- ### Cancel All Voice Messages using Python Source: https://developers.clicksend.com/docs/_spec/messaging/voice-messaging.json?download= This Python example cancels all voice messages. Ensure you have the `clicksend_client` library installed and your API credentials are set. ```Python from __future__ import print_function import clicksend_client from clicksend_client.rest import ApiException # Configure HTTP basic authorization: BasicAuth configuration = clicksend_client.Configuration() configuration.username = 'USERNAME' configuration.password = 'API_KEY' # create an instance of the API class api_instance = clicksend_client.VoiceApi(clicksend_client.ApiClient(configuration)) try: # Update all voice messages as cancelled api_response = api_instance.voice_cancel_all_put() print(api_response) except ApiException as e: print("Exception when calling VoiceApi->voice_cancel_all_put: %s\n" % e) ``` -------------------------------- ### Send SMS Messages (Swift) Source: https://developers.clicksend.com/docs/_spec/messaging/sms.json?download= This Swift code example shows how to send SMS messages. It includes setting up authentication headers and constructing the SMS messages. ```swift import Alamofire if let authHeader = Request.authorizationHeader(user: "USERNAME", password: "PASSWORD") { ClickSendClientAPI.customHeaders = [authHeader.key : authHeader.value] } let message1 = SmsMessage( body: "Chocolate bar icing icing oat cake carrot cake jelly cotton MWEvciEPIr.", to: "+0451111111", source: "swift" ) let message2 = SmsMessage( body: "Chocolate bar icing icing oat cake carrot cake jelly cotton MWEvciEPIr.", source: "swift", listId: 1234, ) let smsCollection = SmsMessageCollection(messages: [message1, message2]) SMSAPI.smsPricePost(smsMessages: smsCollection) { (dataString, error) in guard let dataString = dataString else { print(error!) return } if let data = dataString.data(using: String.Encoding.utf8) { do { if let dictonary = try (JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary) { print(dictonary) } else { print("bad json") } } catch let error as NSError { print(error) } } } ``` -------------------------------- ### Search Available Numbers (Python) Source: https://developers.clicksend.com/docs/_spec/messaging/sender_ids/numbers.json?download= This Python example shows how to search for available numbers using the ClickSend SDK. Ensure you have installed the SDK and configured your API credentials. ```python from __future__ import print_function import ClickSend from ClickSend.rest import ApiException from pprint import pprint # Configure HTTP basic authorization: BasicAuth configuration = ClickSend.Configuration() configuration.username = 'USERNAME' configuration.password = 'API_KEY' # create an instance of the API class api_instance = ClickSend.NumberApi(ClickSend.ApiClient(configuration)) country = 'US' # str | Country code to search search = '' # str | Your search pattern or query. search_type = 1 # int | Your strategy for searching, 0 = starts with, 1 = anywhere, 2 = ends with. page = 1 # int | Page number limit = 10 # int | Number of records per page try: # Search available numbers by country api_response = api_instance.numbers_search_by_country_get(country, search, search_type, page, limit) pprint(api_response) except ApiException as e: print("Exception when calling NumberApi->numbers_search_by_country_get: %s\n" % e) ``` -------------------------------- ### Get MMS Campaigns List (Python) Source: https://developers.clicksend.com/docs/_spec/messaging/mms-campaigns.json?download= Python code to retrieve MMS campaigns. Ensure you have the ClickSend Python SDK installed and configured with your credentials. ```Python from __future__ import print_function import ClickSend_python.rest from ClickSend_python.rest import ApiException from pprint import pprint # configure API key authorization: BasicAuth configuration = ClickSend_python.Configuration() configuration.username = "USERNAME" configuration.password = "API_KEY" # create an instance of the API class api_instance = ClickSend_python.MmsCampaignApi(ClickSend_python.ApiClient(configuration)) page = 1 # Integer | Page number limit = 10 # Integer | Number of records per page try: # Get list of mms campaigns api_response = api_instance.mms_campaigns_get(page, limit) pprint(api_response) except ApiException as e: print("Exception when calling MmsCampaignApi->mms_campaigns_get: %s\n" % e) ``` -------------------------------- ### Get All Email Campaigns (C#) Source: https://developers.clicksend.com/docs/_spec/messaging/email.json?download= This C# example shows how to retrieve all email campaigns using the ClickSend SDK. You need to configure your username and API key before making the call. ```csharp using IO.ClickSend.ClickSend.Api; using IO.ClickSend.Client; using IO.ClickSend.ClickSend.Model; var configuration = new Configuration() { Username = USERNAME, Password = API_KEY }; var emailMarketingApi = new EmailMarketingApi(configuration); var response = emailMarketingApi.EmailCampaignsGet(); ``` -------------------------------- ### Get Email Campaign Details (Swift) Source: https://developers.clicksend.com/docs/_spec/messaging/email.json?download= Fetches details of a specific email campaign using the ClickSend Swift SDK. Requires authentication setup. ```swift import Alamofire if let authHeader = Request.authorizationHeader(user: "USERNAME", password: "PASSWORD") { ClickSendClientAPI.customHeaders = [authHeader.key : authHeader.value] } EmailMarketingAPI.emailCampaignGet(emailCampaignId: 1) { (dataString, error) in guard let dataString = dataString else { print(error!) return } if let data = dataString.data(using: String.Encoding.utf8) { do { if let dictonary = try (JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary) { print(dictonary) } else { print("Cannot convert the String value to JSON") } } catch let error as NSError { print(error) } } } ``` -------------------------------- ### Get Email Templates (Node.js) Source: https://developers.clicksend.com/docs/_spec/messaging/email.json?download= This Node.js example fetches email templates using pagination. It requires the `api.js` file and handles both successful responses and errors. ```javascript var api = require('./api.js'); var userEmailTemplateApi = new api.UserEmailTemplatesApi("USERNAME", "API_KEY"); var page = 1; var limit = 10; userEmailTemplateApi.emailTemplatesGet(page, limit).then(function(response) { console.log(response.body); }).catch(function(err){ console.error(err.body); }); ```