<?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"; ?>