How to Send SMS through SMS.To API Using Apex in Salesforce

Sept 30, 2023


 

 

In this blog post, we will learn about how to send sms through SMS.To API using apex.

After completing this unit, you’ll be able to:

 

What is SMS.To ?

SMS.to is a service that helps you send text messages to a lot of people at once. It's like sending a message to a big group of friends. It's a tool for managing and sending lots of text messages.

 SMS.to is a service that provides a platform for sending SMS (Short Message Service) messages.

Please note that services and companies can evolve, change, or rebrand over time, so I recommend visiting their official website or conducting a current web search to get the most up-to-date and accurate information about sms.to.

 

What features does SMS.to offer?

As of my last knowledge update in September 2023, SMS.to is a platform that offers various features related to sending and managing SMS (Short Message Service) messages. Some of the key features may include:


  1. Bulk SMS Sending:

    • The ability to send a large number of text messages to multiple recipients at once, which is particularly useful for businesses and organizations.
  2. Two-Way Messaging:

    • The capability for both sending and receiving text messages, allowing for interactive communication with users.
  3. Scheduled Messaging:

    • The option to schedule messages to be sent at a specified date and time, enabling users to plan and automate their messaging campaigns.
  4. Global Reach:

    • The ability to send SMS messages internationally, reaching recipients across different countries and regions.
  5. Custom Sender IDs:

    • The ability to use a personalized sender ID, providing brand recognition and improving message trustworthiness.
  6. API Integration:

    • Application Programming Interface (API) that allows seamless integration of SMS functionality into applications, websites, or systems.
  7. Analytics and Reporting:

    • Insights into message delivery status, open rates, click-through rates, and other relevant metrics to measure the effectiveness of SMS campaigns.
  8. Contact Management:

    • Tools to organize and manage contacts, groups, and phone numbers for targeted messaging.
  9. Delivery Status Tracking:

    • Real-time tracking of message delivery status to monitor successful or failed message deliveries.
  10. Message Personalization:

    • The ability to customize messages with the recipient's name or other relevant details for a more personalized communication experience.
  11. Opt-Out Management:

    • Compliance with opt-out regulations by providing tools for managing opt-out requests and ensuring regulatory compliance.
  12. Easy-to-Use Interface:

    • User-friendly dashboard and interfaces for easy navigation, message composition, and campaign management.

Please note that features may have been updated or expanded since my last knowledge update, so I recommend visiting the official SMS.to website for the most current and detailed information regarding their features and offerings.

 

 

Can I send bulk messages using SMS.to?

Yes, you can typically send bulk messages using SMS.to. Sending bulk messages is a common feature offered by SMS service providers like SMS.to. Bulk messaging allows you to send a large number of SMS (Short Message Service) messages to multiple recipients at once. This is particularly useful for businesses, organizations, or individuals who need to reach a wide audience quickly and efficiently.

 

How to send sms using SMS.To API Apex


End Point : https://api.sms.to/sms/send

Method : POST

 

Body Parameters

Parameter

Type

Required

Description

message

string

Yes

Your message

to

string

Yes

Phone number

bypass_optout

boolean

No

True will bypass optouts

sender_id

string

No

The displayed value of who sent the message

callback_url

string

No

A callback URL that will be used to send back information about updates of message status. See here for more details.

 

Write Below Code in your Apex Class:

public class SMSToAPICall {

    public void sendSMS()  {

        HttpRequest request = new HttpRequest();

        request.setEndpoint('https://api.sms.to/sms/send');

        request.setHeader('Authorization', 'Bearer ');

        request.setHeader('Content-Type', 'application/json');

        request.setMethod('POST');

        String requestBody = '{"message": "This is test and this is a new line","to": "Your Mobile Number"}';

        request.setBody(requestBody);

        Http http = new Http();

        HttpResponse response = http.send(request);

  if(response.getStatusCode() == 200)

        {

            System.debug('response.getBody() >> '+response.getBody());

        }

        else

        {

            System.debug('Error >> '+response.getBody()+ ' Status Code >> ' +response.getStatusCode());

        }

    }

}

 

 

I hope this blog helped you!