Messages

Send Message

This API lets you send messages to contacts you have not saved. To do this, simply send a POST request to the following endpoint.

                                            
                                                EndPoint: https://api.braceafrica.com/v1/sms/send

The json to the POST to the endpoint

phoneNumbers String Compulsory - Comma separated in international format
message String Compulsory - Must be in international format
senderId String Optional - Customize messages with your company name e.g OneLimited
                                            
                                                {
                                                    "phoneNumbers": "+25472*******,+25473*******,+25474*******",
                                                    "message":      "Hello api!",
                                                    "senderId":     ""
                                                }
                                            
                                        

API sample code

                                                        
                                                            import requests
                                                            import json

                                                            # authentication
                                                            x_username         = "";
                                                            x_apikey           = "";

                                                            params = {
                                                                "phoneNumbers": "+25472*******,+25473*******,+25474*******",
                                                                "message":      "Hello api!",
                                                                "senderId":     "", # leave blank if you do not have a custom sender Id
                                                            }

                                                            # endpoint
                                                            sendMessageURL = "https://api.braceafrica.com/v1/sms/send"

                                                            headers = {
                                                                'Content-type': 'application/json',
                                                                'Accept': 'application/json',
                                                                'x-api-user': x_username,
                                                                'x-api-key' : x_apikey
                                                            }

                                                            # endoint
                                                            req = requests.post(sendMessageURL, data=json.dumps(params), headers=headers)

                                                            # response
                                                            print(req.text)
                                                        
                                                    
                                                        
                                                            // authentication
                                                            $x_username           = "";
                                                            $x_apikey             = "";

                                                            // id of contact to delete
                                                            $params = array(
                                                                "phoneNumbers"=> "+25472*******,+25473*******,+25474*******", 
                                                                "message"=>      "Hello api!",
                                                                "senderId"=>     "", // leave blank if you do not have a custom sender Id
                                                            );

                                                            $data = json_encode($params);

                                                            // endoint
                                                            $sendMessageURL     = "https://api.braceafrica.com/v1/sms/send";

                                                            $req                  = curl_init($sendMessageURL);

                                                            curl_setopt($req, CURLOPT_CUSTOMREQUEST, "POST");
                                                            curl_setopt($req, CURLOPT_TIMEOUT, 60);
                                                            curl_setopt($req, CURLOPT_SSL_VERIFYPEER, false);
                                                            curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
                                                            curl_setopt($req, CURLOPT_POSTFIELDS, $data);
                                                            curl_setopt($req, CURLOPT_HTTPHEADER, array(
                                                                'Content-Type: application/json',
                                                                'x-api-user: '.$x_username,
                                                                'x-api-key: '.$x_apikey
                                                            ));

                                                            // read api response
                                                            $res              = curl_exec($req);

                                                            // close curl
                                                            curl_close($req);

                                                            // print the raw json response
                                                            var_dump($res);
                                                        
                                                    
                                                        
                                                            var request = require('request');

                                                            // authentication
                                                            var x_username       = ""
                                                            var x_apikey         = ""

                                                            // data
                                                            var params = {
                                                                "phoneNumbers"=> "+25472*******,+25473*******,+25474*******",
                                                                "message":      "Hello api!",
                                                                "senderId":     "", // leave blank if you do not have a custom sender Id
                                                            }

                                                            // endpoint
                                                            var sendMessageURL = "https://api.braceafrica.com/v1/sms/send"

                                                            var headers = {
                                                                'Content-Type' :  'application/json',
                                                                'Content-Length' : params.length,
                                                                'Accept' : 'application/json',
                                                                'x-api-user' : x_username,
                                                                'x-api-key' : x_apikey
                                                            }

                                                            var options = {
                                                                url: sendMessageURL,
                                                                method: 'POST',
                                                                headers: headers,
                                                                form: params
                                                            }

                                                            // the request and response
                                                            request(options, function (error, response, body) {
                                                                if (!error && response.statusCode == 200) {
                                                                    // Print out the response body
                                                                    console.log(body)
                                                                }
                                                                else{
                                                                    console.log(error)
                                                                }
                                                            })
                                                        
                                                    
                                                        
                                                            package main

                                                            import (
                                                                "bytes"
                                                                "encoding/json"
                                                                "fmt"
                                                                "io/ioutil"
                                                                "net/http"
                                                                "strconv"
                                                            )

                                                            func main() {
                                                                // endpoint
                                                                var sendMessageURL string = "https://api.braceafrica.com/v1/sms/send"

                                                                // authentication

                                                                var x_username string = ""
                                                                var x_apikey string = ""

                                                                // data

                                                                messageData := map[string]string{
                                                                    "phoneNumbers": "+25472*******,+25473*******,+25474*******",
                                                                    "message":      "Hello api!",
                                                                    "senderId":     "", // leave blank if you do not have a custom sender Id
                                                                }

                                                                params, _ := json.Marshal(messageData)

                                                                request, err := http.NewRequest("POST", sendMessageURL, bytes.NewBuffer(params))

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                request.Header.Add("Content-Type", "application/json")
                                                                request.Header.Set("x-api-user", x_username)
                                                                request.Header.Set("x-api-key", x_apikey)
                                                                request.Header.Set("Content-Length", strconv.Itoa(len(params)))

                                                                response, err := http.DefaultClient.Do(request)

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                body, err := ioutil.ReadAll(response.Body)

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                defer response.Body.Close()

                                                                fmt.Println(string(body))
                                                            }

                                                        
                                                    

