# POST /foreign/inspect

First published 3 Oct 2026 (release 0.1.0) · Unchanged since publication

UrbeStack release 0.2.35 API operation in the foreign group.

Preview the import of a hosting account archive

- Who may call it: administrator, reseller
- Token scope, any of: users, all
- Answers: 200 OK

Reads metadata from a pkgacct archive or a full backup from the customer's panel on the source server. It returns the report in import without unpacking the archive or creating an account. The report shows the proposed account name, using as if supplied, whether the original login password can be kept, the package matched by the source plan name, and the account owner.

The report lists domains, subdomains, and aliases with their document roots and PHP versions. It covers DNS zones, free and paid certificates, databases and their users, FTP accounts, and cron jobs. It identifies database users MariaDB cannot accept. For each domain, it reports mailboxes, forwarders, filters to restore or skip, autoresponders, and DKIM keys. It also shows the proposed email address for the source account's own mailbox, using default_mailbox as the local part if supplied.

The check identifies account name, domain, and database conflicts, missing PHP versions and services such as MariaDB and FTP, and anything the import would skip or leave behind. It includes the installation commands in the order to run them when software is missing. Blocking conflicts and missing requirements stop an import before it creates the account. The report identifies any databases named in skip_databases.

Administrators and resellers need a token with the users scope. Other roles receive 403. Administrators provide an absolute server path in file. Resellers provide a path starting with /, which represents their home directory, and must own the archive. Reseller paths are limited to 4096 characters and 255 characters per component. The API returns 400 for a missing or invalid file value, including reseller paths with control characters or a .. component.

If supplied, paths must be rewrite or leave. UrbeStack converts default_mailbox to lowercase. It accepts 1 to 64 ASCII letters, digits, periods, underscores, or hyphens, with a letter or digit at each end. Supply skip_databases as a list of up to 100 names as they appear in the archive. Each name must contain 1 to 64 ASCII letters, digits, or underscores. The API returns 400 for an invalid paths or default_mailbox value, or for a malformed skip_databases list or name.

## As a command

- [urbestack-foreign-import](https://urbestack.com/docs/commands/urbestack-foreign-import.md): Imports a hosting account into UrbeStack from a pkgacct archive or a full backup downloaded from the customer's panel on the source server.

## Request body

JSON, the type [ForeignImportRequest](https://urbestack.com/docs/api/types/ForeignImportRequest.md).

- `file` (string, up to 4096 characters, required): Path to the archive. Administrators use an absolute path on the server. Resellers specify the path from the root of their home directory, for example /uploads/cpmove-ana.tar.gz.
- `as` (Username): Username to assign to the imported account. Defaults to the username in the archive.
- `default_mailbox` (string, matching ^[a-z0-9]([a-z0-9._-]{0,62}[a-z0-9])?$): Local part under the main domain for the source account's default mailbox, found at the top of mail/. Defaults to the account's username. If the email address is already in use, the mailbox stays in the home directory and the import report identifies it.
- `paths` (string, one of rewrite, leave): The value rewrite replaces the old home directory path with the new one in .htaccess, .user.ini and php.ini files. The value leave preserves the home directory contents and lists files that reference the old path. Any affected password-protected directory still references a missing password file.
- `skip_databases` (array of string, matching ^[A-Za-z0-9_]{1,64}$): Names of databases to omit from the import, for example to resolve a name conflict on this server. For each omitted database, UrbeStack skips its dump and any database user assigned solely to it. The import check, job log and job result record the omissions.

## Example

Set $API to the base URL and $TOKEN to the token, as the [API overview](https://urbestack.com/docs/api.md) shows.

```
curl -sS -X POST "$API/foreign/inspect" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "as": "alice",
    "default_mailbox": "text",
    "file": "urbestack-panel-20260909T101500Z.json.enc",
    "paths": "rewrite",
    "skip_databases": [
      "text"
    ]
  }'
```

Response, 200 OK:

```
{
  "import": {}
}
```

## Errors

- 400: '<_>' is not a database name
- 400: --archive takes --show, --inspect or --queue, or --file with --job for the import itself
- 400: --file is required
- 400: <_> is set per domain, on the PHP page's Domains tab, never as a server default
- 400: <name> has an owner: move them to the administrator before changing their role
- 400: <name> is an administrator: administrators have no home, so nothing to back up
- 400: <name> is an administrator: administrators have no system account, so no shell
- 400: <user.name> is an administrator: administrators have no home, so no FTP accounts
- 400: <what> climbs out of the home with ..
- 400: <what> has a name over 255 characters
- 400: <what> holds a control character
- 400: <what> is required
- 400: <what> is too long
- 400: <what> must start with /, which is the home
- 400: A new job is queued or running
- 400: A subdomain belongs to the same user as its parent
- 400: A subdomain cannot have a subdomain as its parent
- 400: An administrator has no shell: only a customer has a system account
- 400: Cannot demote or suspend the last active administrator
- 400: Domain name required
- 400: Domain name too long
- 400: Domains belong to users with role 'user'
- 400: Invalid IPv4 address
- 400: Invalid IPv6 address
- 400: Invalid PHP version, expected e.g. 8.2
- 400: Invalid boolean
- 400: Invalid domain name
- 400: Invalid email address
- 400: Invalid id
- 400: Invalid password hash
- 400: Invalid password: 8 to 128 printable characters
- 400: Invalid port
- 400: Invalid role: admin, user or reseller
- 400: Invalid setting key
- 400: Invalid status
- 400: Invalid system password hash
- 400: Invalid template name
- 400: Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
- 400: Job parameters must be an object
- 400: Only a customer has an owner: an administrator or a reseller is the administrator's own
- 400: PHP settings must be an object of setting: value
- 400: Subdomain '<name>' does not sit under '<parent.name>'
- 400: The archive is named by its absolute path on the server
- 400: The second factor can only be turned off here; a user enrols from their own page
- 400: Unknown PHP version '<version>'
- 400: Unknown job type
- 400: Username '<value>' is reserved
- 400: default_mailbox is the local part of an address under the main domain
- 400: file is required
- 400: paths is rewrite or leave
- 400: skip_databases is a list of database names
- 400: skip_databases may name at most 100 databases
- 400: skip_databases names databases as the archive names them
- 401: Authentication required
- 403: Cannot read 
- 403: Insufficient privileges
- 404: Domain '<name>' not found
- 404: No archive at 
- 404: Parent domain '<parent>' not found
- 404: Setting '<key>' not found
- 404: User '<name>' not found
- 404: User '<owner>' not found
- 409: '<alias>' is already a domain here
- 409: '<alias>' is already an alias
- 409: '<name>' is already an alias here
- 409: <login> is the customer's own login
- 409: <msg> Nothing was changed.
- 409: <name> is being imported (job <job_id>): wait for the job
- 409: <name> is being imported already (job <job_id>)
- 409: <name> is on the package <p.name> of the reseller <p.owner>: change the package before the move
- 409: <name> owns <owned> 
- 409: <name> was imported already, as <account>, which is on this server
- 409: <who> and its bandwidth for the month is used up: 
- 409: <who> and its disk is used up: 
- 409: A system account named '<name>' already exists
- 409: Domain '<name>' already exists
- 409: The FTP account <login> exists already
- 409: The package <p.name> allows <limit> 
- 409: User '<name>' already exists
