Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| technical:api-voucher-add [2026/05/21 08:08] – system | technical:api-voucher-add [2026/05/21 09:03] (current) – system | ||
|---|---|---|---|
| Line 13: | Line 13: | ||
| * In this page we will show you how to add a Voucher to a Cloud in RADIUSdesk using an API call. | * 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. | * We will use PHP but the principles can be applied using any programming language. | ||
| + | |||
| + | ===== Options available when creating vouchers ===== | ||
| + | * There are two classes of vouchers. | ||
| + | * **Single Field** - Username and Password are of the **same** value and typically an easy to remember compound word. | ||
| + | * **Username and Password** - Username and Password are different where the username is easy to remember but the password is a random generated string. | ||
| + | * There is the option to create a single voucher or a batch of vouchers. | ||
| + | * Batches will be grouped by a batch name. | ||
| + | * Activate and Expire | ||
| + | * By default a voucher never expires. | ||
| + | * One can specify an expiry date where-after the voucher can not be used. | ||
| + | * There is also the option to activate the voucher when a user logs in for the first time. | ||
| + | * These type of vouchers are time based and you can specify the how long after the first login the voucher expires. | ||
| + | * Extra Fields | ||
| + | * There are an optional **Extra field name** and **Extra field value** that can be used to store extra information. | ||
| + | |||
| ----------------- | ----------------- | ||
| - | ====== Add a batch of vouchers | + | ====== 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. | ||
| - | * This Wiki page will start with a simple as possible script and then progress with other more advanced API options. | + | <file php add_voucher.php> |
| - | * We also show the optional fields that can be included in the API call. | + | |
| - | <file php add_single_voucher.php> | + | |
| <?php | <?php | ||
| // Configuration | // Configuration | ||
| - | $api_url | + | $api_url |
| - | $token | + | $token |
| $cloud_id | $cloud_id | ||
| - | | + | $realm |
| - | $password | + | $profile |
| - | | + | |
| - | $profile | + | |
| - | + | ||
| // Set API payload | // Set API payload | ||
| $payload = [ | $payload = [ | ||
| - | | + | |
| //Required Fields | //Required Fields | ||
| - | 'username' | + | 'single_field' |
| - | | + | ' |
| - | ' | + | ' |
| - | ' | + | ' |
| - | ' | + | ' |
| - | ' | + | |
| - | | + | //To create a batch these are needed (leave out for single voucher creation) |
| - | + | 'quantity' | |
| - | / | + | 'batch' |
| - | //Optional Fields | + | |
| - | 'name' | + | |
| - | 'surname' | + | |
| - | 'phone' | + | |
| - | ' | + | |
| - | ' | + | |
| - | ' | + | |
| - | ' | + | |
| - | ' | + | |
| - | ' | + | |
| - | ' | + | |
| - | ' | + | |
| - | ' | + | |
| - | ' | + | |
| - | ' | + | |
| - | ' | + | |
| - | */ | + | |
| ]; | ]; | ||
| Line 74: | Line 68: | ||
| $response = curl_exec($ch); | $response = curl_exec($ch); | ||
| curl_close($ch); | curl_close($ch); | ||
| - | echo " | + | echo " |
| ?> | ?> | ||
| </ | </ | ||
| - | * 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 |