Language

Send an Sms Notification

This API is used to send an sms to your customer after you receive a buygoods_transaction_received webhook. You need to include the reference(id) of the webhook event payload that you received.

POST https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications
Content-Type: application/json
Accept: application/json
Authorization: Bearer < AccessToken >
{
  "webhook_event_reference": "e51438e9-c42b-4bf2-a261-faeaf189e3ed",
  "message": "Your message here",
  "_links": {
    "callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e"
  }
}
# Using K2Connect - https://github.com/kopokopo/k2-connect-ruby (Recommended)
your_input =
{
  webhook_event_reference: "e51438e9-c42b-4bf2-a261-faeaf189e3ed",
  message: "Your message here",
  callback_url: 'https://call_back_to_your_app.your_application.com'
}

k2_notification = k2Notification.new("your_access_token")
k2_notification.transaction_sms_notifications(your_input)
k2_notification.location_url # => "https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/247b1bd8-f5a0-4b71-a898-f62f67b8ae1c"

request_body =
{
  "access_token": ACCESS_TOKEN,
  "callback_url": "https://webhook.site/52fd1913-778e-4ee1-bdc4-74517abb758d",
  "webhook_event_reference": "e51438e9-c42b-4bf2-a261-faeaf189e3ed",
    "message": "Your message here"
}

# Using K2Connect - https://github.com/kopokopo/k2-connect-python (Recommended)
k2connect.initialize(environ.get('CLIENT_ID'), environ.get('CLIENT_SECRET'), 'http://127.0.0.1:3000/')
notification_service = k2connect.NotificationService
notification_location = notification_service.transaction_sms_notifications(request_body)
notification_location # => 'https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/247b1bd8-f5a0-4b71-a898-f62f67b8ae1c'


const SmsNotificationService = K2.SmsNotificationService

var notificationOptions = {
  webhookEventReference: 'e51438e9-c42b-4bf2-a261-faeaf189e3ed',
  message: 'Your message here',
    // This is where once the request is completed kopokopo will post the response
  callbackUrl: 'https://callback_to_your_app.your_application.com/endpoint',
    accessToken: 'myRand0mAcc3ssT0k3n'
}

SmsNotificationService
  .sendTransactionSmsNotification(notificationOptions)
  .then( response => {
    console.log(response)
    // => 'https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/247b1bd8-f5a0-4b71-a898-f62f67b8ae1c'
  })
  .catch( error => {
    console.log(error)
  })
<?
$transaction_sms_notifications = $K2->SmsNotificationService();
$response = $transaction_sms_notifications->sendTransactionSmsNotification([
  'webhookEventReference' => 'e51438e9-c42b-4bf2-a261-faeaf189e3ed',,
  'message' => 'Your message here',
  'callbackUrl' => 'https://callback_to_your_app.your_application.com/endpoint',
  'accessToken' => 'myRand0mAcc3ssT0k3n',
]);
if($response['status'] == 'success')
{
    echo "The resource location is:" . json_encode($response['location']);
    // => 'https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/247b1bd8-f5a0-4b71-a898-f62f67b8ae1c'
}

Retrieve your newly created subscription by its resource location:

GET https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af
Accept: application/json
Authorization: Bearer pBA9fVDBEyYZCEsLf/wKehyh1RTpzjUj5KzIRfDi0wKTii7DqY

...

{
  "data": {
    "id": "a48ad0a7-b43b-48c5-9ff8-509552d603af",
    "type": "transaction_sms_notification",
    "attributes": {
      "status": "Success",
      "message": "Your message here",
      "webhook_event_reference": "4b46f88a-31f6-4af2-8795-b11ef1f3b846",
      "_links": {
        "callback_url": "https://webhook.site/a67f60b8-8c26-40a2-866c-99f5314a3e0e",
        "self": "https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af"
      }
    }
  }
}
notification_url = 'https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af'

# Using K2Connect - https://github.com/kopo-kopo/k2-connect-ruby (Recommended)
subscription = K2Subscribe.new(your_access_token)
subscription.query_resource_url(notification_url)
//  Using Kopo Kopo Connect - https://github.com/kopokopo/k2-connect-node (Recommended)
const NotificationService = K2.NotificationService

var webhookSubscriptionUrl = 'https://sandbox.kopokopo.com/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af'

NotificationService
  .getStatus({accessToken: 'myRand0mAcc3ssT0k3n', location: webhookSubscriptionUrl})
  .then(response => { console.log(response) }) 
  .catch(error => { console.log(error) })
notification_url = 'https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/a48ad0a7-b43b-48c5-9ff8-509552d603af'

#Provide example using K2Connect https://github.com/kopo-kopo/k2-connect-python (Recommended)
k2connect.initialize(CLIENT_ID, CLIENT_SECRET, BASE_URL)
webhook_service = k2connect.NotificationService
webhook_service.webhook_status(ACCESS_TOKEN, notification_url) 
<?
//  Using Kopo Kopo Connect - https://github.com/kopokopo/k2-connect-php (Recommended)
$webhooks = $K2->NotificationService();

$options = [
  'location' => 'https://sandbox.kopokopo.com/api/v1/transaction_sms_notifications/d76265cd-0951-e511-80da-0aa34a9b2388',
  'accessToken' => 'myRand0mAcc3ssT0k3n',
];
$response = $webhooks->getStatus($options);

echo $response;