# Rentals

A rental is a directory plus a row. The lifecycle has been `inactive`, `active`, and `expired` since version 0.7.0. There is no background sweeper. The lease clock starts when the rental is enabled.

`create` makes an `inactive` rental. `expires_at` stays null until enable. Enable sets `expires_at` to `enabled_at` plus `duration_seconds` from create. `duration_seconds` is required and must be within that client's `max_duration_seconds`.

Enable succeeds only when the stored status is `inactive`. Enable of any other stored status is 409. Disable accepts `active`, including a rental the owner sees as `expired`, and returns it to `inactive` with a null lease. Revive extends an `active` rental, including one the owner sees as `expired`. An `inactive` rental is 409. A non-positive extension is 400.

Lock holds the clock on an active rental and refuses purge while set. While `locked` is true, the owner status stays `active` even past `expires_at`, and public downloads keep working. Unlock does not add time. If `expires_at` is already past, public downloads become 404 and lock cannot be taken again. A locked rental's uploaded bytes still count toward storage until the row is deleted. Lock has been available since version 0.6.0.

Purge deletes the directory and the row for an unlocked `inactive` or `expired` rental. `active` or locked is 409. Those bytes stop counting toward the key and the host. `goff purge` and `DELETE /api/rentals/{id}` are that operation. `goff purge --expired` deletes every rental the key lists as `expired`.

Uploads are accepted while the rental row exists, including after enable and after the owner sees the rental as `expired`. A same-size replace is a 0 ledger delta. The upload streams to `{data_dir}/upload-tmp/{uuid}` and renames onto the destination only after the body is accepted, so a rejected `PUT` leaves the previous file and `uploaded_bytes` unchanged. That temp path has been outside the rental since version 0.10.0.

The owner commands are on the [CLI](/cli/) page. The HTTP shapes are on the [HTTP API](/features/api/) page.

