- Plesk for Linux
How to create a subdomain via Plesk XML API?
1. Login to the server over SSH
2. Create an XML file, for example, request.xml:
CONFIG_TEXT: <packet version="22.214.171.124">
3. Use the following command to make a request:
# curl -kLi -H "Content-Type: text/xml" -H "HTTP_AUTH_LOGIN: admin" -H 'HTTP_AUTH_PASSWD: *********' -H "HTTP_PRETTY_PRINT: TRUE" -d @request.xml https://203.0.113.2:8443/enterprise/control/agent.php
Note: wrapping up the XML requests into scripts that are later called via HTTP is not recommended. The reasons are:
- requests via Plesk API are more stable, it isn't affected by operations which require Apache/Nginx/FPM restart (i.e., site creation, updating of hosting settings, daily maintenance operations and so on)
- security: malicious client can flood the server with HTTP requests to the PHP script causing the server downtime. API requests are executed only from authorized clients.