UAPI accesses the cPanel interface's features. Use this API to access and modify cPanel account data and settings.
https://api.docs.cpanel.net/_mock/specifications/cpanel.openapi/
https://{host}:{port}/execute/
Request
This function creates a subdomain.
Important:
When you disable the Web Server role, the system disables this function.
The domain on which to create the new subdomain. The domain must already exist on the cPanel account.
Whether to use a canonical name (CNAME) in the Apache® configuration for self-referential URLs.
1- Use the CNAME.0- Do not use the CNAME.
The subdomain's document root within the home directory, given as a valid directory path relative to the user's home directory.
This value defaults to the user's home directory /public_html/ path.
Note:
If the Restrict document roots to public_html value is set to Off in WHM's Tweak Settings interface (WHM >> Home >> Server Configuration >> Tweak Settings), this parameter defaults to the /username/ path. For example, the username user's subdomain example would default to the /home/username/example path.
- Mock server
https://api.docs.cpanel.net/_mock/specifications/cpanel.openapi/SubDomain/addsubdomain
- A server running cPanel.
https://cpanel-server.tld:2083/execute/SubDomain/addsubdomain
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
-u <username>:<password> \
'https://api.docs.cpanel.net/_mock/specifications/cpanel.openapi/SubDomain/addsubdomain?domain=subdomain&rootdomain=example.com&canoff=1&dir=%2Fpublic_html%2Fdirectory_name&disallowdot=1'{ "apiversion": 3, "func": "addsubdomain", "module": "SubDomain", "result": { "data": null, "errors": null, "messages": null, "metadata": {}, "status": 1, "warnings": null } }