API Reference

Welcome to Moozisms’s API! You can use this API to access all our API endpoints.

The API is organized around REST. All requests should be made over SSL. All request and response bodies, including errors, are encoded in JSON.

We also have some specific language bindings to make integration easier. You can switch the programming language of the examples with the tabs in the top right.

To play around with a few examples, we recommend a REST client called Postman. Simply tap the button below to import a pre-made collection of examples.

Request & Send SMS

Authentication using HTTP basic auth.
                    
                      #!/bin/bash

                      base_url='http://api.moozisms.com'
                      action='/'
                      key='API_KEY'
                      secret='API_SECRET'
                      to='441632960961'
                      from='441632960960'
                      datatype = 'json' // or datatype= 'xml'
                      text="A text sent using the SMS API."

                      curl -X POST "$base_url$action" \
                      -d api_key=$key \
                      -d api_secret=$secret \
                      -d to=$to \
                      -d datatype=$datatype \
                      -d from="$from" \
                      --data-urlencode "text=$text"

                    
                  

                    



                    $data = array(
                      "api_key" => "XXXX",
                      "api_secret" => "XXXX",
                      "to" => "XXXX",    // destination number with country code without OO or+
                      "from" => "XXXX", // your startup or company name (max 11 characters)
                      "text" => "your message",
                       "datatype"=> "json" // can replace json with xml to get xml reponse
                    );

                    $url_send ="http://api.moozisms.com/";
                    $str_data = json_encode($data);

                    function sendSms($url, $post){
                      $ch = curl_init($url);
                      $headers = array();
                      $headers[] = 'Content-Type: application/json';

                      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                      curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
                      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                      curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
                      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                      $result = curl_exec($ch);
                      curl_close($ch);  /
                      return $result;
                    }

                    echo " " . sendSms($url_send, $str_data);
                    //echo $str_data;


                    
                  
                    
                      var https = require('https');

                      var data = JSON.stringify({
                       api_key: 'API_KEY',
                       api_secret: 'API_SECRET',
                       to: '441632960960',
                       from: '441632960961',
                       datatype = 'json', // or datatype= 'xml'
                       text: 'Hi Moozisms'
                      });

                      var options = {
                       host: 'api.moozisms.com',
                       path: '/',
                       //port: 443,
                       method: 'POST',
                       headers: {
                         'Content-Type': 'application/json',
                         'Content-Length': Buffer.byteLength(data)
                       }
                      };

                      var req = https.request(options);

                      req.write(data);
                      req.end();

                      var responseData = '';
                      req.on('response', function(res){
                       res.on('data', function(chunk){
                         responseData += chunk;
                       });

                       res.on('end', function(){
                         console.log(JSON.parse(responseData));
                       });
                      });

                    
                  
                    
                      import urllib
                      import urllib2

                      params = {
                          'api_key': 'API_KEY',
                          'api_secret': 'API_SECRET',
                          'to': '441632960960',
                          'from': '441632960961',
                          'datatype' = 'json', // or datatype= 'xml'
                          'text': 'Hi Koffi !!!'
                      }

                      url = 'http://api.moozisms.com/?' + urllib.urlencode(params)

                      request = urllib2.Request(url)
                      request.add_header('Accept', 'application/json')
                      response = urllib2.urlopen(request)
                      
                  
                    
                      package net.moozisms.mavenproject;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;

public class ApiClient {


    public static void main(String[] args) {

        String targetURL = "http://api.moozisms.com";//?api_key=123456&api_secret=123456&to=22892520119&from=MOM&text=cc ici&datatype=json";
        try {

            // Replace default data with your own information


            String api_key = "123456";
            String api_secret = "123456";
            String to = "22890286201"; // phonenumber of the recipient with code without 00 or +
            String from = "MOOZISMS"; // sender ID less than 11 characters
            String text = "Hello John Doe"; //Your messages without the special characters
            String datatype = "json";  //String datatype = "xml"; or datatype="json"
            String urlParameters = "api_key="+api_key+
                    "&api_secret="+api_secret+
                    "&to="+to+
                    "&from="+from+
                    "&text="+text+
                    "&datatype="+datatype;
            System.out.println("param "+urlParameters);

            byte[] postData = urlParameters.getBytes(StandardCharsets.UTF_8);
            int postDataLength = postData.length;
            URL restServiceURL = new URL(targetURL);

            HttpURLConnection httpConnection = (HttpURLConnection) restServiceURL.openConnection();
            httpConnection.setDoOutput(true);
            httpConnection.setInstanceFollowRedirects(false);
            httpConnection.setRequestMethod("POST");
            httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            httpConnection.setRequestProperty("charset", "utf-8");
            httpConnection.setRequestProperty("Content-Length", Integer.toString(postDataLength));
            httpConnection.setUseCaches(false);
            try (DataOutputStream wr = new DataOutputStream(httpConnection.getOutputStream())) {
                wr.write(postData);
            }

            int responseCode = httpConnection.getResponseCode();
            String responseMessage = httpConnection.getResponseMessage();

            System.out.println("Response code : " + responseCode + " Response message :" + responseMessage);
            BufferedReader responseBuffer = new BufferedReader(new InputStreamReader(
                    (httpConnection.getInputStream())));

            String buffLine;
            String output = "";
            System.out.println("Output from Server:  \n");

            while ((buffLine = responseBuffer.readLine()) != null) {
                //System.out.println(buffLine);
                output += buffLine;
            }
            System.out.println("Response from server : \n"+output);
            httpConnection.disconnect();

        } catch (MalformedURLException e) {

            e.printStackTrace();

        } catch (IOException e) {

            e.printStackTrace();

        }

    }

}
                      
                  

Authentication is done via the API key which you can find in your account settings.

Requests are authenticated using HTTP Basic Auth. Provide your API key as the basic auth username. You do not need to provide a password.

Alternatively you can also pass your API key as a bearer token in an Authorization header.

You can see your account’s API keys, and roll them if necessary, in the dashboard.

Responses

Our API returns standard HTTP success or error status codes. For errors, we will also include extra information about what went wrong encoded in the response as JSON. The various HTTP status codes we might return are listed below.

HTTP Status codes

Code Title Description
200 OK The request was successful.
201 Created The resource was successfully created.
202 Async created The resource was asynchronously created
400 Bad request Bad request
401 Unauthorized Your API key is invalid.
402 Over quota Over plan quota on this endpoint.
404 Not found The resource does not exist.
422 Validation error A validation error occurred.
50X Internal Server Error An error occurred with our API.

Error types

All errors are returned in the form of JSON with a type and optional message.

Example error response.

                    
                      
                      {
                      
                      "error"
                      :
                      
                      {
                      
                      "type"
                      :
                      
                      "params_invalid"
                      ,
                      
                      "message"
                      :
                      
                      "Name is required"
                      
                      }
                      
                      }
                      
                    
                  
Type Description
params_invalid Your parameters were not valid.
unknown_record Record was not found.
unknown_route URL was not valid.
queued Lookup queued. Try this request again in a few minutes.
rate_limit The request has been rate limited.
api_error Internal API error.