When the request is successful, you should expect the following response.

                                            
                                                {
                                                    "0": {
                                                        "country": "kenya",
                                                        "cost": "KES 0.80",
                                                        "success": [
                                                            "+2547********"
                                                        ]
                                                    },
                                                    "status": 200,
                                                    "message": "Message sent"
                                                }
                                            
                                        

Send Group Message

This API lets you as the developer send messages all contacts in a particular group. To do this, simply send a POST request to the following endpoint.

                                            
                                                EndPoint: https://api.braceafrica.com/v1/sms/send/group/:groupId

Send a POST request to the endpoint

                                            
                                                {
                                                    "message":      "Hello group!",
                                                    "senderId":     "", // leave blank if you do not have a custom sender Id
                                                }
                                            
                                        

API sample code

                                                        
                                                            import requests
                                                            import json

                                                            # authentication
                                                            x_username         = "";
                                                            x_apikey           = "";

                                                            params = {
                                                                "message":      "Hello group!",
                                                                "senderId":     "", # leave blank if you do not have a custom sender Id
                                                            }

                                                            groupId = ""

                                                            # endpoint
                                                            sendMessageURL = "https://api.braceafrica.com/v1/sms/send/group/" + groupId

                                                            headers = {
                                                                'Content-type': 'application/json',
                                                                'Accept': 'application/json',
                                                                'x-api-user': x_username,
                                                                'x-api-key' : x_apikey
                                                            }

                                                            # endoint
                                                            req = requests.post(sendMessageURL, data=json.dumps(params), headers=headers)

                                                            # response
                                                            print(req.text)
                                                        
                                                    
                                                        
                                                            // authentication
                                                            $x_username           = "";
                                                            $x_apikey             = "";

                                                            // id of contact to delete
                                                            $params = array(
                                                                "message"=>      "Hello group!",
                                                                "senderId"=>     "", // leave blank if you do not have a custom sender Id
                                                            );

                                                            $groupId = "";

                                                            $data = json_encode($params);

                                                            // endoint
                                                            $sendMessageURL     = "https://api.braceafrica.com/v1/sms/send/group/".$groupId;

                                                            $req                  = curl_init($sendMessageURL);

                                                            curl_setopt($req, CURLOPT_CUSTOMREQUEST, "POST");
                                                            curl_setopt($req, CURLOPT_TIMEOUT, 60);
                                                            curl_setopt($req, CURLOPT_SSL_VERIFYPEER, false);
                                                            curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
                                                            curl_setopt($req, CURLOPT_POSTFIELDS, $data);
                                                            curl_setopt($req, CURLOPT_HTTPHEADER, array(
                                                                'Content-Type: application/json',
                                                                'x-api-user: '.$x_username,
                                                                'x-api-key: '.$x_apikey
                                                            ));

                                                            // read api response
                                                            $res              = curl_exec($req);

                                                            // close curl
                                                            curl_close($req);

                                                            // print the raw json response
                                                            var_dump($res);
                                                        
                                                    
                                                        
                                                            var request = require('request');

                                                            // authentication
                                                            var x_username       = ""
                                                            var x_apikey         = ""

                                                            // data
                                                            var params = {
                                                                "message":      "Hello group!",
                                                                "senderId":     "", // leave blank if you do not have a custom sender Id
                                                            }

                                                            var groupId = ""

                                                            // endpoint
                                                            var sendMessageURL = "https://api.braceafrica.com/v1/sms/send/group/"+ groupId

                                                            var headers = {
                                                                'Content-Type' :  'application/json',
                                                                'Content-Length' : params.length,
                                                                'Accept' : 'application/json',
                                                                'x-api-user' : x_username,
                                                                'x-api-key' : x_apikey
                                                            }

                                                            var options = {
                                                                url: sendMessageURL,
                                                                method: 'POST',
                                                                headers: headers,
                                                                form: params
                                                            }

                                                            // the request and response
                                                            request(options, function (error, response, body) {
                                                                if (!error && response.statusCode == 200) {
                                                                    // Print out the response body
                                                                    console.log(body)
                                                                }
                                                                else{
                                                                    console.log(error)
                                                                }
                                                            })

                                                        
                                                    
                                                        
                                                            package main

                                                            import (
                                                                "bytes"
                                                                "encoding/json"
                                                                "fmt"
                                                                "io/ioutil"
                                                                "net/http"
                                                            )

                                                            func main() {
                                                                var groupId string = ""
                                                                // endpoint
                                                                var sendMessageURL string = "https://api.braceafrica.com/v1/sms/send/group/" + groupId

                                                                // authentication
                                                                var x_username string = ""
                                                                var x_apikey string = ""

                                                                // data
                                                                createMessage := map[string]string{
                                                                    "message":  "Hello group!",
                                                                    "senderId": "", // leave blank if you do not have a custom sender Id
                                                                }

                                                                params, err := json.Marshal(createMessage)

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                // request
                                                                request, err := http.NewRequest("POST", sendMessageURL, bytes.NewBuffer(params))

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                // headers
                                                                request.Header.Set("Content-Type", "application/json")
                                                                request.Header.Set("x-api-user", x_username)
                                                                request.Header.Set("x-api-key", x_apikey)

                                                                // response
                                                                response, err := http.DefaultClient.Do(request)

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                body, err := ioutil.ReadAll(response.Body)

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                fmt.Println(string(body))
                                                            }

                                                        
                                                    

