# POST /ftp/accounts

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

UrbeStack release 0.2.35 API operation in the files group.

Create an FTP account

- Who may call it: administrator, reseller, customer
- Token scope, any of: files, all
- Answers: 201 Created

Set user to select the customer. The API returns 400 if an administrator omits user or if user identifies an administrator. For other callers, user defaults to the caller's username. The API returns 201 with the new FTP account in account.

The login is <name>@<domain>. The domain must belong to the customer. UrbeStack lowercases name, which must be 1 to 32 characters, start with an ASCII letter or digit, and contain only ASCII letters, digits, dots, hyphens, or underscores. The login must differ from existing FTP logins and the customer's own login. The customer's package may limit the number of FTP accounts. The required password must contain 8 to 128 printable characters. UrbeStack hashes it with SHA512-CRYPT.

The directory path starts with /, which represents the customer's home. UrbeStack normalizes repeated slashes and . components. The API returns 400 for a missing path, a path that lacks the leading / or contains a control character or a .. component, a path over 4096 characters, or a component over 255 characters. UrbeStack creates missing directories with mode 0755 and gives the customer ownership. The FTP account is confined to the selected directory and its contents. ProFTPD can use the new login immediately.

By default, the account has no expiration. To schedule removal, set expires_at to a valid future UTC timestamp in the format 2026-11-04T09:30:00Z. Invalid or nonfuture values return 400. After that time, nightly cleanup removes the FTP account and retains its directory.

## As a command

- [urbestack-ftp-account-add](https://urbestack.com/docs/commands/urbestack-ftp-account-add.md): Creates an FTP account for the customer selected by --user.

## Request body

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

- `directory` (HomePath, required): A path within the customer's home directory, with / representing the home directory itself. The path cannot contain .. components or control characters.
- `domain` (DomainName, required): One of the customer's domains.
- `name` (string, matching ^[A-Za-z0-9][A-Za-z0-9._-]{0,31}$, required): Part of the login before the @, converted to lowercase.
- `password` (string, up to 128 characters, required)
- `expires_at` (string, matching ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$ or null): Future UTC expiration time, such as 2026-11-04T09:30:00Z. The nightly run removes the account after expiration and preserves its directory. Omit this field to create an account with no expiration.
- `user` (Username): Username of the customer for whom an administrator is creating the FTP account.

## 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/ftp/accounts" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "directory": "text",
    "domain": "example.com",
    "expires_at": "2026-09-16T10:15:00Z",
    "name": "alice",
    "password": "Sup3r-Secret-Passphrase",
    "user": "alice"
  }'
```

Response, 201 Created:

```
{
  "account": {
    "created_at": "2026-09-09T10:15:00Z",
    "directory": "text",
    "expires_at": "2026-09-16T10:15:00Z",
    "id": 1,
    "last_login_at": "text",
    "name": "alice",
    "package": "basic",
    "path": "public_html/index.php",
    "user": "alice",
    "user_id": 2
  }
}
```

## Errors

- 400: --<_> is required
- 400: --password-stdin is required: the password comes on standard input
- 400: <name> is an administrator: administrators have no home, so no FTP accounts
- 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: An FTP account name is 1 to 32 lowercase letters, digits, dots, dashes or underscores, before the @
- 400: Domain name required
- 400: Domain name too long
- 400: Invalid domain name
- 400: Invalid password: 8 to 128 printable characters
- 400: Invalid system password hash
- 400: Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
- 400: Username '<value>' is reserved
- 400: expires_at has passed already: <t>
- 400: expires_at is a UTC time spelled as 2026-11-04T09:30:00Z
- 400: expires_at is not a day the calendar has: <t>
- 400: user is required: the customer the account is for
- 401: Authentication required
- 404: User '<user>' not found
- 409: <login> is the customer's own login
- 409: The FTP account <login> exists already
- 409: The package <p.name> allows <limit> 
