CoreViz
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}/move

Path Parameters

ParameterTypeDescription
mediaIdstringID of the item or folder to move

Request Body

FieldTypeRequiredDescription
destinationPathstringYesltree 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

StatusDescription
400destinationPath missing, destination is a descendant of source, or destination is in a different collection
401Missing or invalid authentication
403No organization access or insufficient role
404Item 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);