Ahhh that is what you mean, I though you mean the 'hostname' of the server itself.
But the server's hostname should already be correctly when you install it, unless you change the hostname later after installing DA.
I wish to automate this so the hostname can be changed from an other service panel where me manage all our servers without having to login into the server itself using the DA interface our commandline.
For this option is a API specially made for, the only thing is the API has to support this.
The hostname.sh script in de scripts map does not set the hostname within DirectAdmin.
So if you update the hostname it using the script it is still NOT updated within the panel itself, this results that the message system of DA starts mailing that the server hostname is not correctly setup.
Although there is no CMD_API_ADMIN_SETTINGS function in DA, you can still call CMD_ADMIN_SETTINGS with an API script. This would do everything for you with regards to the hostname.
The catch is that you must pass all variable that the form uses, which may be difficult to obtain since there is no API... but if the hostname change was only for new systems and rarely done, then you could just pick default values, along with the new hostname, and ns1/ns2 values, etc.. and submit it to CMD_ADMIN_SETTINGS with your script. The output would be html, so no likely readable, but there are not usually any errors with saving this form.
Note, that when changing the hostname, you must also ensure that the hostname resolves. I'd recommend adding a new zone into the dns (DNS Admin) with the full name of the hostname, eg: "domain = server.hostname.com", as this will also create an MX record which is needed for mail delivery from system accounts.