Overview

You can use this API request to top-up a customer’s email/SMS quota.

The Method

API-Method
RESTPOSThttps://[Your URL]/api/2.0/customers/topup/:customer_id/:package_identifier

Parameters

Required Parameters

You must include the following parameters for the request to work.

Property TypeDescriptionDefaultRequired
$idintegerID of the customer to top-up.noneyes
$package_idstringIdentifier for the top-up package.noneyes

Example Request

<?php
$username = 'administrator';
$apiKey = '7IjRKva9OzwCsy9xaCwsihA6HxUTwE7a_999';
$localUrl = 'https://localhost';
$customerId = 1;
$packageIdentifier = 24;
$url = $localUrl . '/api/2.0/customers/topup/' . $customerId . '/' . $packageIdentifier;
$method = 'POST';
$auth = base64_encode($username . ':' . $apiKey);

$cSession = curl_init();

curl_setopt($cSession, CURLOPT_URL, $url);
curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cSession, CURLOPT_HEADER, false);
curl_setopt($cSession, CURLOPT_CUSTOMREQUEST, strtoupper($method));
curl_setopt($cSession, CURLOPT_POSTFIELDS, '{}');
curl_setopt($cSession, CURLOPT_HTTPHEADER, [
    'Authorization: Basic ' . $auth,
    'Content-Type: application/json'
]);

$response = curl_exec($cSession);
var_dump($response);

curl_close($cSession);

Example Response

{
   "links":[
      {
         "title":"Self",
         "rel":"self",
         "href":"http:\/\/localhost\/api\/2.0\/customers\/topup\/1\/1"
      },
      {
         "title":"Home",
         "rel":"home",
         "href":"http:\/\/localhost\/api\/2.0\/"
      }
   ],
   "item":{
      "id":1,
      "enterprise_id":1,
      "hash":"7kvwQz6dzkgKbjS8",
      "country_code":"ZA",
      "is_department":"no",
      "name":"Administrator Customer",
      "status":"on",
      "address":"4th Floor Rosebank Corner",
      "state_provinces":"Gauteng",
      "postal_code":"2121",
      "telephone":"+27 11 447 6147",
      "fax":"+27 11 880 0340",
      "email":"support@pmailer.net",
      "industry":"E-commerce",
      "website_url":"",
      "country":"ZA",
      "email_package_id":1,
      "email_quota":2500,
      "sms_quota":10,
      "push_package_id":110,
      "transactions_package_id":0,
      "transactions_quota":0,
      "deleted":"no"
   }
}