When the request is successful, you should expect the following response.

                                            
                                                {
                                                    "0": {
                                                        "country": "kenya",
                                                        "cost": "KES 0.80",
                                                        "success": [
                                                            "+25477xxxxxx"
                                                        ]
                                                    },
                                                    "status": 200,
                                                    "message": "Message sent"
                                                }
                                            
                                        

Message Broadcast

This API lets you send messages to all your contacts. To do this, send a POST request to the following endpoint.

                                            
                                                EndPoint: https://api.braceafrica.com/v1/sms/send/all

Send a POST to the endpoint with the data below

                                            
                                                {
                                                    "message":  "Hello broadcast!",
                                                    "senderId": "", // Leave blank if you do not have a custom sender Id
                                                }
                                            
                                        

API sample code

                                                        
                                                            import requests
                                                            import json

                                                            # authentication
                                                            x_username         = "";
                                                            x_apikey           = "";

                                                            params = {
                                                                "message":      "Hello broadcast!",
                                                                "senderId":     "", # leave blank if you do not have a custom sender Id
                                                            }

                                                            # endpoint
                                                            sendMessageURL = "https://api.braceafrica.com/v1/sms/send/all"

                                                            headers = {
                                                                'Content-type': 'application/json',
                                                                'Accept': 'application/json',
                                                                'x-api-user': x_username,
                                                                'x-api-key' : x_apikey
                                                            }

                                                            # endoint
                                                            req = requests.post(sendMessageURL, data=json.dumps(params), headers=headers)

                                                            # response
                                                            print(req.text)
                                                        
                                                    
                                                        
                                                            // authentication
                                                            $x_username           = "";
                                                            $x_apikey             = "";

                                                            // id of contact to delete
                                                            $params = array(
                                                                "message"=>      "Hello broadcast!",
                                                                "senderId"=>     "", // leave blank if you do not have a custom sender Id
                                                            );

                                                            $data = json_encode($params);

                                                            // endoint
                                                            $sendMessageURL     = "https://api.braceafrica.com/v1/sms/send/all";

                                                            $req                  = curl_init($sendMessageURL);

                                                            curl_setopt($req, CURLOPT_CUSTOMREQUEST, "POST");
                                                            curl_setopt($req, CURLOPT_TIMEOUT, 60);
                                                            curl_setopt($req, CURLOPT_SSL_VERIFYPEER, false);
                                                            curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
                                                            curl_setopt($req, CURLOPT_POSTFIELDS, $data);
                                                            curl_setopt($req, CURLOPT_HTTPHEADER, array(
                                                                'Content-Type: application/json',
                                                                'x-api-user: '.$x_username,
                                                                'x-api-key: '.$x_apikey
                                                            ));

                                                            // read api response
                                                            $res              = curl_exec($req);

                                                            // close curl
                                                            curl_close($req);

                                                            // print the raw json response
                                                            var_dump($res);
                                                        
                                                    
                                                        
                                                            var request = require('request');

                                                            // authentication
                                                            var x_username       = ""
                                                            var x_apikey         = ""

                                                            // data
                                                            var params = {
                                                                "message":      "Hello broadcast!",
                                                                "senderId":     "", // leave blank if you do not have a custom sender Id
                                                            }

                                                            // endpoint
                                                            var sendMessageURL = "https://api.braceafrica.com/v1/sms/send/all"

                                                            var headers = {
                                                                'Content-Type' :  'application/json',
                                                                'Content-Length' : params.length,
                                                                'Accept' : 'application/json',
                                                                'x-api-user' : x_username,
                                                                'x-api-key' : x_apikey
                                                            }

                                                            var options = {
                                                                url: sendMessageURL,
                                                                method: 'POST',
                                                                headers: headers,
                                                                form: params
                                                            }

                                                            // the request and response
                                                            request(options, function (error, response, body) {
                                                                if (!error && response.statusCode == 200) {
                                                                    // Print out the response body
                                                                    console.log(body)
                                                                }
                                                                else{
                                                                    console.log(error)
                                                                }
                                                            })
                                                        
                                                    
                                                        
                                                            package main

                                                            import (
                                                                "bytes"
                                                                "encoding/json"
                                                                "fmt"
                                                                "io/ioutil"
                                                                "net/http"
                                                            )

                                                            func main() {
                                                                // endpoint
                                                                var sendMessageURL string = "https://api.braceafrica.com/v1/sms/send/all"

                                                                // authentication
                                                                var x_username string = ""
                                                                var x_apikey string = ""

                                                                // data
                                                                createMessage := map[string]string{
                                                                    "message":  "Hello broadcast!",
                                                                    "senderId": "", // leave blank if you do not have a custom sender Id
                                                                }

                                                                params, err := json.Marshal(createMessage)

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                // request
                                                                request, err := http.NewRequest("POST", sendMessageURL, bytes.NewBuffer(params))

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                // headers
                                                                request.Header.Set("Content-Type", "application/json")
                                                                request.Header.Set("x-api-user", x_username)
                                                                request.Header.Set("x-api-key", x_apikey)

                                                                // response
                                                                response, err := http.DefaultClient.Do(request)

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                body, err := ioutil.ReadAll(response.Body)

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                fmt.Println(string(body))
                                                            }

                                                        
                                                    

