---
title: "Rename or move a file"
method: PATCH
path: "/api/v1/files/{fileId}"
tags: ["Files"]
---

# Rename or move a file

`PATCH /api/v1/files/{fileId}`

## Request

- Base URL: `https://app.khotan.com`
- URL: `https://app.khotan.com/api/v1/files/{fileId}`
- Auth: one of:
  - HTTP bearer
  - API key in header `x-api-key`

Renames the file (name) and/or moves it (folderId or folderPath, mutually exclusive; null folderId or path / targets the root). When both a rename and a move are requested they apply in sequence — rename, then move — and a move failure leaves the rename applied. A folderPath creates any missing folders along the path (mkdir -p), matching upload prepare.

## Path parameters

- `fileId` string, required

## Request body

- object
  - `name` string
  - `folderId` string, nullable: Destination folder id; null moves the file to the root.
  - `folderPath` string: Destination folder path; "/" moves the file to the root. Missing folders along the path are created ("mkdir -p" semantics), matching upload prepare.

## Response `200`

The updated file record.

- object
  - `id` string, required
  - `name` string, required
  - `contentUrl` string, required: Stable authenticated API URL for opening the file content. It redirects to a short-lived inline storage URL when the file is ready.
  - `folderId` string, nullable, required: The containing folder's id, or null for the root.
  - `path` string, required: The file's full display path, including the file name. Paths change on rename/move; store ids.
  - `kind` 'archive' | 'audio' | 'document' | 'image' | 'other' | 'pdf' | 'spreadsheet' | 'video', required
  - `extension` string, nullable, required
  - `contentType` string, required
  - `sizeBytes` integer, required
  - `status` 'pending' | 'ready', required
  - `createdAt` string, required
  - `updatedAt` string, required

## Other responses

- `400`: The request was malformed or failed validation.
- `401`: Authentication is missing or invalid.
- `403`: The caller is not permitted to perform this action.
- `404`: The resource was not found.
- `409`: Response.
- `429`: Too many requests; retry after the indicated delay.

---

[API](https://skmtc.dev/khotan/apis/khotan-api.md) - [All operations](https://skmtc.dev/khotan/apis/khotan-api/llms.txt) - [OpenAPI document](https://skmtc.dev/khotan/apis/khotan-api/revisions/90b512a53e42?raw)
