Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
technical:api-voucher-add [2026/05/21 08:47] systemtechnical:api-voucher-add [2026/05/21 09:03] (current) system
Line 31: Line 31:
 ----------------- -----------------
  
-====== Add single voucher using the API ======+====== Add single or batch using the API ======
  
   * When using the API to generate vouchers you have the option to create a single voucher or a batch of vouchers.   * When using the API to generate vouchers you have the option to create a single voucher or a batch of vouchers.
-  * Here we will cover the API call to create a single voucher. +<file php add_voucher.php>
-<file php add_single_voucher.php>+
 <?php <?php
    
     // Configuration     // Configuration
-    $api_url    = 'http://127.0.0.1/cake4/rd_cake/permanent-users/add.json'; +    $api_url    = 'http://127.0.0.1/cake4/rd_cake/vouchers/add.json'; 
-    $token      = 'b4c6ac81-8c7c-4802-b50a-0a6380555b50';+    $token      = 'fe707444-b00c-b00c-b00c-03ae7fc12345';
     $cloud_id   = 23; // replace with the Cloud ID that you want to work on.     $cloud_id   = 23; // replace with the Cloud ID that you want to work on.
-    $username   = 'testuser'; +    $realm      = 'pppoe'; 
-    $password   = 'testing123'; +    $profile    = 'slow'; 
-    $realm      = 'Dev'; +     
-    $profile    = 'MzanziFibre-12/1'; +
- +
     // Set API payload     // Set API payload
     $payload = [     $payload = [
-    +        
         //Required Fields              //Required Fields     
-        'username => $username, +        'single_field => 'true'//must be set to the string 'trueto be activated 
-        'password => $password, +        'realm'         => $realm, 
-        'realm'     => $realm, +        'profile'       => $profile, 
-        'profile'   => $profile, +        'cloud_id'      => $cloud_id, 
-        'cloud_id'  => $cloud_id, +        'token'         => $token, 
-        'token'     => $token, +         
-        'active'    => 'active', //active flag must be set for user to authenticate       +        //To create a batch these are needed (leave out for single voucher creation) 
-                  +        'quantity     => 10
-       /        +        'batch        => 'api_batch_one          
-       //Optional Fields   +
-        'name         => ''+
-        'surname'       => '',      +
-        'phone        => ''+
-        'email'         => '', +
-        'address'       => '', +
-        'from_date'     => '04/12/2025', +
-        'to_date'       => ''04/12/2026', +
-        'realm_id'     => 19, //Alternative to Realm's name +
-        'profile_id'    => 49, //Alternative to Profile's name +
-        'static_ip'     => '192.168.1.100' +
-        'extra_name'    => '', +
-        'extra_value'   => '', +
-        'site'          => '', +
-        'ppsk'          => '', +
-        'auto_add'      => 'auto_add' //flag to automatically add the MAC Address the user connects with as a Device (BYOD) belonging to him +
-        */+
     ];     ];
    
Line 88: Line 68:
     $response = curl_exec($ch);     $response = curl_exec($ch);
     curl_close($ch);     curl_close($ch);
-    echo "Added $username: $response\n";+    echo "Added single voucher: $response\n";
    
 ?> ?>
 </file> </file>
-  * Now that we have created a Permanent User, we will cover some common actions that can be done on the Permanent User via the API.+  * The reply will be in JSON which can be used should there be a requirement
  
  • technical/api-voucher-add.txt
  • Last modified: 2026/05/21 09:03
  • by system