When the request is successful, you should expect the following response.

                                            
                                                {
                                                    "0": {
                                                        "country": "kenya",
                                                        "cost": "KES 1.60",
                                                        "success": [
                                                            "+2547********",
                                                            "+2547********"
                                                        ]
                                                    },
                                                    "status": 200,
                                                    "message": "Message sent"
                                                }
                                            
                                        

Fetch Group Messages

This API allows you to fetch all the messages sent to a particular group. To fetch the messages, send a GET request to the following endpoint.

                                            
                                                EndPoint: https://api.braceafrica.com/v1/sms/fetch/group/:groupId?count=100
Note: Count is the number of messages that you want to return. The default is 20

API sample code

                                                        
                                                            import requests
                                                            import json

                                                            # authentication
                                                            x_username        = "";
                                                            x_apikey          = "";

                                                            groupId = ""

                                                            # endoint
                                                            fetchMessagesURL   = "https://api.braceafrica.com/v1/sms/fetch/group/" + groupId + "?count=20"

                                                            headers = {
                                                                'Content-type': 'application/json',
                                                                'Accept': 'application/json',
                                                                'x-api-user': x_username,
                                                                'x-api-key' : x_apikey
                                                            }

                                                            req = requests.get(fetchMessagesURL, headers=headers)

                                                            # response
                                                            print(req.text)
                                                        
                                                    
                                                        
                                                            // authentication
                                                            $x_username           = "";
                                                            $x_apikey             = "";

                                                            $groupId = "";

                                                            // endoint
                                                            $fetchMessagesURL       = "https://api.braceafrica.com/v1/sms/fetch/group/".$groupId."?count=20";

                                                            $req                  = curl_init($fetchMessagesURL);

                                                            curl_setopt($req, CURLOPT_CUSTOMREQUEST, "GET");
                                                            curl_setopt($req, CURLOPT_TIMEOUT, 60);
                                                            curl_setopt($req, CURLOPT_SSL_VERIFYPEER, false);
                                                            curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
                                                            curl_setopt($req, CURLOPT_HTTPHEADER, array(
                                                                'Content-Type: application/json',
                                                                'x-api-user: '.$x_username,
                                                                'x-api-key: '.$x_apikey
                                                            ));

                                                            // read api response
                                                            $res              = curl_exec($req);

                                                            // close curl
                                                            curl_close($req);

                                                            // print the raw json response
                                                            var_dump($res);
                                                        
                                                    
                                                        
                                                            var request             = require('request');

                                                            // authentication
                                                            var x_username          = ""
                                                            var x_apikey            = ""

                                                            var groupId = ""

                                                            // endpoint
                                                            var fetchMessagesURL     = "https://api.braceafrica.com/v1/sms/fetch/group/" + groupId + "?count=20"

                                                            var headers = {
                                                                'Content-Type' :  'application/json',
                                                                'Accept' : 'application/json',
                                                                'x-api-user' : x_username,
                                                                'x-api-key' : x_apikey
                                                            }

                                                            var options = {
                                                                url: fetchMessagesURL,
                                                                method: 'GET',
                                                                headers: headers
                                                            }

                                                            // the request and response
                                                            request(options, function (error, response, body) {
                                                                if (!error && response.statusCode == 200) {
                                                                    // Print out the response body
                                                                    console.log(body)
                                                                }
                                                                else{
                                                                    console.log(error)
                                                                }
                                                            })
                                                        
                                                    
                                                        
                                                            package main

                                                            import (
                                                                "fmt"
                                                                "io/ioutil"
                                                                "net/http"
                                                            )

                                                            func main() {
                                                                var groupId string = ""
                                                                // endpoint
                                                                var fetchMessagesURL string = "https://api.braceafrica.com/v1/ama/fetch/group/" + groupId + "?count=20"

                                                                // authentication
                                                                var x_username string = ""
                                                                var x_apikey string = ""

                                                                // request

                                                                request, err := http.NewRequest("GET", fetchMessagesURL, nil)

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                // headers
                                                                request.Header.Set("Content-Type", "application/json")
                                                                request.Header.Set("x-api-user", x_username)
                                                                request.Header.Set("x-api-key", x_apikey)

                                                                // response
                                                                response, err := http.DefaultClient.Do(request)

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                body, err := ioutil.ReadAll(response.Body)

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                fmt.Println(string(body))
                                                            }

                                                        
                                                    

