# POST Create or update server This API call creates a server or updates it with the given information. #### Location ``` /api/v1/servers/ ``` #### Permissions required `servers` RW #### Body parameters | Parameter | Type | Required | Description | | -------------------- | ------------------------------------------------------ | -------- | ----------------------------------------- | | server_vm_host_id | string | yes | Unique id of the vm | | server_vm_host_name | string | no | Name of the vm | | company_uuid | string | no | Company_uuid from companies | | server_power_state | enum ['Running', 'Off'] | no | If the vm is on or off | | server_state | enum ['new', 'active', 'deleted', 'trial', 'disabled'] | no | Server state. 'new' is the default | | server_hostname | string | no | Hostname of the server | | server_os | string | no | Server operating system | | server_cpu | int | no | Amount of cpu used by the server | | server_memory | int | no | Amount of memory used by the server in MB | | server_memory_demand | int | no | Amount memory demand by the server in MB | | server_disks | array | no | Array of the servers disks | | server_ipv4 | array | no | Array of the ipv4 addresses in a list | | server_ipv6 | json | no | Array of the ipv6 addresses in a list | | server_vm_generation | int | no | VM machine generation or version | | server_vm_snapshot | int | no | Amount of snapshots made of the vm | | server_licenses | json | no | Array of the server licenses | | server_backup | json | no | Array of the server backups | | server_description | string | no | description of the server | >[!note] > If the current `server_state` is _new_ and the posted `server_state` is _deleted_, the server will be permanently deleted. Otherwise, if the current state is not _new_, the `server_state` will simply be updated to _deleted_ without permanent removal." #### server_disks parameters | Parameter | Type | Required | Description | | ------------- | ------ | -------- | -------------------------------------------------------------------------------------------- | | disk_name | string | yes | Name of the disk | | disk_space | float | yes | The file space of the vhd that is reserved. | | disk_used | float | yes | the real space used on the server for the vhd file. Can be used for dynamically sized disks. | | disk_location | string | yes | The real location of the vhd file. | #### server_licenses parameters When posting `server_licenses`, you must include a prefix before each license name. Use **+** to add or register a license, and **-** to ensure the license is not registered in Sentri. This ensures that any license a server no longer has is automatically removed from Sentri. | Parameter | Type | Required | Description | | -------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------ | | *license name* | string | yes | Name of a license | | *license type* | string | yes | Type the license like, **super-plus** or **plus**. If this is not applicable, name it the same as the license name | #### server_backup parameters When posting `server_backup`, you must include a prefix before each backup name. Use **+** to add or register a backup, and **-** to ensure the backup is not registered in Sentri. This ensures that any backup a server no longer has is automatically removed from Sentri. | Parameter | Type | Required | Description | | ------------- | ------ | -------- | ------------------------------------------------------------------- | | *backup name* | string | yes | Name of the backup | | *backup type* | string | yes | Type of the backup. You can put here yes or the type of the backup. | ### Example Body (json) ```json { "server_vm_id": "00155d001d3f", "server_vm_host_name": "web01.test.example.nl", "server_power_state": "Running", "server_state": "new", "server_hostname": "web01.test.example.nl", "server_os": "AlmaLinux 10.1", "server_cpu": 1, "server_memory": 2048, "server_memory_demand": 1267, "server_disks": [ { "disk_name": "server_datadisk.vhdx", "disk_space": "150", "disk_used": "140.5", "disk_location": "C:\\ClusterStorage\\vol07\\web01.test\\VHD\\" } ], "server_ipv4": [ "123.12.34.113", "123.12.34.134" ], "server_ipv6": [ "2a01:4c66:4:2:44::1", "2a01:4c66:4:2:45::2" ], "server_vm_generation": 2, "server_vm_snapshot": 1, "server_licenses": [ { "+directadmin": "Discounted Standard" }, { "+cpguard": "cpguard" }, { "-installatron": "none" } ], "server_backup": [ { "+borg": "yes" } ], "server_description": "test web server" } ``` #### Multiple servers It is possible to post multiple servers in one request. Put the different servers in an array like below: ```json { "servers": [ { "server_vm_id": "00155d001d3d", "server_vm_host_name": "web01.test.example.nl" }, { "server_vm_id": "00155d001d3f", "server_vm_host_name": "web02.test.example.nl" } ] } ``` ### Example Request ```php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://sentri.nl/api/v1/servers/', CURLOPT_HTTPHEADER => [ "Authorization: Bearer ", ], CURLOPT_POST => true, CURLOPT_POSTFIELDS => '', )); $response = curl_exec($curl); curl_close($curl); echo $response; ``` ### Example Response ```json "Server(s) modified or updated successfully." ``` #### Known errors or issues. None are known at the time. If you do encounter issues and get an http code in return, check the response codes on this page.