Skip to content

Instantly share code, notes, and snippets.

@JaniKibichi
Last active December 20, 2022 23:06
Show Gist options
  • Save JaniKibichi/8226020389209a524b13acf0cad08560 to your computer and use it in GitHub Desktop.
Save JaniKibichi/8226020389209a524b13acf0cad08560 to your computer and use it in GitHub Desktop.
cURL Endpoints
Sandbox End Points
1. SMS
Make a HTTP POST request to https://api.sandbox.africastalking.com/version1/messaging
See the Parameters
curl -v -H "Accept: application/json" \
-d "username=sandBoxUserName&message=hello test&to=+254711XXXYYY,+254733YYYZZZ" \
-H "Apikey:fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674" \
-X POST http://api.sandbox.africastalking.com/version1/messaging --insecure
2. USER DATA
Make a HTTP GET request to https://api.sandbox.africastalking.com/version1/user
See the Parameters
curl -H "Accept: application/json" \
-H "Apikey:fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674" \
"https://api.sandbox.africastalking.com/version1/user?username=sandBoxUserName" --insecure
3. PREMIUM SUBSCRIPTIONS
Make a HTTP POST request to https://api.sandbox.africastalking.com/version1/subscription/create
See the Parameters
curl -v -H "Accept: application/json" \
-H "Apikey:fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674" \
-d "username=sandBoxUsername&shortCode=12345&keyword=myPremiumKeyword&phoneNumber=+254711XXXYYY" \
-X POST https://api.sandbox.africastalking.com/version1/subscription/create --insecure
4. AIRTIME
Make a HTTP POST request to https://api.sandbox.africastalking.com/version1/airtime/send
See the Parameters
curl -v -H "Accept: application/json" \
-H "Apikey:fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674" \
-d "username=myusername&recipients=[{'phoneNumber':'+254711XXXYYY','amount':'KES X'},{'phoneNumber':'+254733YYYZZZ','amount':'KES Y'}]" \
-X POST http://api.sandbox.africastalking.com/version1/airtime/send --insecure
5. PAYMENTS
Make a HTTP POST request to https://payments.sandbox.africastalking.com/mobile/checkout/request
See the Parameters
curl -v -H "Accept: application/json" \
-H "Apikey:fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674" \
-d "username=myusername&productName=My Online Store&phoneNumber=+254711XYYZZZ&currencyCode=KES&amount=100.50&metaData=[{'agentId':'123','productId':'456'}]" \
-X POST https://payments.sandbox.africastalking.com/mobile/checkout/request --insecure
Make a HTTP POST request to https://payments.sandbox.africastalking.com/mobile/b2c/request
See the Parameters
curl -v -H "Accept: application/json" \
-H "Apikey:fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674" \
-d "username=myusername&productName=My Online Store&recipients=[{'phoneNumber':'123','currencyCode':'KES','amount':'10.50'}, 'metadata':[{'name':'clerk','reason':'May Salary'}]]" \
-X POST https://payments.sandbox.africastalking.com/mobile/b2c/request --insecure
Make a HTTP POST request to https://payments.sandbox.africastalking.com/mobile/b2b/request
See the Parameters
curl -v -H "Accept: application/json" \
-H "Apikey:fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674" \
-d "username=myusername&productName=myPaymentProductName" \
-d "provider=Athena&destinationChannel=535400" \
-d "transferType=BusinessToBusinessTransfer" \
-d "providerData=[{'provider':'Mpesa','destinationChannel':'535400','transferType':'BusinessToBusinessTransfer'}]&currencyCode=KES&amount=100&metadata=[{'shopId':'1234','itemId':'abcde'}]" \
-X POST https://payments.sandbox.africastalking.com/mobile/b2b/request --insecure
6. VOICE
Make a HTTP POST request to https://voice.sandbox.africastalking.com/call
See Parameters
curl -v -H "Accept: application/json" \
-H "Apikey:fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674" \
-d "username=myUsername&to=+254711XXXYYY&from=+254711082XXX" \
-X POST https://voice.sandbox.africastalking.com/call --insecure
Live End Points
1. SMS
Make a HTTP POST request to https://api.africastalking.com/version1/messaging
See the Parameters
curl -v -H "Accept: application/json" \
-d "username=sandBoxUserName&message=hello test&to=+254711XXXYYY,+254733YYYZZZ" \
-H "Apikey:fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674" \
-X POST http://api.africastalking.com/version1/messaging --insecure
2. USER DATA
Make a HTTP GET request to https://api.africastalking.com/version1/user
See the Parameters
curl -H "Accept: application/json" \
-H "Apikey:fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674" \
"https://api.africastalking.com/version1/user?username=sandBoxUserName" --insecure
3. PREMIUM SUBSCRIPTIONS
Make a HTTP POST request to https://api.africastalking.com/version1/subscription/create
See the Parameters
curl -v -H "Accept: application/json" \
-H "Apikey:fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674" \
-d "username=sandBoxUsername&shortCode=12345&keyword=myPremiumKeyword&phoneNumber=+254711XXXYYY" \
-X POST https://api.africastalking.com/version1/subscription/create --insecure
4. AIRTIME
Make a HTTP POST request to https://api.africastalking.com/version1/airtime/send
See the Parameters
curl -v -H "Accept: application/json" \
-H "Apikey:fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674" \
-d "username=myusername&recipients=[{'phoneNumber':'+254711XXXYYY','amount':'KES X'},{'phoneNumber':'+254733YYYZZZ','amount':'KES Y'}]" \
-X POST http://api.africastalking.com/version1/airtime/send --insecure
5. PAYMENTS
Make a HTTP POST request to https://payments.africastalking.com/mobile/checkout/request
See the Parameters
curl -v -H "Accept: application/json" \
-H "Apikey:fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674" \
-d "username=myusername&productName=My Online Store&phoneNumber=+254711XYYZZZ&currencyCode=KES&amount=100.50&metaData=[{'agentId':'123','productId':'456'}]" \
-X POST https://payments.africastalking.com/mobile/checkout/request --insecure
Make a HTTP POST request to https://payments.africastalking.com/mobile/b2c/request
See the Parameters
curl -v -H "Accept: application/json" \
-H "Apikey:fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674" \
-d "username=myusername&productName=My Online Store&recipients=[{'phoneNumber':'123','currencyCode':'KES','amount':'10.50'}, 'metadata':[{'name':'clerk','reason':'May Salary'}]]" \
-X POST https://payments.africastalking.com/mobile/b2c/request --insecure
Make a HTTP POST request to https://payments.africastalking.com/mobile/b2b/request
See the Parameters
curl -v -H "Accept: application/json" \
-H "Apikey:fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674" \
-d "username=myusername&productName=myPaymentProductName" \
-d "provider=Mpesa&destinationChannel=partnerBusinessChannel" \
-d "transferType=BusinessToBusinessTransfer" \
-d "providerData=[{'provider':'Mpesa','destinationChannel':'partnerBusinessChannel','transferType':'BusinessToBusinessTransfer'}]&currencyCode=KES&amount=100&metadata=[{'shopId':'1234','itemId':'abcde'}]" \
-X POST https://payments.africastalking.com/mobile/b2b/request --insecure
6. VOICE
Make a HTTP POST request to https://voice.africastalking.com/call
See Parameters
curl -v -H "Accept: application/json" \
-H "Apikey:fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674" \
-d "username=myUsername&to=+254711XXXYYY&from=+254711082XXX" \
-X POST https://voice.africastalking.com/call --insecure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment