API for DirectAdmin

cherimos

New member
Joined
Jun 9, 2025
Messages
2
I'm a new user trying to set up an API integration with DirectAdmin, and I'm encountering some difficulties, despite following the official documentation.

My goal is to create an admin-level API connection that allows me to perform various management tasks, such as creating email accounts, FTP accounts, and other user-specific resources. Crucially, I need to be able to do this on behalf of other users (i.e., for users under my admin account).

I am specifically trying to achieve this using Login Keys (API keys) rather than my main DirectAdmin account password, as this is recommended for security. I followed the steps to create a login key in the DirectAdmin GUI and set its permissions.

When I attempt to make an API call (e.g., to CMD_API_SHOW_USERS), I repeatedly receive an "Unauthorized" or "Not logged in" error. I've double-checked the API key value, the username, and especially the "Allowed IP addresses" setting for the login key to ensure it matches the IP from which I'm making the API calls.

I assumed that setting up an admin API connection with login keys to manage users would be a relatively straightforward process, but I'm struggling to get it to work.

Could someone please clarify if what I'm trying to achieve (admin API access for user management using login keys, including acting on behalf of other users) is indeed possible and straightforward? If so, could you point me towards common pitfalls or provide specific guidance on how to properly configure the login key and structure the API calls for this purpose?

Any help or insights would be greatly appreciated.

Thank you in advance!
 
Hello,

If you create an API url using the command:

Bash:
da api-url

and still get the error, you might check /var/log/directadmin/ for more clues.

I got this on my end:

Bash:
[root@dev ~]# curl -i $(da api-url)/CMD_API_SHOW_USERS; echo
HTTP/2 200
content-type: text/plain
cross-origin-resource-policy: same-origin
server: DirectAdmin Daemon
vary: Origin
vary: Accept-Encoding
x-content-type-options: nosniff
x-frame-options: sameorigin
date: Tue, 10 Jun 2025 04:54:12 GMT

list[]=testuser1
[root@dev ~]#
 
Back
Top