When the request is successful, you should expect the following response.

                                            
                                                {
                                                    "status": 200,
                                                    "data": [
                                                        {
                                                            "id": 2727,
                                                            "message": "Hello group! ",
                                                            "sentTo": "Group Jenga",
                                                            "cost": "KES 68.8",
                                                            "status": {
                                                                "Success": 86,
                                                                "Failed": 3
                                                            },
                                                            "dateSent": "2019-05-18T10:53:25.000Z",
                                                            "link": 13892,
                                                            "refId": "AMSND1558176804825"
                                                        }
                                                    ]
                                                }
                                            
                                        

Fetch All Messages

To fetch all your messages, send a GET request to the following endpoint.

                                            
                                                EndPoint: https://api.braceafrica.com/v1/sms/fetch?count=100

Send a GET request to the endpoint.

Note: Count is the number of messages that you want to return. The default is 20

API sample code

                                                        
                                                            import requests
                                                            import json

                                                            # authentication
                                                            x_username        = "";
                                                            x_apikey          = "";

                                                            # endoint
                                                            fetchMessagesURL   = "https://api.braceafrica.com/v1/sms/fetch?count=20"

                                                            headers = {
                                                                'Content-type': 'application/json',
                                                                'Accept': 'application/json',
                                                                'x-api-user': x_username,
                                                                'x-api-key' : x_apikey
                                                            }

                                                            req = requests.get(fetchMessagesURL, headers=headers)

                                                            # response
                                                            print(req.text)
                                                        
                                                    
                                                        
                                                            // authentication
                                                            $x_username           = "";
                                                            $x_apikey             = "";

                                                            // endoint
                                                            $fetchMessagesURL     = "https://api.braceafrica.com/v1/sms/fetch?count=20";

                                                            $req                  = curl_init($fetchMessagesURL);

                                                            curl_setopt($req, CURLOPT_CUSTOMREQUEST, "GET");
                                                            curl_setopt($req, CURLOPT_TIMEOUT, 60);
                                                            curl_setopt($req, CURLOPT_SSL_VERIFYPEER, false);
                                                            curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
                                                            curl_setopt($req, CURLOPT_HTTPHEADER, array(
                                                                'Content-Type: application/json',
                                                                'x-api-user: '.$x_username,
                                                                'x-api-key: '.$x_apikey
                                                            ));

                                                            // read api response
                                                            $res              = curl_exec($req);

                                                            // close curl
                                                            curl_close($req);

                                                            // print the raw json response
                                                            var_dump($res);
                                                        
                                                    
                                                        
                                                            var request             = require('request');

                                                            // authentication
                                                            var x_username          = ""
                                                            var x_apikey            = ""

                                                            // endpoint
                                                            var fetchMessagesURL = "https://api.braceafrica.com/v1/sms/fetch?count=20"

                                                            var headers = {
                                                                'Content-Type' :  'application/json',
                                                                'Accept' : 'application/json',
                                                                'x-api-user' : x_username,
                                                                'x-api-key' : x_apikey
                                                            }

                                                            var options = {
                                                                url: fetchMessagesURL,
                                                                method: 'GET',
                                                                headers: headers
                                                            }

                                                            // the request and response
                                                            request(options, function (error, response, body) {
                                                                if (!error && response.statusCode == 200) {
                                                                    // Print out the response body
                                                                    console.log(body)
                                                                }
                                                                else{
                                                                    console.log(error)
                                                                }
                                                            })
                                                        
                                                    
                                                        
                                                            package main

                                                            import (
                                                                "bytes"
                                                                "fmt"
                                                                "io/ioutil"
                                                                "net/http"
                                                            )

                                                            func main() {
                                                                // endpoint
                                                                var fetchMessagesURL string = "https://api.braceafrica.com/v1/sms/fetch?count=20"

                                                                // authentication
                                                                var x_username string = ""
                                                                var x_apikey string = ""

                                                                // request

                                                                request, err := http.NewRequest("GET", fetchMessagesURL, nil)

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                // headers
                                                                request.Header.Set("Content-Type", "application/json")
                                                                request.Header.Set("x-api-user", x_username)
                                                                request.Header.Set("x-api-key", x_apikey)

                                                                // response
                                                                response, err := http.DefaultClient.Do(request)

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                body, err := ioutil.ReadAll(response.Body)

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                fmt.Println(bytes.NewBuffer(body))
                                                            }

                                                        
                                                    

