Skip to main content
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

contentId
string
required
The unique identifier of the content to update

Request Headers

Authorization
string
required
Bearer token for admin authentication
Content-Type
string
required
Must be multipart/form-data

Request Body (multipart/form-data)

title
string
Content title
description
string
Content description
type
string
Content type. Must be one of: pdf, video, audio
category
string
Category ID
price
number
Content price (minimum: 0)
file
file
Optional new content file to replace the existing one
thumbnail
file
Optional new thumbnail image to replace the existing one
status
string
Content status. Must be one of: draft, published
tags
string
JSON stringified array of tags. Example: ["javascript", "advanced"]

Response

message
string
Success message
content
object
Updated content object

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": "john@example.com"
    },
    "createdAt": "2024-03-01T12:00:00.000Z",
    "updatedAt": "2024-03-03T15:30:00.000Z"
  }
}

Build docs developers (and LLMs) love