Welcome back my valued viewers,

You will learn how to leverage the API Key of 1Byte SMS Service and how to integrate this amazing key into your application, program, or whatever else you desire in this tutorial from 1Byte.

 
 

 

 

WHAT IS API KEY?

To save the post from getting too long and to appeal to people who are unfamiliar with IT knowledge, I will describe it as simply as possible.

+ Assume you’ve recently launched an application that you developed yourself. You now want your application to be able to deliver bulk SMS messages. But you have no idea how to code this functionality.
→ Your solution is find a way to intergrate 1Byte SMS service into your application.

+ Because the presence of 1Byte API Key, you now may utilize API Key integrated into your own applications.
→ As a result, you don’t need to utilize the 1Byte platform to send SMS messages; instead, your application may use the built-in 1Byte SMS service functionality.

PREREQUISITES

1) You need to have a cool-sounding Brandname

If you don’t have a BrandName yet, see the instructions for creating a BrandName in this post.

 

2) You need to have at least 1$ in your wallet to use this service.

 

3) You need to have API Key

→ Select “API Key Management” from the User Dashboard page. You’ll find the SMS API Key there.

 

4) A list of receivers in JSON format, nomarlly this list comes with 3 main fields of information: Name, Phone Number and Date of Birth.

 
 

 

 

GENERAL INFO

+ APIs only work on HTTPS protocol

 

+ Limit API calls to 100 times per minute


+ API response data will be in JSON format

 

+ The APIs will respond with the following appropriate HTTP status code:

1) Status 200 OK → everything goes well

2) Status 4XX for → this fault is on your side (Ex: You don’t have enough money to send SMS, Invalid BrandName, …etc).

3) Status 5XX → this is fault’s 1Byte, error from our API server

DEMO CASE + SYNTAX

+ Check your API Key in User Dashboard, at API Key Management section

(To advoid abuse API Key, at here 1Byte will blur a part of the API Key)

 

+ Need to remember that all parameters passed in each case are sensitive case

→ Therefore, it must be written correctly

 

Ex: parameter is “brandName” but you type “brandname

→ Is not correct, because the letter “N” is not uppercase

 

+ Make POST request to this URL: https://api.1byte.com/external/sms

 

Case 1: send type is "now" (send immediately)

				
					//This is the HEADER section of POST request
X-API-KEY: 1ce8ac553ab0559xxxxxxxxxf61a     //insert your SMS API KEY here
				
			
				
					//This is the BODY section of POST request
{
  "brandName": "1Byte-Demo",              //insert your SMS Brandname in here
  "subject": "Warning about COVID-19 ",   //insert your SMS title in here
  "content": "Require all employees of company A to wear masks when working ", //insert your SMS content in here
  "type": "NOW",
  "listUser": [
    {
      "name": "Person A",                 //insert your customer name in here
      "phoneNumber": "+855123123123"      //insert your customer phone in here
    },
    {
      "name": "Person B",                 //insert your customer name in here
      "phoneNumber": "+855123456789"      //insert your customer phone in here
    }
  ]
}
				
			

CASE 2: SEND TYPE IS "BIRTHDAY" (SEND BASED ON BIRTHDAY)

				
					//This is the HEADER section of POST request
X-API-KEY: 1ce8ac553ab0559xxxxxxxxxf61a     //insert your SMS API KEY here
				
			
				
					{
  "brandName": "1Byte-Demo",          //insert your SMS Brandname in here
  "subject": "Happy Brithday",        //insert your SMS title in here
  "content": "1Byte would like to wish you happy brithday!!!",   //insert your SMS content in here
  "type": "BIRTHDAY",
  "timezone": "Asia/Phnom_Penh",
  "sendBefore": {
    "day": 0,                           //From the date of birth of the recipient, send 0 days before  
    "at": "24:00"                       //Send at 24:00 (midnight - 12PM) 
  },
  "listUser": [
    {
      "name": "Person A",               //insert your customer name in here
      "phoneNumber": "+855123123123",   //insert your customer phone in here
      "birthday": "22/02/1992"          //insert your customer DOB in here
    },
    {
      "name": "Person B",
      "phoneNumber": "+855123456789",
      "birthday": "22/02/1992"
    }
  ]
}'
				
			

CASE 3: SEND TYPE IS "TIMER" (SEND BASED ON A CERTAIN DAY IN FUTURE)

				
					//This is the HEADER section of POST request
X-API-KEY: 1ce8ac553ab0559xxxxxxxxxf61a     //insert your SMS API KEY here
				
			
				
					//This is the BODY section of POST request
{
  "brandName": "1Byte-Demo",            //insert your SMS Brandname in here
  "subject": "Change of workplace",     //insert your SMS title in here
  "content": "We will no longer work here, but will move to Building B instead ",
  "type": "TIMER",
  "sendingTime": "2022-02-22T08:00:00.000Z",   //will be send on 22-Feb-2022 at 8AM 
  "listUser": [
    {
      "name": "Person A",                 //insert your customer name in here
      "phoneNumber": "+855123123123"      //insert your customer phone in here
    },
    {
      "name": "Person B",
      "phoneNumber": "+855123456789"
    }
  ]
}'
				
			

SOME COMMON ERRORS

+ Status 429: Too many request In one minute you use API calls more than 100 times

+ Status 401: Unauthorized → Your API Key is missing, malformed or invalid