> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openinary.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Rename File or Folder

> Rename a file or folder in place, without changing its parent location

## Endpoint

```
PATCH /storage/{path}
```

**Auth:** API Key required

## Path parameters

<ParamField path="path" type="string" required>
  Path to the file or folder relative to the storage root. Use the `id` from [List Storage](/api-reference/storage/list).

  `photo.jpg` · `photos/portrait.jpg` · `photos`
</ParamField>

## Body parameters

<ParamField body="name" type="string" required>
  The new name (not a full path). Must not contain `/` or `\`.
</ParamField>

## Response

```json theme={null}
{
  "success": true,
  "path": "photos/new-name.jpg"
}
```

<ResponseField name="success" type="boolean">
  `true` if the rename succeeded.
</ResponseField>

<ResponseField name="path" type="string">
  The new full path of the file or folder.
</ResponseField>

**Status codes:** `200` success · `400` invalid name · `404` not found · `409` a file or folder with that name already exists · `500` error

## Example

```bash theme={null}
curl -X PATCH http://localhost:3000/storage/photos/portrait.jpg \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"name": "headshot.jpg"}'
```

## Related

<CardGroup cols={2}>
  <Card title="Move File or Folder" icon="folder-tree" href="/api-reference/storage/move">
    Move a file or folder to a different parent folder.
  </Card>

  <Card title="List Storage" icon="folder-open" href="/api-reference/storage/list">
    Browse all files and folders.
  </Card>
</CardGroup>
