Skip to main content

Media Library

The media library lets workspace members upload, organize, and download files. Files are stored in S3-compatible object storage (MinIO). Each workspace has its own isolated library.

note

All media library endpoints require authentication (requireAuth). Access is scoped to workspace members only.


The Library Item Object

{
"id": 1,
"workspace_id": 2,
"uploaded_by": 5,
"uploaded_by_name": "Jane Smith",
"name": "Product Demo.mp4",
"description": "Q1 product walkthrough",
"file_key": "ws-2/550e8400-e29b-41d4-a716-446655440000/demo.mp4",
"file_url": null,
"mime_type": "video/mp4",
"size": 52428800,
"duration": null,
"labels": [
{ "id": 3, "name": "Marketing", "color": "#22c55e" }
],
"created_at": 1711000000,
"updated_at": 1711000000
}
FieldTypeDescription
idintegerUnique item ID
workspace_idintegerOwning workspace
uploaded_byintegerUser ID of the uploader (null if user deleted)
uploaded_by_namestringDisplay name of the uploader
namestringDisplay name of the file
descriptionstringOptional description
file_keystringInternal object storage key
file_urlstring/nullDirect URL (currently null; use download endpoint)
mime_typestringMIME type (application/pdf or video/mp4)
sizeintegerFile size in bytes
durationinteger/nullDuration in seconds for video files
labelsarrayAssigned workspace labels
created_atintegerUnix timestamp
updated_atintegerUnix timestamp

List Library Items

Returns a paginated list of media items for the workspace. Any workspace member can list items.

GET /api/workspaces/:id/library

Query parameters:

ParameterTypeDefaultDescription
searchstringFilter by name (case-insensitive substring match)
labelintegerFilter by label ID
sortstringdateSort field: date, name, or size
orderstringdescSort direction: asc or desc
limitinteger50Max items to return (1–100)
offsetinteger0Pagination offset

Response:

{
"items": [
{
"id": 1,
"name": "Product Demo.mp4",
"mime_type": "video/mp4",
"size": 52428800,
"uploaded_by_name": "Jane Smith",
"labels": [],
"created_at": 1711000000,
"updated_at": 1711000000
}
],
"total": 1
}

Upload a File

Upload a file to the workspace library. Any workspace member can upload. Files are stored in MinIO object storage.

POST /api/workspaces/:id/library

Content-Type: multipart/form-data

FieldTypeRequiredDescription
filefileYesThe file to upload
namestringNoDisplay name (defaults to original filename)
descriptionstringNoOptional description

Accepted formats:

MIME typeExtension
application/pdf.pdf
video/mp4.mp4
warning

Maximum file size is 100 MB. Uploading a file of an unsupported type or exceeding the size limit returns 400.

Response:

{
"item": {
"id": 1,
"name": "Product Demo.mp4",
"mime_type": "video/mp4",
"size": 52428800,
"labels": [],
"created_at": 1711000000,
"updated_at": 1711000000
}
}

Errors:

StatusError
400File is required
500Upload failed: storage service unavailable

This endpoint also fires a library_item.uploaded webhook event.


Get Download URL

Returns a time-limited presigned URL for downloading a library item directly from object storage. Any workspace member can download.

GET /api/workspaces/:id/library/:itemId/download

Response:

{
"url": "https://storage.example.com/nexus-library/ws-2/550e8400.../demo.mp4?X-Amz-Signature=..."
}
note

The presigned URL expires after 15 minutes. Do not cache or share it publicly.


Update a Library Item

Rename an item or update its description. Any workspace member can update.

PATCH /api/workspaces/:id/library/:itemId

Request body:

{
"name": "Updated Demo.mp4",
"description": "Updated Q1 walkthrough"
}
FieldTypeRequiredDescription
namestringNoNew display name (cannot be empty)
descriptionstringNoNew description

Response:

{
"item": {
"id": 1,
"name": "Updated Demo.mp4",
"description": "Updated Q1 walkthrough",
"labels": [...]
}
}

Delete a Library Item

Deletes the item record and removes the underlying file from object storage. Any workspace member can delete.

DELETE /api/workspaces/:id/library/:itemId

Response:

{ "ok": true }

This endpoint also fires a library_item.deleted webhook event.


Assign a Label to an Item

Add a workspace label to a library item. Any workspace member can assign labels.

POST /api/workspaces/:id/library/:itemId/labels

Request body:

{ "labelId": 3 }

Response: the full updated list of labels on the item.

{
"labels": [
{ "id": 3, "name": "Marketing", "color": "#22c55e" }
]
}

Errors:

StatusError
400labelId is required
404Label not found

Remove a Label from an Item

Remove a workspace label from a library item.

DELETE /api/workspaces/:id/library/:itemId/labels/:labelId

Response: the full updated list of labels remaining on the item.

{
"labels": []
}

Retention Policy

Workspace owners can configure an automatic retention policy. When set, library items older than the configured number of days are automatically deleted (including their object storage files) on server startup.

Get Retention Policy

Owner only.

GET /api/workspaces/:id/retention

Response:

{
"media_retention_days": 90
}

media_retention_days is null when no policy is set (items are kept indefinitely).


Update Retention Policy

Owner only.

PATCH /api/workspaces/:id/retention

Request body:

{
"media_retention_days": 30
}
ValueMeaning
7Delete items older than 7 days
30Delete items older than 30 days
60Delete items older than 60 days
90Delete items older than 90 days
180Delete items older than 180 days
365Delete items older than 1 year
nullKeep items indefinitely (no policy)
warning

Only the values listed above are accepted. Any other integer returns 400. Pass null to disable the policy.

Response:

{
"media_retention_days": 30
}

Webhook Events

The media library dispatches the following workspace webhook events:

EventWhen fired
library_item.uploadedAfter a file is successfully uploaded
library_item.deletedAfter an item is deleted

See Webhooks for payload format and signature verification.