<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Africa's Talking]]></title><description><![CDATA[We provide easy-to-use APIs that allow software developers worldwide to easily integrate SMS, USSD, Voice, Airtime and Mobile Data into their apps.]]></description><link>https://africastalking.hashnode.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1692190304510/Hwg9j-ib1.png</url><title>Africa&apos;s Talking</title><link>https://africastalking.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Tue, 08 Sep 2026 08:04:34 GMT</lastBuildDate><atom:link href="https://africastalking.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How To: Send Data and Receive Reports using Africa’s Talking APIs]]></title><description><![CDATA[Africa’s Talking APIs help you facilitate communication in the form of messaging, USSDs, airtime and voice. The SMS and Airtime products enable setting callback URLs to monitor transactions. Transactions are sent via requests using Postman via the lo...]]></description><link>https://africastalking.hashnode.dev/how-to-send-data-and-receive-reports-using-africas-talking-apis</link><guid isPermaLink="true">https://africastalking.hashnode.dev/how-to-send-data-and-receive-reports-using-africas-talking-apis</guid><category><![CDATA[APIs]]></category><category><![CDATA[SMS API]]></category><category><![CDATA[Airtime API]]></category><dc:creator><![CDATA[Sylvia Kipkemoi]]></dc:creator><pubDate>Thu, 07 Sep 2023 09:37:07 GMT</pubDate><content:encoded><![CDATA[<p>Africa’s Talking APIs help you facilitate communication in the form of messaging, USSDs, airtime and voice. The <a target="_blank" href="https://africastalking.com/sms">SMS</a> and <a target="_blank" href="https://africastalking.com/airtime">Airtime</a> products enable setting callback URLs to monitor transactions. Transactions are sent via requests using <a target="_blank" href="https://www.postman.com/africastalking"><em>Postman</em></a> via the <a target="_blank" href="http://localhost"><em>localhost</em></a> or Africa’s Talking API <em>endpoints</em>.</p>
<p>The <em>messaging</em> products have the following features:</p>
<ol>
<li><a target="_blank" href="https://africastalking.com/sms/bulksms"><strong>Bulk SMS</strong></a></li>
</ol>
<p>These are the messages sent as a whole to multiple recipients at once. It is the same message received by all recipients.</p>
<p><strong>2.</strong> <a target="_blank" href="https://africastalking.com/sms/twowaysms"><strong>Two-way SMS</strong></a></p>
<p>This is a message sent from the developer/business to the recipients where the recipients are required or able to send a message back to the sender, such as in collecting feedback.</p>
<p><strong>3.</strong> <a target="_blank" href="https://africastalking.com/sms/premiumsms"><strong>Premium SMS</strong></a></p>
<p>These are messages sent to recipients on demand or on subscription to generate income to the sender.</p>
<p>The <em>airtime</em> product has no variety of features, and simply involves sending an amount of airtime to various recipients.</p>
<p>In order for these transactions to take place, the developer needs to use an application URL to send the data, and monitor transactions made. That is where <strong>Postman</strong> and <strong>Ngrok</strong> come in.</p>
<h1 id="heading-postman"><strong>Postman</strong></h1>
<p><a target="_blank" href="https://www.postman.com/">Postman</a> is an application that is used to process requests from a user on a particular application. The requests can be in the form of:</p>
<ol>
<li><p>POST</p>
</li>
<li><p>GET</p>
</li>
<li><p>PUT</p>
</li>
<li><p>DELETE</p>
</li>
</ol>
<p>… among others.</p>
<p>For the purpose of this article, we will focus on the POST request.</p>
<ol>
<li><h2 id="heading-sms"><strong>SMS</strong></h2>
</li>
</ol>
<p>When sending a message, the developer/business POSTs a request with the required data in order to receive a notification. The required fields in POSTing a request for messaging are:</p>
<ul>
<li><p><strong>Username</strong>: Your application username as defined on your dashboard</p>
</li>
<li><p><strong>To</strong>: The number of the message recipient (May be more than one for bulk messaging, The country code should be included in the number, Separate multiple numbers using a comma(,) )</p>
</li>
<li><p><strong>Message</strong>: The body of message to be shared to the recipients</p>
</li>
</ul>
<p>On Postman, you can post a request to send a message for an application/file hosted locally via <a target="_blank" href="http://localhost"><em>localhost</em></a> or an application that is live via Africa’s Talking <em>endpoint</em> <em>URL</em> (Live or Sandbox).</p>
<h3 id="heading-i-localhosthttplocalhost"><strong>i.</strong> <a target="_blank" href="http://Localhost"><strong>Localhost</strong></a></h3>
<p>To POST a request via <a target="_blank" href="http://localhost">localhost</a>, the code for the application is run and hosted on your local machine or environment. The URL used is the loopback address (127.0.0.1) together with the port number specified in your code (e.g. 3005, 8080). The combination yields a URL of the form:</p>
<pre><code class="lang-plaintext">http://127.0.0.1:PORTNUMBER/
</code></pre>
<p>...depending on your port number. For example: The port number used in the image illustration below is <em>3003</em>, hence the URL is</p>
<pre><code class="lang-plaintext">http://127.0.0.1:3003/
</code></pre>
<p>This is as shown in the image below:</p>
<p><img src="https://lh4.googleusercontent.com/G8jsKMYX9lnulU1obIsxqoCv7ZQmDAhNoEZ7QUGrBpUt9ijd0tHEZ1usLwawpPB-CqAOPnRUzTsV7eiv8bAPjTx_S6-XWhAuPYYcFGAkmvaYFI_8JOr8JeScY6l4bZ6fWZQV2OpVCBb2zDOydoVWuIU" alt /></p>
<p>Since the code is on your local machine, the key identifiers such as API Key, username and sending details (To, Message) are already defined there. Hence, clicking on the SEND button immediately sends the message to the recipient(s). A response is output on the console as illustrated in the image below:</p>
<p><img src="https://lh6.googleusercontent.com/wdovEIUR2KNBCgb-lZIPrnuVnrYSTGgIyKgjOfh6_daMAZLEccIw_JxH_RIOcvll_vu3kLwTppAA_JvuRfzxyFYeGTJKqwAQdmDbbO_TNNV9QknUxhpsMtjNaib7aFUyQcWJpIhfV0hhFZioGK9AiEM" alt /></p>
<h3 id="heading-ii-africas-talking-sms-endpoint-live"><strong>ii. Africa’s Talking SMS Endpoint (Live)</strong></h3>
<p>When using the AT endpoint URL, the endpoint is used by all users, hence, you have to specify your API Key, username as well as the message specifics (To, Message). The endpoints are in two forms: <em>Live</em> and <em>Sandbox</em>. In this case, we will use the Live endpoint. The endpoints can be found <a target="_blank" href="https://developers.africastalking.com/docs/sms/sending/bulk">here</a>. The Live endpoint URL is:</p>
<pre><code class="lang-plaintext">https://api.africastalking.com/version1/messaging
</code></pre>
<p><strong>Note</strong>: <em>Sandbox</em> is the test environment, <em>Live</em> is the actual environment used in production.</p>
<p>The POST request sent to the endpoint with the mentioned fields is as shown in the images below:</p>
<ul>
<li>The API Key is added in the <em>authorization</em> field, hence, to the <em>Header</em> section as shown:</li>
</ul>
<p><img src="https://lh6.googleusercontent.com/HPPpChyvPv4G7r5NcJSbqe_Hi-QAFXlya4AHHSsLdZmzfWzfpr9r8hqKHoTNLpWbqAtlzr0qQZrXhVIe4Sk4Zqx8Fjghf6T__E0MaW7V5zG4yWcG-eXUCeuGT5hUzIXB3vvXH4sA7XiV7fqlaoYmJss" alt /></p>
<ul>
<li>The rest of the details are added in the <em>Body</em> as shown:</li>
</ul>
<p><img src="https://lh3.googleusercontent.com/LionR6CScOb9y4L_DfVPsxzc91pftSOhDvQewvW43ZD7VFJaMWan1vmkpRyRG2draA-gigxmC8RU_ZI2AttDRF3sgD7qNJt6M3ZYOpqNx7-8dckE48uTk_IXgO9rtIYwpKlXiA7w_hONZm0CMU1w5xA" alt /></p>
<p>The response message received is similar to the one received when using the <a target="_blank" href="http://localhost">localhost</a> URL as shown below:</p>
<p><img src="https://lh4.googleusercontent.com/hOMY8fAS-Zr_AbDMxdwjIRvF-Ns3xuNVd3l_FWosanRDRnDa4PwB9t1c27LbPZ5enIDihkj00o_btLuAN_a9AOEQBvDIGUjl6NB5NXk_HjWifpEeHAkAFyrA-zyDOCYhdPU9jIIYeUHHRVXq2j5USi0" alt /></p>
<ol>
<li><h2 id="heading-airtime"><strong>Airtime</strong></h2>
</li>
</ol>
<p>When sending airtime, the developer/business POSTs a request with the required data in order to receive a notification. The required fields in POSTing a request for airtime are:</p>
<ul>
<li><p><strong>maxNumRetry</strong>: This is the maximum number of retries which the transaction does every 60 seconds for the next specified number of hours.</p>
</li>
<li><p><strong>Recipient details</strong>: The details of the recipients that are essential are:</p>
</li>
<li><p><strong><em>phoneNumber</em></strong>: This is the number of the recipient who receives the airtime.</p>
</li>
<li><p><strong><em>Amount</em></strong>: This is the amount to be transferred.</p>
</li>
<li><p><strong><em>Currency</em></strong>: This is to identify the currency form to be transferred as.</p>
</li>
</ul>
<p>On Postman, you can post a request to send airtime for an application/file hosted locally via <a target="_blank" href="http://localhost"><em>localhost</em></a> or an application that is live via the Africa’s Talking <em>endpoint</em> <em>URL</em> (Live or Sandbox).</p>
<h3 id="heading-i-localhosthttplocalhost-1"><strong>i.</strong> <a target="_blank" href="http://Localhost"><strong>Localhost</strong></a></h3>
<p>The <a target="_blank" href="http://localhost">localhost</a> method is done by POSTing using the URL formed by the loopback address (127.0.0.1) together with the port number specified in your code (e.g. 3005, 8080), just as shown in the previous section on SMS -&gt; <a target="_blank" href="http://Localhost">Localhost</a>. This is as shown in the image below:</p>
<p><img src="https://lh6.googleusercontent.com/TX8kiKE_CWIXe8ENMneAmg0kCzp-pqPzdZJ7mO_3ZdtDeWeGojuzcFllpc6JSxK1MRv8sK3np3nW9MC6iGlt1pBcFc3dr01ycPcVXrJK-c7aTQSwuRWz-H6-hSzMCvOjgRU1M-bdcKIoS6gvk0EqFK0" alt /></p>
<p>The response received is as shown in the image below:</p>
<p><img src="https://lh3.googleusercontent.com/dNN4zGW6cHu9eVFNy9X_DxJamqGhsdfEONhChthh_PxwE80Fy4EtV4B0_k40Kdi1ue1Yf_huvjWxvd9el6yweR5ti6Rj3IBxwb9PAdluPVXk1e0HgQbARlNUjZcLARlDXnsy_k2mbFmsYar3ZOFcHTc" alt /></p>
<h3 id="heading-ii-africas-talking-sms-endpoint-live-1"><strong>ii. Africa’s Talking SMS Endpoint (Live)</strong></h3>
<p>When using the AT endpoint URL, the endpoint is used by all users, hence, you have to specify your API Key, username as well as the airtime specifics (maxNumRetry, Recipients). The endpoints are in two forms: <em>Live</em> and <em>Sandbox</em>. In this case, we will use the Live endpoint. The endpoints can be found <a target="_blank" href="https://developers.africastalking.com/docs/airtime/sending">here</a>. The Live endpoint URL is:</p>
<pre><code class="lang-plaintext">https://api.africastalking.com/version1/airtime/send
</code></pre>
<p>The POST request sent to the endpoint with the mentioned fields is as shown in the images below:</p>
<ul>
<li>The API Key is added in the <em>authorization</em> field, hence, to the <em>Header</em> section as shown:</li>
</ul>
<p><img src="https://lh3.googleusercontent.com/yNBkEB4IXxtuHLxgFXP8g6guzSq6mFbXJKRnlfX__jeQjGwHBnjz1mSrGH7WLSZ3ydTKnsRq--wxxaqqLgVhkeo05ouKwRi_PIhmEL8ivv5mn6KC-rCRILo1Y9Xzx1vKJSbvR_EJ3hJt6JK74eFQMwY" alt /></p>
<ul>
<li>The rest of the details are added in the <em>Body</em> as shown:</li>
</ul>
<p><img src="https://lh5.googleusercontent.com/z62PFiRZZj2tVcpm-2TRlyEhsJKVB8xMFC-GwWFhPhjoyuj9YXl8yuBziu54GGYmJ271f1siXtFpzYT5wvo2u6MvqQMXGs-OHiXPZYpIcVJgegJ-Zy9Wb66gQncINJBVbNFLYswm7lSifk5MXZi9me8" alt /></p>
<p>The response message received is similar to the one received when using the <a target="_blank" href="http://localhost">localhost</a> URL as shown below:</p>
<p><img src="https://lh4.googleusercontent.com/Vip_Eqn5YgDCH0V8gFR-aDTBDPLmn8dtZVMl-R1ZLJF8ZdhBVwqHMfR7CHKOrYm5EouC7FvWiBmKDpo99Sno7z1DFbplqCuK6qwGR5zCyMw86mALOeWMVBFLez_OMkPXc-HWUsnjWWPXtFCB23pKQek" alt /></p>
<h1 id="heading-ngrok"><strong>Ngrok</strong></h1>
<p><a target="_blank" href="https://ngrok.com/">Ngrok</a> is used for connectivity to the app by providing a forwarding address. To do this, Ngrok should be installed on your local machine. The port to be accessed in as defined in the code for your application. Commands are used to access that port in which the code is running in this form:</p>
<pre><code class="lang-plaintext">ngrok http PORTNUMBER
</code></pre>
<p>For example, in our case the port number used is 3003, hence, the command is:</p>
<pre><code class="lang-plaintext">ngrok http 3003
</code></pre>
<p>After running the command, the terminal opens a window with details as illustrated in the image below:</p>
<p><img src="https://lh4.googleusercontent.com/NRH248_Gs8sRKwUHVVYlgTQNWCcIky0A1UL7ngFMJa0VtJCrNt2rmdKe4Xy4YC5Gs8h7pZUY_6B2vqGLzBlw_S4aicFzgJo-_t9MSEY4PLH_wI9WPN1rDBiN93DEc20EeQrlNv03EcBziSGE2x2MxxM" alt /></p>
<p>With this, a forwarding address is identified which is used to create the callback URL.</p>
<h1 id="heading-callback-urls"><strong>Callback URLs</strong></h1>
<p>A <a target="_blank" href="https://help.africastalking.com/en/articles/2189463-what-is-a-callback-url">callback URL</a> is an address where data is posted to which enables you to receive reports in your application. The <em>Ngrok</em> forwarding address is placed in the callback URL field with a small extension to identify it. SMS and Airtime have various callback URLs as explained below:</p>
<p><strong>a) SMS</strong></p>
<ul>
<li><p><strong><em>Delivery reports</em></strong>: Reports on whether the messages were delivered</p>
</li>
<li><p><strong><em>Incoming messages</em></strong>: Reports details on the incoming messages for two-way SMS</p>
</li>
<li><p><strong><em>Bulk SMS opt out</em></strong>: Reports on users who wish to opt out of receiving bulk SMSs</p>
</li>
<li><p><strong><em>Subscription notifications</em></strong>: Reports details on users who subscribe to various SMS</p>
</li>
</ul>
<p><strong>b) Airtime</strong></p>
<ul>
<li><p><strong><em>Status</em></strong>: Reports on whether the transactions were successful or failed</p>
</li>
<li><p><strong><em>Validation</em></strong>: Reports used when the developer wishes to validate or approve transactions before they take place</p>
</li>
</ul>
<p>An illustration of setting a callback URL in:</p>
<ul>
<li><h2 id="heading-sms-delivery-reports"><strong>SMS (Delivery Reports)</strong></h2>
</li>
</ul>
<p>The <em>Ngrok</em> forwarding address is placed in the callback URL field with a small extension to identify it, such as /delivery in this case. Hence, the callback URL is as shown in the image below:</p>
<p><img src="https://lh5.googleusercontent.com/f_ty-pOg8Cdqlh7kXnOOQ7uv65wuzCMftWuUKo5FwsDVGQIY5RA0RVsiW_nzx9CG2rupZujPdTWRmesEgVLki-vQk2Azne-dXjl_-cwKK6OAWKE27j6w4Ujp0gYYLxIM0aTr8EdZp0iSk-rSaM5-Xzs" alt /></p>
<p>The <em>Submit</em> button is selected and a message displayed to show that the callback has successfully been updated. Once this is done, whenever messages are sent, the reports are visible on the terminal as shown in the image below:</p>
<p><img src="https://lh6.googleusercontent.com/Lrp_Bt-sZDExti8hCtUJQrzh8hTZ_JCWy7DF6Rwvi4rdHm8g0vkZQTvB8-WS44yPqRjGjWRvQX4tjsch5d6yRTouqw_9AJSMg-1KzQU85Qtn334oSuUJ52lxaiL2S4D_iYaXmBUHTYQ_f-7kx8o0MW4" alt /></p>
<ul>
<li><h2 id="heading-airtime-status"><strong>Airtime (Status)</strong></h2>
</li>
</ul>
<p>The <em>Ngrok</em> forwarding address is placed in the callback URL field with a small extension to identify it, such as /status in this case. Hence, the callback URL is as shown in the image below:</p>
<p><img src="https://lh3.googleusercontent.com/FweJ0RXievHxGREwhPcep7Y_VLvkC8EpjfwKkHIcq2urxx3f_EHP4_ued23blriHpU50o623OsLB5CDuINoFYScVPdQQv96GTJyhUnx2TwdA7r0AYEkrD0XtlI4LcazuClJPlIkmF3Gkc_TNDhg_33U" alt /></p>
<p>The <em>Submit</em> button is selected and a message displayed to show that the callback has successfully been updated. Once this is done, whenever transactions take place, the reports are visible on the terminal as shown in the image below:</p>
<p><img src="https://lh4.googleusercontent.com/W_ebUF4q-Qej0hqiWbboQfLrKO2CswUIcvXa6fJSt-aYBRIM3AH4cAKZZZ5yLZNFdOF45ilwCiQpq0RhtFzzO95VNwYZkWGz_5q8oUBP1KxzpBzcEkDlP1o6liQKoAXTUCIbSsjkLZqUCTDb6sRGt-4" alt /></p>
<p>That’s it. All the best in getting started :)</p>
<h1 id="heading-resources"><strong>Resources</strong></h1>
<ul>
<li>Africa’s Talking <a target="_blank" href="https://www.postman.com/africastalking">Postman Collections</a> are found here</li>
</ul>
]]></content:encoded></item></channel></rss>