When the request is successful, you should expect the following response.

                                            
                                                {
                                                    "status": 200,
                                                    "data": [
                                                        {
                                                            "id": 17697687,
                                                            "message": "Lorem ipsum...",
                                                            "sentTo": "John Doe +2547********",
                                                            "cost": "KES 16.0",
                                                            "status": {
                                                                "Success": 20,
                                                                "Failed": 0
                                                            },
                                                            "senderId": "BraceAfrica",
                                                            "dateSent": "2019-04-15T16:09:13.000Z",
                                                            "link": 0,
                                                            "refId": "AMSND1555344553483"
                                                        }
                                                    ]
                                                }
                                            
                                        

Fetch Messages By Status

You can filter-fetch messages using the final delivery status.
The message status can either be "Success" or "Failed". Simply send a GET request to the following endpoint.

                                            
                                                EndPoint: https://api.braceafrica.com/v1/sms/fetch/status/:messageStatus?count=20

Send a GET request to the endpoint

Note: Count is the number of messages that you want to return. The default is 20

API sample code

                                                        
                                                            import requests
                                                            import json

                                                            # authentication
                                                            x_username        = "";
                                                            x_apikey          = "";

                                                            messageStatus = "" # Success or Failed

                                                            # endoint
                                                            fetchMessagesURL   = "https://api.braceafrica.com/v1/sms/fetch/status/" + messageStatus + "?count=20"

                                                            headers = {
                                                                'Content-type': 'application/json',
                                                                'Accept': 'application/json',
                                                                'x-api-user': x_username,
                                                                'x-api-key' : x_apikey
                                                            }

                                                            req = requests.get(fetchMessagesURL, headers=headers)

                                                            # response
                                                            print(req.text)
                                                        
                                                    
                                                        
                                                            // authentication
                                                            $x_username           = "";
                                                            $x_apikey             = "";

                                                            $messageStatus = ""; // Success or Failed

                                                            // endoint
                                                            $fetchMessagesURL     = "https://api.braceafrica.com/v1/sms/fetch/status/".$messageStatus."?count=20";

                                                            $req                  = curl_init($fetchMessagesURL);

                                                            curl_setopt($req, CURLOPT_CUSTOMREQUEST, "GET");
                                                            curl_setopt($req, CURLOPT_TIMEOUT, 60);
                                                            curl_setopt($req, CURLOPT_SSL_VERIFYPEER, false);
                                                            curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
                                                            curl_setopt($req, CURLOPT_HTTPHEADER, array(
                                                                'Content-Type: application/json',
                                                                'x-api-user: '.$x_username,
                                                                'x-api-key: '.$x_apikey
                                                            ));

                                                            // read api response
                                                            $res              = curl_exec($req);

                                                            // close curl
                                                            curl_close($req);

                                                            // print the raw json response
                                                            var_dump($res);
                                                        
                                                    
                                                        
                                                            var request             = require('request');

                                                            // authentication
                                                            var x_username          = ""
                                                            var x_apikey            = ""

                                                            var messageStatus = "" // Success or Failed

                                                            // endpoint
                                                            var fetchMessagesURL     = "https://api.braceafrica.com/v1/sms/fetch/status/" + messageStatus +"?count=20"

                                                            var headers = {
                                                                'Content-Type' :  'application/json',
                                                                'Accept' : 'application/json',
                                                                'x-api-user' : x_username,
                                                                'x-api-key' : x_apikey
                                                            }

                                                            var options = {
                                                                url: fetchMessagesURL,
                                                                method: 'GET',
                                                                headers: headers
                                                            }

                                                            // the request and response
                                                            request(options, function (error, response, body) {
                                                                if (!error && response.statusCode == 200) {
                                                                    // Print out the response body
                                                                    console.log(body)
                                                                }
                                                                else{
                                                                    console.log(error)
                                                                }
                                                            })
                                                        
                                                    
                                                        
                                                            package main

                                                            import (
                                                                "fmt"
                                                                "io/ioutil"
                                                                "net/http"
                                                            )

                                                            func main() {

                                                                var messageStatus = "" //Success or Failed

                                                                var fetchMessagesURL = "https://api.braceafrica.com/v1/sms/fetch/status/" + messageStatus + "?count=20"

                                                                // authentication

                                                                var x_username string = ""
                                                                var x_apikey string = ""

                                                                // request

                                                                request, err := http.NewRequest("GET", fetchMessagesURL, nil)

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                // headers

                                                                request.Header.Set("Content-Type", "application/json")
                                                                request.Header.Set("x-api-user", x_username)
                                                                request.Header.Set("x-api-key", x_apikey)

                                                                response, err := http.DefaultClient.Do(request)

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                body, _ := ioutil.ReadAll(response.Body)

                                                                fmt.Println(string(body))

                                                            }

                                                        
                                                    

