Changing user's main domain via API without losing data - CMD_API_MODIFY_USER doesn't have domain parameter

amoozesh98com

Verified User
Joined
Mar 8, 2015
Messages
19
Hello,

I'm trying to change a user's main domain using the DirectAdmin API, but I can't find the correct endpoint for this. The goal is to change the domain without losing any user data (files, emails, databases, etc.).

What I've tried:

1. CMD_API_MODIFY_USER - This endpoint works for changing settings like bandwidth, quota, packages, etc., but it doesn't have a "domain" parameter in the documentation. I tried adding "domain" anyway but it didn't work.

2. CMD_API_CHANGE_DOMAIN - I get this error:
"you do not own that old_domain"
Even when running as Admin.

3. CMD_API_DOMAIN with action=change - I get this error:
"Called CMD_DOMAIN or CMD_API_DOMAIN without any variables."

4. CMD_API_ACCOUNT_MODIFY - Returns HTTP 405 (Method Not Allowed)

Example of what I'm trying to do:
- User: testuser
- Current domain: olddomain.com
- New domain: newdomain.com
- All data (files, emails, databases) should remain intact

Environment:
- DirectAdmin Version: [your version]
- OS: [your OS]
- PHP: [your version]
- Account: Admin

What I've confirmed:
- The user exists and is active
- The login key has proper permissions
- Other APIs work fine (CMD_API_USER_PASSWD, CMD_API_SHOW_USER_CONFIG, etc.)
- No errors in /var/log/directadmin/error.log

My questions:

1. Is there a specific API endpoint for changing a user's main domain without losing data?
2. If CMD_API_MODIFY_USER doesn't support domain changes, what is the correct method?
3. Is there a specific parameter order or format required for CMD_API_CHANGE_DOMAIN?
4. Could there be a configuration issue on my server that prevents domain changes?

I need to change the domain while keeping all user data intact. Please guide me to the correct API endpoint and parameters.

Thank you for your help.
 
The domain can be renamed only by DA user to whom it is added. "admin" cannot do it, if the domain is not added for him.
The API-call that can be used is:
Code:
curl -s -X POST "$(da api-url --user=[DA_USER])/CMD_CHANGE_DOMAIN?json=yes" -d '{"old_domain":"[OLD_DOMAIN]","new_domain":"[NEW_DOMAIN]","json":"yes"}'
Also "users_can_rename_domains" DA configuration option must be enabled (set to "1"):
Code:
[root@server2 ~]# da config-get users_can_rename_domains
1
[root@server2 ~]#
 
Back
Top