Please always check if the wanted functionality is already implemented in the new codebase. When introducing a new modern API - not all the legacy parts can be ported 100% The new API is considered to be much more stable. More info about new API
Most new CMD_API_open in new window calls are only listed in the versions system, which can be searched. Please check the versions system if it's not listed below
The values ON or OFF generally indicate a checkbox, so if the checkbox is not checked, the name will not be passed and OFF is assumed. If a checkbox value is to be OFF, then the variable should not be passed at all.
A return value of Text means that a website will be returned with text showing the result.
If a return value is Location, then a Location header will be returned as a redirect to send the client to a new page.
If a return value is url encoded, then a url encoded string is returned after the DirectAdmin Headers.
You MUST have the proper permissions with your account in order use the API. For example, a User cannot get the list of all the Users on the server, only an Admin can.
The Admin's username. 4-8 characters, alphanumeric
email
A valid email address
passwd
The admins password. 5+ characters, ascii
passwd2
Password double check. 5+ characters, ascii
notify
yes or no. If yes, an email will be sent to email
Create Admin:
Function
To create a new admin account. Exactly the same as CMD_ACCOUNT_ADMIN except return value
Command
CMD_API_ACCOUNT_ADMIN
Method
GET or POST
Success Returns
error=0&text=text&details=details
Failure Returns
error=1&text=text&details=details
Create Reseller:
Function
To create a new reseller account using a pre-made package
Command
CMD_ACCOUNT_RESELLER
Method
GET or POST
Success Returns
Text
Failure Returns
Text
Form Values:
Name
Value
action
create
add
Submit
username
The Reseller's username. 4-8 characters, alphanumeric
email
A valid email address
passwd
The admins password. 5+ characters, ascii
passwd2
Password double check. 5+ characters, ascii
domain
A valid domain name in the form: domain.com
package
One of the Reseller packages created by an admin
ip
shared, sharedreseller or assign. If shared, domain will use the server's main ip. assign will use one of the reseller's ips. sharedreseller will set the resellers ip to shared and assign the reseller to it.
notify
yes or no. If yes, an email will be sent to email
Create Custom Reseller:
Function
To create a new reseller account without the need for a reseller package
Command
CMD_ACCOUNT_RESELLER
Method
GET or POST
Success Returns
Text
Failure Returns
Text
Form Values:
Name
Value
action
create
add
Submit
username
The Reseller's username. 4-8 characters, alphanumeric
email
A valid email address
passwd
The admins password. 5+ characters, ascii
passwd2
Password double check. 5+ characters, ascii
domain
A valid domain name in the form: domain.com
bandwidth
Amount of bandwidth Reseller will be allowed to use. Number, in Megabytes
ubandwidth
ON or OFF. If ON, bandwidth is ignored and no limit is set
quota
Amount of disk space Reseller will be allowed to use. Number, in Megabytes
uquota
ON or OFF. If ON, quota is ignored and no limit is set
vdomains
Number of domains the reseller and his/her User's are allowed to create
uvdomains
ON or OFF. If ON, vdomains is ignored and no limit is set
nsubdomains
Number of subdomains the reseller and his/her User's are allowed to create
unsubdomains
ON or OFF. If ON, nsubdomains is ignored and no limit is set
ips
Number of ips that will be allocated to the Reseller upon account during account
nemails
Number of pop accounts the reseller and his/her User's are allowed to create
unemails
ON or OFF Unlimited option for nemails
nemailf
Number of forwarders the reseller and his/her User's are allowed to create
unemailf
ON or OFF Unlimited option for nemailf
nemailml
Number of mailing lists the reseller and his/her User's are allowed to create
unemailml
ON or OFF Unlimited option for nemailml
nemailr
Number of autoresponders the reseller and his/her User's are allowed to create
unemailr
ON or OFF Unlimited option for nemailr
mysql
Number of MySQL databases the reseller and his/her User's are allowed to create
umysql
ON or OFF Unlimited option for mysql
domainptr
Number of domain pointers the reseller and his/her User's are allowed to create
udomainptr
ON or OFF Unlimited option for domainptr
ftp
Number of ftp accounts the reseller and his/her User's are allowed to create
uftp
ON or OFF Unlimited option for ftp
aftp
ON or OFF If ON, the reseller and his/her users will be able to have anonymous ftp accounts.
php
ON or OFF If ON, the reseller and his/her users will have the ability to run php scripts.
cgi
ON or OFF If ON, the reseller and his/her users will have the ability to run cgi scripts in their cgi-bins.
ssl
ON or OFF If ON, the reseller and his/her users will have the ability to access their websites through secure https://.
ssh
ON or OFF If ON, the reseller will be have an ssh account.
userssh
ON or OFF If ON, the reseller will be allowed to create ssh accounts for his/her users.
dnscontrol
ON or OFF If ON, the reseller will be able to modify his/her dns records and to create users with or without this option.
dns
OFF or TWO or THREE. If OFF, no dns's will be created. TWO: domain ip for ns1 and another ip for ns2. THREE: domain has own ip. ns1 and ns2 have their own ips
serverip
ON or OFF If ON, the reseller will have the ability to create users using the servers main ip.
ip
shared or assign. If shared, domain will use the server's main ip. assign will use one of the reseller's ips
notify
yes or no. If yes, an email will be sent to email
Create Reseller:
Function
To create a new reseller account. Exactly the same as CMD_ACCOUNT_RESELLER except return value
Command
CMD_API_ACCOUNT_RESELLER
Method
GET or POST
Success Returns
error=0&text=text&details=details
Failure Returns
error=1&text=text&details=details
Create User:
Function
To create a new user account using a pre-made package
Command
CMD_API_ACCOUNT_USER
Method
GET or POST
Success Returns
Text
Failure Returns
Text
Form Values:
Name
Value
action
create
add
Submit
username
The User's username. 4-8 characters, alphanumeric
email
A valid email address
passwd
The User's password. 5+ characters, ascii
passwd2
Password double check. 5+ characters, ascii
domain
A valid domain name in the form: domain.com
package
One of the User packages created by the Reseller
ip
One of the ips which is available for user creation. Only free or shared ips are allowed.
notify
yes or no. If yes, an email will be sent to email
Create Custom User:
Function
To create a new user account without the need for a user package
Command
CMD_API_ACCOUNT_USER
Method
GET or POST
Success Returns
Text
Failure Returns
Text
Form Values:
Name
Value
action
create
add
Submit
username
The Users's username. 4-8 characters, alphanumeric
email
A valid email address
passwd
The User's password. 5+ characters, ascii
passwd2
Password double check. 5+ characters, ascii
domain
A valid domain name in the form: domain.com
bandwidth
Amount of bandwidth User will be allowed to use. Number, in Megabytes
ubandwidth
ON or OFF. If ON, bandwidth is ignored and no limit is set
quota
Amount of disk space User will be allowed to use. Number, in Megabytes
uquota
ON or OFF. If ON, quota is ignored and no limit is set
inode
Inode limit for the User Number, positive integer
uinode
ON or OFF. If ON, inode is ignored and no limit is set
vdomains
Number of domains the User will be allowed to create
uvdomains
ON or OFF. If ON, vdomains is ignored and no limit is set
nsubdomains
Number of subdomains the User will be allowed to create
unsubdomains
ON or OFF. If ON, nsubdomains is ignored and no limit is set
nemails
Number of pop accounts the User will be allowed to create
unemails
ON or OFF Unlimited option for nemails
nemailf
Number of forwarders the User will be allowed to create
unemailf
ON or OFF Unlimited option for nemailf
nemailml
Number of mailing lists the User will be allowed to create
unemailml
ON or OFF Unlimited option for nemailml
nemailr
Number of autoresponders the User will be allowed to create
unemailr
ON or OFF Unlimited option for nemailr
mysql
Number of MySQL databases the User will be allowed to create
umysql
ON or OFF Unlimited option for mysql
domainptr
Number of domain pointers the User will be allowed to create
udomainptr
ON or OFF Unlimited option for domainptr
ftp
Number of ftp accounts the User will be allowed to create
uftp
ON or OFF Unlimited option for ftp
aftp
ON or OFF If ON, the User will be able to have anonymous ftp accounts.
cgi
ON or OFF If ON, the User will have the ability to run cgi scripts in their cgi-bin.
php
ON or OFF If ON, the User will have the ability to run php scripts.
spam
ON or OFF If ON, the User will have the ability to run scan email with SpamAssassin.
cron
ON or OFF If ON, the User will have the ability to creat cronjobs.
catchall
ON or OFF If ON, the User will have the ability to enable and customize a catch-all email (*@domain.com).
ssl
ON or OFF If ON, the User will have the ability to access their websites through secure https://.
ssh
ON or OFF If ON, the User will have an ssh account.
sysinfo
ON or OFF If ON, the User will have access to a page that shows the system information.
login_keys
ON or OFF If ON, the User will have access to the Login Key system for extra account passwords.
dnscontrol
ON or OFF If ON, the User will be able to modify his/her dns records.
suspend_at_limit
ON or OFF If ON, the User will be suspended if their User bandwidth limit is exceeded.
skin
evolution or enhanced, etc. The skin the User will use (optional).
language
en or other if installed. The language the User will use (optional).
ip
One of the ips which is available for user creation. Only free or shared ips are allowed. See "Getting List of IPs and IP info" for the list of ips allowed here
notify
yes or no. If yes, an email will be sent to email
Create User:
Function
To create a new User account. Exactly the same as CMD_ACCOUNT_USER except return value
To get the list of IPs currently owned by this reseller. If value ip is passed, information about that IP is returned instead
Command
CMD_API_SHOW_RESELLER_IPS
Method
GET or POST
Success Returns
url encoded array in list[] OR url encoded string
Failure Returns
error=1
Form Values:
Name
Value
( ip )
Optional. If passed, info about the ip is generated. If not, the list of IPs is generated in the list[]. Information includes: ns: if a nameserver is on this ip, it will be listed here, reseller: if allocated to a reseller, their username will be here , status: "server" (server's ip) "owned" or "free", value:if owned, the user who owns it, else the # of users using it
To get the list of Users currently owned by this reseller. If value reseller is passed, the list of Users created by that Reseller will be shown instead
Command
CMD_API_SHOW_USERS
Method
GET or POST
Success Returns
url encoded array in list[]
Failure Returns
error=1
Form Values:
Name
Value
( reseller )
Optional. If passed, the list of Users created by the Reseller identified by reseller will be given. Else, the list of Users created by the Reseller calling the function will be produced
To allow a user to change his/her email for their account. This is their account email and does not modify their ticket/messaging system email
Command
CMD_API_CHANGE_INFO
Method
POST
Success Returns
Location with the users stats screen: CMD_USER_STATS
Form Values:
Name
Value
evalue
A valid email address
domain
Any domain in the users account. Its only purpose it to provide a return link to that domain's stats page
email
Save. Used to determine what value is being saved. With email being passed, DirectAdmin will know its supposed to be saving an email
Save User Email for Ticket/Messaging system:
Function
To allow a user to change his/her email for the message/ticket system. This email address is the one that will be used when tickets or messages are sent back and forth
Command
CMD_API_TICKET
Method
POST
Success Returns
Location of the messaging system: CMD_TICKET
Failure Returns
Text
Form Values:
Name
Value
email
A valid email address
ON
yes or no this is a checkbox to tell the ticket system if it should send an email out for each message.
save
Save. Button for the form (not actually required)
Modify User Settings:
Function
To allow a reseller to update the settings of one of his/her users
Command
CMD_API_MODIFY_USER
Method
POST
Success Returns
Location: CMD_USER_SHOW
Failure Returns
Text
Form Values:
Name
Value
action
customize
user
the username of the User to be modified
bandwidth
Amount of bandwidth User will be allowed to use. Number, in Megabytes
ubandwidth
ON or OFF. If ON, bandwidth is ignored and no limit is set
quota
Amount of disk space User will be allowed to use. Number, in Megabytes
uquota
ON or OFF. If ON, quota is ignored and no limit is set
vdomains
Number of domains the User will be allowed to create
uvdomains
ON or OFF. If ON, vdomains is ignored and no limit is set
nsubdomains
Number of subdomains the User will be allowed to create
unsubdomains
ON or OFF. If ON, nsubdomains is ignored and no limit is set
nemails
Number of pop accounts the User will be allowed to create
unemails
ON or OFF Unlimited option for nemails
nemailf
Number of forwarders the User will be allowed to create
unemailf
ON or OFF Unlimited option for nemailf
nemailml
Number of mailing lists the User will be allowed to create
unemailml
ON or OFF Unlimited option for nemailml
nemailr
Number of autoresponders the User will be allowed to create
unemailr
ON or OFF Unlimited option for nemailr
mysql
Number of MySQL databases the User will be allowed to create
umysql
ON or OFF Unlimited option for mysql
domainptr
Number of domain pointers the User will be allowed to create
udomainptr
ON or OFF Unlimited option for domainptr
ftp
Number of ftp accounts the User will be allowed to create
uftp
ON or OFF Unlimited option for ftp
aftp
ON or OFF If ON, the User will be able to have anonymous ftp accounts.
cgi
ON or OFF If ON, the User will have the ability to run cgi scripts in their cgi-bin.
php
ON or OFF If ON, the User will have the ability to run php scripts.
spam
ON or OFF If ON, the User will have the ability to turn on spamassassin.
cron
ON or OFF If ON, the User will have the ability to run cron jobs
ssl
ON or OFF If ON, the User will have the ability to access their websites through secure https://.
sysinfo
ON or OFF If ON, the User will have the ability to view the system information page.
ssh
ON or OFF If ON, the User will have an ssh account.
dnscontrol
ON or OFF If ON, the User will be able to modify his/her dns records.
skin
Skin name that the user will use. Selected from the Resellers list of skins. If the skin doesn't exist or is invalid, it will not be changed
ns1
Name server 1 that the user will use. Will remove the old one and replace it with this one
ns2
Name server 2 that the user will use. Will remove the old one and replace it with this one
Number of megabytes currently received through the adaptor with units, as returned by 'ifconfig'. eg. 1045.4 Mb
TX
Number of megabytes currently sent through the adaptor with units, as returned by 'ifconfig'. eg. 5345.4 Mb
bandwidth
Number of megabytes sent and recorded by DirectAdmin
quota
Number of megabytes of disk space used by users as recorded by DirectAdmin
disk1
Disk Usage as returned by 'df'. Stored in a colon separated list. eg: /dev/hda6:381139:276138:85323:77%:/ Where data is: Filesystem:1k-blocks:Used:Available:Use%:Mounted on
( disk2 ... )
Repeat of disk1, with one disk# for each partition.
domainptr
Number of domain pointers on the server
ftp
Number of ftp accounts on the server
mysql
Number of databases on the server
nemailf
Number of email forwarders on the server
nemailml
Number of mailing lists on the server
nemailr
Number of autoresponders on the server
nemails
Number of pop accounts on the server
nresellers
Number of resellers on the server
nsubdomains
Number of subdomains on the server
nusers
Number of users on the server
vdomains
Number of virtual domains on the server
Get User Usage:
Function
Retrieve the user's usages
Command
CMD_API_SHOW_USER_USAGE
Method
GET
Success Returns
url encoded array
Failure Returns
error=1
Form Values:
Name
Value
user
Username of the user for which you wish to view the stats
Array Returns Values
Name
Value
bandwidth
Number of megabytes sent by the user
quota
Number of megabytes of disk space used by the user
domainptr
Number of domain pointers used
ftp
Number of ftp accounts used
mysql
Number of databases used
nemailf
Number of email forwarders used
nemailml
Number of mailing lists used
nemailr
Number of autoresponders used
nemails
Number of pop accounts used
nsubdomains
Number of subdomains used
vdomains
Number of virtual domains used
Get User Limits and Configurations:
Function
Retrieve the user's upper limits and settings that defines their account
Command
CMD_API_SHOW_USER_CONFIG
Method
GET
Success Returns
url encoded array
Failure Returns
error=1
Form Values:
Name
Value
user
Username of the user for which you wish to view the stats
Array Returns Values
Name
Value
account
One of ON or OFF. Used to determine the state of an account. Manually suspendig a user will set this to off. Automatic suspensions will not.
additional_bandwidth
Number of extra meg User is allowed to use this month.
aftp
One of ON or OFF. Used to determine if the user can have an anonymous ftp account
catchall
One of ON or OFF. Used to determine if the user can have a catch-all address
cgi
One of ON or OFF. Used to determine if the user can have a cgi-bin
creator
name of the account used to create this user
cron
One of ON or OFF. Used to determine if the user can have cronjobs
date_created
Date the User was created. May not exist on older accounts.
dnscontrol
One of ON or OFF. Used to determine if the user is allowed to modify their dns records
docsroot
local path (relative to /usr/local/directadmin) to the user's current selected skin
domain
The main domain for the user. Will be the domain included when the account was created
email
The current email account, as set by the user. Note that this may differ from the email set in their messaging system
ip
Current ip assigned to the user
language
Current language assigned to the user
lastquotaupdate
Unix timestamp of when the User click the Update button for their disk usage
login_keys
One of ON or OFF. Used to determine if the user can create Login Keys
ns1 and ns2
Current nameservers assigned to the user
package
Package used to create the user. Will be custom if their settings were modified.
sentwarning
To determine if the usage warning email has already been sent out
skin
Name of the user's current skin
spam
One of ON or OFF. Does the user have access to enable SpamAssassin
ssh
One of ON or OFF. Does the user have ssh
ssl
One of ON or OFF. Does the user have ssl
suspend_at_limit
One of ON or OFF. Will the user be suspended at his bandwidth limit
suspended
One of yes or no. Is the user currently suspended.
sysinfo
One of ON or OFF. Does the user have access to view the System Information page
username
The username of the username.
usertype
One of user, reseller or admin. Type of user account
zoom
Depreciated setting where you can set the permanent ZOOM token. Will set the webpage to be zoomed at this level
bandwidth
Maximum number of megabytes allowed by the user
quota
Maximum megabytes of disk space allowed by the user
domainptr
Number of domain pointers allowed
ftp
Number of ftp accounts allowed
mysql
Number of databases allowed
nemailf
Number of email forwarders allowed
nemailml
Number of mailing lists allowed
nemailr
Number of autoresponders allowed
nemails
Number of pop accounts allowed
nsubdomains
Number of subdomains allowed
vdomains
Number of virtual domains allowed
Get User Domains:
Function
Retrieve the list of domains owned by the user, and some basic stats
Command
CMD_API_SHOW_USER_DOMAINS
Method
GET
Success Returns
url encoded array
Failure Returns
error=1
Form Values:
Name
Value
user
Username of the user for which you wish to view the stats
Array Returns Values
Name
Value
domain.com
Colon speparated list with domain information: eg. 6757.4:unlimited:0.000356674:93.5:2:no:unlimited:ON:ON:ON where the data is bandwidth used:bandwidth limit:disk usage for the domain:log usage for the domain:# of subdomains:suspended:quota:ssl:cgi:php
Used to change an email password without requiring a DirectAdmin account (will not change system email account password)
Command
CMD_CHANGE_EMAIL_PASSWORD
Method
GET or POST
Success Returns
url encoded array if api is passed. Else if redirect is passed, browser will be redirected there. Else a dynamic "success" page is shown.
Failure Returns
url encoded array if api is passed. Else a dynamic "error" page is shown.
Form Values:
Name
Value
email
virtual pop account to be changed. This will not change the main system acccount email
oldpassword
Previous password used for the email account
password1
New password to be used
password2
Re-type the new password to be used
( redirect )
Optional redirect. Upon successful password change, the user will be forwarded here eg."/" or "http://redirect.com/site". This value has no effect if api is passed
( api )
yes (any value will work, only the inclusion of "api=" is checked)
Array Returns Values
Name
Value
error
0 or 1, To determine if it was successful or not
text
some text decribing the result
List Virtual POP Account:
Function
Used to list all of the pop accounts for a domain
Command
CMD_API_POP
Method
GET or POST
Success Returns
url encoded array in list[]
Failure Returns
error=1 and url encoded String
Form Values:
Name
Value
action
list
domain
the domain to be shown eg: domain.com
Create a Virtual POP Account:
Function
Used to create a pop account for a domain
Command
CMD_API_POP
Method
GET or POST
Success Returns
error=0 and url encoded String
Failure Returns
error=1 and url encoded String
Form Values:
Name
Value
action
create
domain
the domain to be shown eg: domain.com
user
email user eg: bob
passwd
the password for the account
passwd2
password confirmation
quota
Integer in Megabytes. Zero for unlimited, 1+ for number of Megabytes.
limit
Send Limit. Zero for unlimited. Blank defaults to the system's default.
When called by an Admin, CMD_API_USER_EXISTS will return exists=1 or exists=0 if the account exists for any account type (Admin, Reseller, or User). error=1|0 is also returned. If error=1, then text= will be set to the reason for the error.
We get many emails about how to run certain commands that are run with a browser, to be run through the API.
For most cases, the API command does already exist. Searching the Versions Systemopen in new window is the best place to start with regards to that.
However, not all cases have specific CMD_API documentation.
Since the CMD_API_X commands are almost always exactly the same as the CMD_X commands (minus the command name and output), the simplest way to figure out what variables you need to pass would be to run DA in debug mode and use the very last:
|grep string
The | grep string option will filter the large amounts of debug output and only show you what variables are being passed.
Once DA is running in debug mode with the | grep string option, you can then go into your browser, log in to DA and submit the function of DA that you'd like to use in your API. After you post the command you're looking for, you'll notice output in your console that has variables. These are the variables that you'll need for the CMD_API_X version of the CMD_X command you just ran.
Take these variables, add them into your API script, and see if it works.
If you're trying to post some data to DirectAdmin with the API, but are not getting the desired results, rather than trying to figure out what's wrong with your script, it's usually easier to be shown what you're passing and what should be passed.
To do this, run DirectAdmin in debug mode, with the | grep string option. This will show you what's being passed.
Then test the function you want with your browser normally through DA (without your script). The posted data will be shown in the debug output. Log the POST parameters passed and their syntax so that you may emulate this data in your own script as desired.
Lastly, test the function using your API script. Again, the data being passed will be shown. Compare the output generated from your script with the output generated from the browser. Adjust your script to match, and it should work.
If an external site should redirect the client to DirectAdmin, but you don't want the account to enter a user/pass for this redirection, you can create a hidden form, and use JavaScript to submit it automatically.
A sample auto-submission form, to be generated in a temporary HTML code:
As you may have noticed, the plain-text password is set in the form, so it might be more secure to leave the value blank, and try and set the value via ajax, or some dynamic option, and/or specify that this page must not be cached by the browser so it cannot be retrieved from disk later on.
A better option would be to preset a short-term use Login Keys, just for this client's IP address. It would expire after a certain amount of time, and only allow this client's IP to login with it. Much more secure.
Use the created Login Key for the password, along with this account's usual username (not the login key name).
# How to create an account when only the crypted password is known
This is useful when creating an account with an API, for a restore, when the plain-text password is not known, for example.
When creating a User with one of the following commands:
This PHP code could be used to decode the url encoded output from the legacy endpoint. Please note that you can always use the '?json=yes' parameter to force the backend to respond with json.