Updates existing content. This endpoint requires admin authentication and accepts multipart/form-data for optional file updates.
This endpoint requires admin authentication. Include a valid JWT token in the Authorization header: Bearer <token>
Path Parameters
The unique identifier of the content to update
Bearer token for admin authentication
Must be multipart/form-data
Request Body (multipart/form-data)
Content type. Must be one of: pdf, video, audio
Content price (minimum: 0)
Optional new content file to replace the existing one
Optional new thumbnail image to replace the existing one
Content status. Must be one of: draft, published
JSON stringified array of tags. Example: ["javascript", "advanced"]
Response
Updated content object Unique identifier for the content
Content type: pdf, video, or audio
Cloudinary URL to the file
Cloudinary public ID for the file
Cloudinary URL to the thumbnail image
Cloudinary public ID for the thumbnail
Duration in seconds (for video/audio content)
Creator information with name and email
Error Responses
404 Not Found
{
"error" : "Content not found"
}
401 Unauthorized
Returned when authentication token is missing or invalid.
403 Forbidden
Returned when the authenticated user is not an admin.
500 Internal Server Error
{
"error" : "Error message"
}
When uploading a new file or thumbnail, the old file is automatically deleted from Cloudinary. The resource type for deletion is determined by the content type (pdf uses ‘image’, while video and audio use ‘video’ resource type).
You can update text fields without uploading new files. Only include file fields when you want to replace existing files.
{
"message" : "Content updated successfully" ,
"content" : {
"_id" : "507f1f77bcf86cd799439011" ,
"title" : "Advanced JavaScript Patterns - Updated" ,
"description" : "Learn advanced design patterns in JavaScript with new examples" ,
"type" : "pdf" ,
"category" : "507f1f77bcf86cd799439012" ,
"price" : 34.99 ,
"fileUrl" : "https://res.cloudinary.com/example/raw/upload/v1234567890/content.pdf" ,
"filePublicId" : "vaniyk/content/abc123" ,
"thumbnailUrl" : "https://res.cloudinary.com/example/image/upload/v1234567890/thumbnail.jpg" ,
"thumbnailPublicId" : "vaniyk/thumbnails/xyz789" ,
"fileSize" : 5242880 ,
"status" : "published" ,
"tags" : [ "javascript" , "patterns" , "advanced" , "updated" ],
"createdBy" : {
"_id" : "507f1f77bcf86cd799439013" ,
"name" : "John Doe" ,
"email" : "[email protected] "
},
"createdAt" : "2024-03-01T12:00:00.000Z" ,
"updatedAt" : "2024-03-03T15:30:00.000Z"
}
}