When the request is successful, you should expect the following response.

                                            
                                                {
                                                    "0": {
                                                        "id": 176976,
                                                        "message": "Lorem ipsum",
                                                        "sentTo": "Jane Doe +2547********",
                                                        "cost": "KES 0.80",
                                                        "status": "Success",
                                                        "dateSent": "2019-04-15T16:09:13.000Z",
                                                        "link": 0
                                                    },
                                                    "status": 200
                                                }
                                            
                                        

Messages Analytics

The analytics API gives you a quick preview of the number of successful or failed messages between 2 dates.
Simply send a GET request to the following endpoint.

                                            
                                                EndPoint: https://api.braceafrica.com/v1/sms/analytics?startDate=YYYY-MM-DD&endDate=YYYY-MM-DD

API sample code

                                                        
                                                            import requests
                                                            import json

                                                            # authentication
                                                            x_username        = "";
                                                            x_apikey          = "";

                                                            startDate = "YYYY-MM-DD"
                                                            endDate = "YYYY-MM-DD"

                                                            # endoint
                                                            analyticsURL   = "https://api.braceafrica.com/v1/sms/analytics?startDate="+startDate+"&"+"endDate="+endDate";

                                                            headers = {
                                                                'Content-type': 'application/json',
                                                                'Accept': 'application/json',
                                                                'x-api-user': x_username,
                                                                'x-api-key' : x_apikey
                                                            }

                                                            req = requests.get(analyticsURL, headers=headers)

                                                            # response
                                                            print(req.text)
                                                        
                                                    
                                                        
                                                            // authentication
                                                            $x_username           = "";
                                                            $x_apikey             = "";

                                                            $startDate = "YYYY-MM-DD"
                                                            $endDate = "YYYY-MM-DD"

                                                            // endoint
                                                            $analyticsURL     = "https://api.braceafrica.com/v1/sms/analytics?startDate=".$startDate."&"."endDate=".$endDate";

                                                            $req                  = curl_init($analyticsURL);

                                                            curl_setopt($req, CURLOPT_CUSTOMREQUEST, "GET");
                                                            curl_setopt($req, CURLOPT_TIMEOUT, 60);
                                                            curl_setopt($req, CURLOPT_SSL_VERIFYPEER, false);
                                                            curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
                                                            curl_setopt($req, CURLOPT_HTTPHEADER, array(
                                                                'Content-Type: application/json',
                                                                'x-api-user: '.$x_username,
                                                                'x-api-key: '.$x_apikey
                                                            ));

                                                            // read api response
                                                            $res              = curl_exec($req);

                                                            // close curl
                                                            curl_close($req);

                                                            // print the raw json response
                                                            var_dump($res);
                                                        
                                                    
                                                        
                                                            var request             = require('request');

                                                            // authentication
                                                            var x_username          = ""
                                                            var x_apikey            = ""

                                                            startDate = "YYYY-MM-DD"
                                                            endDate = "YYYY-MM-DD"

                                                            // endpoint
                                                            var analyticsURL     = "https://api.braceafrica.com/v1/sms/analytics?startDate="+startDate+"&"+"endDate="+endDate";

                                                            var headers = {
                                                                'Content-Type' :  'application/json',
                                                                'Accept' : 'application/json',
                                                                'x-api-user' : x_username,
                                                                'x-api-key' : x_apikey
                                                            }

                                                            var options = {
                                                                url: analyticsURL,
                                                                method: 'GET',
                                                                headers: headers
                                                            }

                                                            // the request and response
                                                            request(options, function (error, response, body) {
                                                                if (!error && response.statusCode == 200) {
                                                                    // Print out the response body
                                                                    console.log(body)
                                                                }
                                                                else{
                                                                    console.log(error)
                                                                }
                                                            })
                                                        
                                                    
                                                        
                                                            package main

                                                            import (
                                                                "fmt"
                                                                "io/ioutil"
                                                                "net/http"
                                                            )

                                                            func main() {

                                                                startDate := "YYYY-MM-DD"
                                                                endDate := "YYYY-MM-DD"

                                                                var analyticsURL     = "https://api.braceafrica.com/v1/sms/analytics?startDate="+startDate+"&"+"endDate="+endDate";

                                                                // authentication

                                                                var x_username string = ""
                                                                var x_apikey string = ""

                                                                // request

                                                                request, err := http.NewRequest("GET", analyticsURL, nil)

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                // headers

                                                                request.Header.Set("Content-Type", "application/json")
                                                                request.Header.Set("x-api-user", x_username)
                                                                request.Header.Set("x-api-key", x_apikey)

                                                                response, err := http.DefaultClient.Do(request)

                                                                if err != nil {
                                                                    panic(err.Error())
                                                                }

                                                                body, _ := ioutil.ReadAll(response.Body)

                                                                fmt.Println(string(body))

                                                            }

                                                        
                                                    

When the request is successful, you should expect the following response.

                                            
                                                {
                                                    "status": 200,
                                                    "data": {
                                                        "dates": [
                                                            "2019-04-10",
                                                            "2019-04-11",
                                                            "2019-04-12",
                                                            "2019-04-13",
                                                            "2019-04-14",
                                                            "2019-04-15"
                                                        ],
                                                        "messages": {
                                                            "success": [132,46,89,12,82,9],
                                                            "failed": [2,0,0,0,2,0]
                                                        }
                                                    }
                                                }