Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. <nav type="pills" justified="false"> * [[:user_manuals|Back to Documentation]] * [[:technical:api-voucher-add|Add Vouchers]] </nav> ----- ====== Vouchers ====== * Vouchers are a once off way to give someone access to the Internet. * With a voucher you don't care who are using it and we thus do not record any personal information with a voucher. * A **Voucher** has to belong to a **Profile** and **Realm** in order to be useful to RADIUS. * There are dedicated Wiki Pages that cover adding a Profile and a Realm. * In this page we will show you how to add a Voucher to a Cloud in RADIUSdesk using an API call. * We will use PHP but the principles can be applied using any programming language. ----------------- ====== Add a Permanent User using the API ====== * Below is a simple as possible script that can be used as reference when adding a Permanent User using the API. * We also show the optional fields that can be included in the API call. <file php add_permanent_users.php> <?php // Configuration $api_url = 'http://127.0.0.1/cake4/rd_cake/permanent-users/add.json'; $token = 'b4c6ac81-8c7c-4802-b50a-0a6380555b50'; $cloud_id = 23; // replace with the Cloud ID that you want to work on. $username = 'testuser'; $password = 'testing123'; $realm = 'Dev'; $profile = 'MzanziFibre-12/1'; // Set API payload $payload = [ //Required Fields 'username' => $username, 'password' => $password, 'realm' => $realm, 'profile' => $profile, 'cloud_id' => $cloud_id, 'token' => $token, 'active' => 'active', //active flag must be set for user to authenticate /* //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 */ ]; $json_payload = json_encode($payload); $ch = curl_init($api_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $json_payload); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); $response = curl_exec($ch); curl_close($ch); echo "Added $username: $response\n"; ?> </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. technical/api-voucher-add.txt Last modified: 2025/06/10 14:10by system