---
title: "Change a subdomain or addon domain document root"
method: GET
path: "/SubDomain/changedocroot"
tags: ["Subdomains"]
---

# Change a subdomain or addon domain document root

`GET /SubDomain/changedocroot`

This function changes the document root for a subdomain or addon domain
that the calling cPanel user owns.

**Important:**

- This function does **not** apply to the account's primary domain.
  Use the WHM API `set_primary_domain_docroot` function to change the document root for a primary domain.
- The target directory must already exist before you call this function.
  The function does not create it.
- This function does **not** move any files. You must ensure that the files
  exist in the new path when you call this function.
- Any parked domains (`ServerAlias` entries) on the affected domain will
  inherit the new document root.
- AutoSSL HTTP-01 renewals will fail if the new document root is empty
  or missing at renewal time.
- To revert a document root change, call this function again with the
  original path.

When you disable the [Web Server role](https://go.cpanel.net/serverroles#roles),
the system **disables** this function.

## Query parameters

- `docroot` string, path, required
- `domain` string, domain, required

## Response `200`

HTTP Request was successful.

- object
  - `data` object
    - `documentroot` string — The absolute path of the new document root.
  - `errors` string[]
  - `messages` string[]
  - `metadata` object
    - `transformed` integer
  - `status` 0 | 1 — * `1` — Success. * `0` — Failed. Check the `errors` field for more details.
  - `warnings` string[]

---

[API](https://skmtc.net/cpanel/apis/cpanel-uapi.md) · [All operations](https://skmtc.net/cpanel/apis/cpanel-uapi/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/cpanel/cpanel-uapi/versions/632e2f8e6d04/schema)
