Contacts

Send Message

To add a contact, send a POST request to the folowing endpoint

                                                
                                                    EndPoint: https://api.braceafrica.com/v1/contacts/add

The json to POST to the endpoint

name String Compulsory
phone String Compulsory - Must be in international format
tags String Optional - A unique field to help group contacts e.g football,team,family
groups String Optional - This is a group name that the contacts will be added to. It must be an existing group
                                                
                                                {
                                                    "name":"John Omosh",
                                                    "phone":"+2547xxxxxxx",
                                                    "tags":"team,client",
                                                    "groups":"SomeGroup,Designer"
                                                }
                                                
                                            

API code samples

                                                            
                                                            import requests
                                                            import json

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

                                                            # data
                                                            name            = "John Migo" # contact name
                                                            phone           = "+254711xxxxxx" # international format
                                                            tags            = "developer,nairobi" # optional comma separated tags
                                                            groups          = "Nairobi Coding, Group 2" # optional groups to add contact

                                                            # endoint
                                                            addContactURL   = "https://api.braceafrica.com/v1/contacts/add"

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

                                                            params = {
                                                                'name' : name,
                                                                'phone' : phone,
                                                                'tags' : tags,
                                                                'groups': groups
                                                            }

                                                            req = requests.post(MessageHost, data=json.dumps(params), headers=headers)
                                                            
                                                            # response
                                                            print(req.text)

                                                            
                                                        
                                                            
                                                            // authentication
                                                            $x_username      = "";
                                                            $x_apikey        = "";

                                                            // data
                                                            $createContact   = array(
                                                                "name"       => "John Migo", # contact name
                                                                "phone"      => "+254711xxxxxx", # international format
                                                                "tags"       => "developer,nairobi", # optional comma separated tags
                                                                "groups"     => "Nairobi Coding, Group 2" # optional groups to add contact
                                                            );

                                                            // endoint
                                                            $addContactURL     = "https://api.braceafrica.com/v1/contacts/add";

                                                            // encoding params
                                                            $params            = json_encode($createContact);
                                                            $req               = curl_init($addContactURL);

                                                            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, $params);
                                                            curl_setopt($req, CURLOPT_HTTPHEADER, array(
                                                                'Content-Type: application/json',
                                                                'Content-Length: '.strlen($params),
                                                                '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 = {
                                                                'name' : 'John Migo', // contact name
                                                                'phone' : '+254711xxxxxx', // international format
                                                                'tags' : 'developer,nairobi', // optional comma separated tags
                                                                'groups': 'Nairobi Coding, Group 2' // optional groups to add contact
                                                            }
                                                            
                                                            // endpoint
                                                            var addContactURL     = "https://api.braceafrica.com/v1/contacts/add";

                                                            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: addContactURL,
                                                                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)
                                                                }
                                                                console.log(body)
                                                            })
                                                            
                                                        
                                                            
                                                            package main

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

                                                            func main() {
                                                                // endpoint
                                                                var addContactURL string = "https://api.braceafrica.com/v1/contacts/add"

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

                                                                // data
                                                                createContact := map[string]string{
                                                                    "name":   "John Migo",
                                                                    "phone":  "+254711xxxxxx",
                                                                    "tags":   "developer,nairobi",
                                                                    "groups": "Nairobi Coding, Group 2",
                                                                }

                                                                params, _ := json.Marshal(createContact)

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

                                                                if err != nil {
                                                                    log.Fatal(err)
                                                                }

                                                                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
                                                                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.

                                                
                                                    {
                                                        "status": 200,
                                                        "message": "Contact added"
                                                    }
                                                
                                            

Edit Contacts

Our edit contacts API lets you edit your contacts by sending a post request to the following endpoint

                                                
                                                    EndPoint: https://api.braceafrica.com/v1/contacts/edit/:contactId

The json to POST to the endpoint

                                                
                                                {
                                                    "name":"Jane Doe", // new name - compulsory
                                                    "phone":"+25476xxxxxxx", // new phone - compulsory
                                                    "tags":"braceafrica, developer", // new tags - optional. This will replace existing tags
                                                    "groups":"Some Group 1, Some Group 2" // new groups - optional. Contact will be linked to the new groups
                                                }
                                                
                                            

API code samples

                                                            
                                                            import requests
                                                            import json

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

                                                            # data
                                                            name            = "John New" # new contact name
                                                            phone           = "+2507xxxxxxxx" # new phonenumber - international format 
                                                            tags            = "Edited Tag 1, Edited Tag" # new tags - comma separated tags
                                                            groups          = "New Group1" # new groups - optional groups to link contact

                                                            # id of contact to edit: this can be gotten from the fetch contacts api
                                                            contactId       = "1";

                                                            # endoint
                                                            editContactURL  = "https://api.braceafrica.com/v1/contacts/edit/"+contactId

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

                                                            params = {
                                                                'name' : name,
                                                                'phone' : phone,
                                                                'tags' : tags,
                                                                'groups': groups
                                                            }

                                                            req = requests.post(editContactURL, data=json.dumps(params), headers=headers)

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

                                                            // data
                                                            $editContactData   = array(
                                                                "name"       => "John New", # new contact name
                                                                "phone"      => "+254711xxxxxx", # new phonenumber - international format  
                                                                "tags"       => "Edited Tag 1, Edited Tag", # new tags - comma separated tags
                                                                "groups"     => "New Group1" # new groups - optional groups to link contact
                                                            );

                                                            // id of contact to edit: this can be gotten from the fetch contacts api
                                                            $contactId          = "1";

                                                            // endoint
                                                            $editContactURL     = "https://api.braceafrica.com/v1/contacts/edit/".$contactId;

                                                            // encoding params
                                                            $params             = json_encode($editContactData);
                                                            $req                = curl_init($editContactURL);

                                                            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, $params);
                                                            curl_setopt($req, CURLOPT_HTTPHEADER, array(
                                                                'Content-Type: application/json',
                                                                'Content-Length: '.strlen($params),
                                                                '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 = {
                                                                'name' : 'John New', // new contact name
                                                                'phone' : '+254711xxxxxx', // new phonenumber - international format 
                                                                'tags' : 'Edited Tag 1, Edited Tag', // new tags - comma separated tags
                                                                'groups': 'New Group1' // optional groups to link contact
                                                            }

                                                            // id of contact to edit: this can be gotten from the fetch contacts api
                                                            var contactId         = "1";

                                                            // endpoint
                                                            var editContactURL    = "https://api.braceafrica.com/v1/contacts/edit/" + contactId;


                                                            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: editContactURL,
                                                                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)
                                                                }
                                                                console.log(body)
                                                            })

                                                            
                                                        
                                                            
                                                            package main

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

                                                            func main() {
                                                                // id of contact to edit: this can be gotten from the fetch contacts api
                                                                var contactId string      = ""

                                                                // endpoint 
                                                                var editContactURL string = "https://api.braceafrica.com/v1/contacts/edit/" + contactId

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

                                                                // data
                                                                newContactDetails := map[string]string{
                                                                    "name": "",  // new contact name
                                                                    "phone": "", // new phonenumber - international format 
                                                                    "tags": "",  // new tags - comma separated tags
                                                                    "groups":""  // new groups - optional groups to link contact
                                                                }

                                                                params, _ := json.Marshal(newContactDetails)

                                                                // request
                                                                request, err := http.NewRequest("POST", editContactURL, 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, 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.

                                                
                                                {
                                                    "status": 200,
                                                    "message": "Contact has been updated"
                                                }
                                                
                                            

Fetch Contacts

This API lets you fetch all the contacts that you added to your system. This lets you integrate our API to your application without the need to store the contacts in your database.

                                            
                                                EndPoint: https://api.braceafrica.com/v1/contacts/fetch

Send a GET request to the endpoint

API code samples

                                                        
                                                        import requests
                                                        import json

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

                                                        # endoint
                                                        fetchContactURL   = "https://api.braceafrica.com/v1/contacts/fetch"

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

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

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

                                                        // endoint
                                                        $fetchContactURL     = "https://api.braceafrica.com/v1/contacts/fetch";

                                                        // encoding params
                                                        $req                 = curl_init($fetchContactURL);

                                                        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 fetchContactURL     = "https://api.braceafrica.com/v1/contacts/fetch";

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

                                                        var options = {
                                                            url: fetchContactURL,
                                                            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)
                                                            }
                                                            console.log(body)
                                                        })
                                                        
                                                    
                                                        
                                                        package main

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

                                                        func main() {
                                                            var fetchContactsURL string = "https://api.braceafrica.com/v1/contacts/fetch"

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

                                                            // request
                                                            request, err := http.NewRequest("GET", fetchContactsURL, 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, _ := ioutil.ReadAll(response.Body)

                                                            fmt.Println(string(body))

                                                        }
                                                        
                                                    

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

                                            
                                                {
                                                    "status": 200,
                                                    "contacts": [
                                                        {
                                                            "id": 2,
                                                            "name": "Jane Mwaura",
                                                            "phoneNumber": "+254712345678",
                                                            "tags": "kenya,nairobi",
                                                            "groups": [],
                                                            "createdOn": "2019-12-02T00:00:00.000Z",
                                                            "lastEditedOn": null
                                                        }
                                                    ]
                                                }
                                            
                                        

Delete Contact

                                                
                                                    EndPoint: https://api.braceafrica.com/v1/contacts/delete

The json to POST to the endpoint.

Please note that this will also remove the contact from all linked groups.

                                                
                                                    {
                                                        "contactIds": [1,2,3,4]
                                                    }
                                                
                                            

API code samples

                                                            
                                                            import requests
                                                            import json

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

                                                            # id of contact to delete
                                                            params = {
                                                                "contactIds":[1,2,3,4]
                                                            }

                                                            # endoint
                                                            deleteContactURL   = "https://api.braceafrica.com/v1/contacts/delete

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

                                                            req = requests.post(deleteContactURL, data=json.dumps(params), headers=headers)

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

                                                            // id of contact to delete
                                                            $params            = array(
                                                                "contactIds"=>array(1,2,3,4),
                                                            );

                                                            $contactsData = json_encode($params);

                                                            // endoint
                                                            $deleteContactURL     = "https://api.braceafrica.com/v1/contacts/delete;

                                                            $req                  = curl_init($deleteContactURL);

                                                            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, $contactsData);
                                                            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            = ""

                                                            // id of contact to delete
                                                            var params = {
                                                                "contactIds":[1,2,3,4]
                                                            }

                                                            // endpoint
                                                            var deleteContactURL    = "https://api.braceafrica.com/v1/contacts/delete;

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

                                                            var options = {
                                                                url: deleteContactURL,
                                                                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)
                                                                }
                                                                console.log(body)
                                                            })
                                                            
                                                        
                                                            
                                                            package main

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

                                                            func main() {
                                                                // endpoint
                                                                var deleteContactURL string = "https://api.braceafrica.com/v1/contacts/delete

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

                                                                data := map[string][]int{
                                                                    "contactIds":[]int{1,2,3,4}
                                                                }

                                                                params := json.Marshal(data)

                                                                // request
                                                                request, err := http.NewRequest("POST", deleteContactURL, 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, err := http.DefaultClient.Do(request)

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

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

                                                                defer response.Body.Close()

                                                                fmt.Println(string(body))
                                                            }