API
Move Media
Move a media item or folder to a different location within the same collection
Move Media
Move a media item or folder to a different destination within the same collection. For folders, all descendants are moved recursively.
Endpoint
PATCH /api/media/{mediaId}/movePath Parameters
| Parameter | Type | Description |
|---|---|---|
mediaId | string | ID of the item or folder to move |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
destinationPath | string | Yes | ltree path of the target folder (e.g. collectionId.targetFolderId) |
Use real paths
Always use path values from GET /api/dataset/{collectionId}/media results — never construct ltree paths manually. The collection ID in the path is the UUID with hyphens stripped.
Constraints
- Cannot move an item into itself or one of its own subfolders
- Destination must be within the same collection
Example Request
curl -X PATCH https://lab.coreviz.io/api/media/MEDIA_ID/move \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "destinationPath": "collectionId.archiveFolderId" }'Response
Status Code: 200 OK
{
"id": "abc123def456",
"newPath": "collectionId.archiveFolderId.abc123def456",
"success": true
}Folder Move
When moving a folder, the route updates the folder and all its descendants in a single SQL operation using ltree <@ and subpath(). The new path for each descendant preserves the subtree structure under the new location.
Error Responses
| Status | Description |
|---|---|
400 | destinationPath missing, destination is a descendant of source, or destination is in a different collection |
401 | Missing or invalid authentication |
403 | No organization access or insufficient role |
404 | Item not found |
JavaScript Example
const result = await fetch('https://lab.coreviz.io/api/media/MEDIA_ID/move', {
method: 'PATCH',
headers: {
'Authorization': 'Bearer YOUR_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({ destinationPath: 'collectionId.archiveFolderId' }),
}).then(r => r.json());
console.log(result.newPath);