# Import an existing WordPress site

This function imports an existing WordPress site to your cPanel account.
The import runs in the background, so the function returns as soon as it
queues the task.

  Note:

  - This function has the following prerequisites:
      - The nova-wordpress entitlement.
      - The redirects, wp-toolkit, and mysql features.
  - Because the request carries the source WordPress credentials, use the
    POST method and do not place the source_password or source_user
    keys in the URL query string. The system rejects a request that uses
    another method, or that puts either key in the query string, before it
    reads the credentials, so they cannot leak into access logs, proxy
    logs, or browser history.
  - The background task can still fail after this function returns, for
    example when a feature is revoked in the meantime. Read the outcome
    from the WPX::get_task_progress function.

Endpoint: POST /WPX/import_website
Version: 11.138.0.10
Security: BasicAuth

## Request fields (application/x-www-form-urlencoded):

  - `domain` (string, required)
    The destination domain for the import. The cPanel account must own the domain, and the domain must have its own document root. The system normalizes the value to lowercase.
    Example: "example.com"

  - `overwrite` (integer)
    Whether to overwrite an existing WordPress installation at the
destination.
- 1 - Overwrite.
- 0 - Do not overwrite.
    Enum: 1, 0

  - `password_type` (string)
    The password type supplied in the source_password parameter.
- admin - A WordPress administrator user password.
- application - A service account password for a third-party integration.
    Enum: "admin", "application"

  - `source_password` (string, required)
    The WordPress user's password for the source site.
    Example: "EXAMPLE-PASSWORD-PLACEHOLDER"

  - `source_url` (string, required)
    The URL of the source WordPress site to import.

Note:

- The URL must use the HTTPS scheme.
- The URL must resolve only to publicly routable addresses.
    Example: "https://subdomain.example.net"

  - `source_user` (string, required)
    The WordPress username for the source site.
    Example: "admin_abcd"

## Response 200 fields (application/json):

  - `apiversion` (integer)
    The version of the API.
    Example: 3

  - `func` (string)
    The name of the method called.
    Example: "import_website"

  - `module` (string)
    The name of the module called.
    Example: "WPX"

  - `result` (object)

  - `result.data` (object)
    On the normal start path the object contains the status,
domain, task_id, sse_url, and install_id return
values. When the destination domain already has a
WordPress installation and the overwrite parameter is
not set, the object instead contains the status field
set to collision, plus the domain and
existing_installations fields.

  - `result.data.domain` (string)
    The destination domain, normalized to lowercase.
    Example: "example.com"

  - `result.data.existing_installations` (array)
    The WordPress installations that already exist on the domain. Present only when the status field is collision, and never empty in that case.

  - `result.data.existing_installations.id` (integer)
    The WordPress Toolkit installation id. Pass it to remove_installation.
    Example: 17

  - `result.data.existing_installations.url` (string)
    The site URL of the existing installation. This is an empty string when the system could not determine it.
    Example: "https://example.com"

  - `result.data.install_id` (string)
    The unique correlator for the import run. Pass it to get_task_progress to poll progress with a cPanel API token. Present only when the status field is running.
    Example: "1784237244-988110-12345"

  - `result.data.sse_url` (string)
    The path to the Server-Sent Events stream that reports import progress. This is a path, not a full URL. Resolve it against the cPanel host that served the request. An interactive cPanel session can read this stream, but a cPanel API token cannot. Present only when the status field is running.
    Example: "/sse/UserTasks/00000000_63d7f020927f8f/wpx_install_1784237244-988110-12345.log"

  - `result.data.status` (string)
    The outcome of this call.
- running - The system queued the import task.
  The task_id, sse_url, and install_id fields
  are present.
- collision - The destination domain already has
  a WordPress installation. The existing_installations
  field is present, and the system queued nothing.
    Enum: "running", "collision"

  - `result.data.task_id` (string)
    The queued import task id. Pass it to get_task_status to check whether the task is still queued. Present only when the status field is running.
    Example: "00000000/63d7f020927f8f"

  - `result.errors` (array,null)
    List of errors if the API failed.

  - `result.messages` (array,null)
    List of messages generated by the API.

  - `result.metadata` (object)

  - `result.metadata.transformed` (integer)
    Post-processing may have transformed the data.
    Enum: 1

  - `result.status` (integer)
    - 1 - Success.
- 0 - Failed: Check the errors field for more details.
    Enum: 1, 0

  - `result.warnings` (array,null)
    List of warnings generated by the API. Warnings describe non-critical failures or other problematic conditions noted while running an API.


