# POST /files/{user}/compress

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

UrbeStack release 0.2.35 API operation in the files group.

Create a .zip archive from entries in one directory

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

Supply 1 to 1000 entries that share a parent directory in paths. An invalid list returns 400. To archive the home directory, select its contents. Supply a .zip destination path in to, in a directory that already exists. If the destination exists, the API returns 409.

UrbeStack uses the Linux distribution's zip with the customer's permissions. The archive stores names relative to the shared parent directory, includes directory contents recursively, and preserves symbolic links as links. Compression has a 15-minute time limit.

## As a command

- [urbestack-file-compress](https://urbestack.com/docs/commands/urbestack-file-compress.md): Creates a new .zip archive in a customer's home directory using the distribution's zip under the customer's account.

## Parameters

- `user` (path, Username, required): Username of the customer who owns the home directory. Administrators can specify any customer, and customers can specify only themselves.

## Request body

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

- `paths` (array of HomePath, required): Paths of entries in the same directory.
- `to` (HomePath, required): Path for the new archive, ending in .zip.

## 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/files/alice/compress" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "paths": [
      "text"
    ],
    "to": "text"
  }'
```

Response, 201 Created:

```
{
  "count": 1,
  "file": {
    "inside": true,
    "mode": "text",
    "modified": "text",
    "name": "alice",
    "owner": "text",
    "path": "public_html/index.php",
    "size": 1,
    "target": "https://example.com/new",
    "target_type": "dir",
    "text": true,
    "type": "dir"
  }
}
```

## Errors

- 400: --path is required
- 400: --to is required
- 400: --user is required
- 400: <name> is an administrator: administrators have no home
- 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> may hold at most 1000 paths
- 400: <what> must be a list of at least one path
- 400: <what> must start with /, which is the home
- 400: Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
- 400: Nothing to compress
- 400: Username '<value>' is reserved
- 401: Authentication required
