This is an old revision of the document!



Realms

  • Each Permanent User, Voucher or BYOD Device has to belong to a Profile and Realm in order to be useful to RADIUS.
  • Before we can bulk import Permanent Users using a CSV file, we need to ensure that all the realms that the users belong to in the CSV file already exist.
  • In this page we will show you how to add a Realm 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 Realm using the API

  • Below is a simple as possible script that can be used as reference when adding a Realm using the API
add_profiles.php
<?php
 
    // Configuration
    $api_url    = 'http://127.0.0.1/cake4/rd_cake/realms/add.json';
    $token      = 'b4c6ac81-8c7c-4802-b50a-0a6380555b50';
    $cloud_id   = 23; // replace with the Cloud ID that you want to work on.
    $name       = 'Dev';
 
    // Set API payload
    $payload = [
 
        //Required Fields     
        'name'      => $name,
        'cloud_id'  => $cloud_id,
        'token'     => $token,
 
       /*        
       //Optional Fields       
        'phone'     => '',
        'fax'       => '',
        'cell'      => '',
        'email'     => '',
        'url'       => '',
        'street_no' => '',
        'street'    => '',
        'town_suburb'   => '',
        'city'      => '',
        'country'   => '',
        'lon'       => 0,
        'lat'       => 0,
        'suffix'    => 'example.com',            
        //Flags (exclude if it should not be set)
        'suffix_permanent_users'    =>	'suffix_permanent_users',
        'suffix_vouchers'           =>	'suffix_vouchers',
        'suffix_devices'            =>	'suffix_devices',
        */
    ];
 
    $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 $name: $response\n";
 
?>
  • Now that we have created Profiles and Realms, we can move on to adding a Permanent User.
  • technical/api-realms.1744483516.txt.gz
  • Last modified: 2025/04/12 20:45
  • by system