Blogs
Blog post management
Retrieves a paginated list of blogs. Admins see all; users see only 'published'. Sorted by creation date descending.
Maximum number of items to return.
20
Number of items to skip for pagination.
0
A list of blogs.
Invalid input data provided. See errors object for details.
Authentication information is missing or invalid (e.g., missing/expired token).
An unexpected error occurred on the server.
GET /api/v1/blogs/ HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*
{
"limit": 1,
"offset": 1,
"total": 1,
"blogs": [
{
"_id": "text",
"title": "text",
"slug": "text",
"content": "text",
"banner": {
"url": "text",
"width": 1,
"height": 1
},
"author": {
"_id": "text",
"username": "text",
"email": "[email protected]",
"role": "user",
"firstName": "text",
"lastName": "text",
"socialLinks": {
"website": "text",
"facebook": "text",
"instagram": "text",
"linkedin": "text",
"x": "text",
"youtube": "text"
},
"createdAt": "2025-09-14T23:34:52.599Z",
"updatedAt": "2025-09-14T23:34:52.599Z"
},
"viewsCount": 0,
"likesCount": 0,
"commentsCount": 0,
"status": "draft",
"publishedAt": "2025-09-14T23:34:52.599Z",
"updatedAt": "2025-09-14T23:34:52.599Z"
}
]
}
Creates a new blog post. Requires banner image upload. Admin role required.
HTML content
draft
Possible values: Banner image file (png/jpg/webp, max 2MB)
Blog post created successfully.
Invalid input data provided. See errors object for details.
Authentication information is missing or invalid (e.g., missing/expired token).
Access denied due to insufficient permissions.
Uploaded file exceeds size limit.
An unexpected error occurred on the server.
POST /api/v1/blogs/ HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Content-Type: multipart/form-data
Accept: */*
Content-Length: 74
{
"title": "text",
"content": "text",
"status": "draft",
"banner_image": "binary"
}
{
"blog": {
"_id": "text",
"title": "text",
"slug": "text",
"content": "text",
"banner": {
"url": "text",
"width": 1,
"height": 1
},
"author": {
"_id": "text",
"username": "text",
"email": "[email protected]",
"role": "user",
"firstName": "text",
"lastName": "text",
"socialLinks": {
"website": "text",
"facebook": "text",
"instagram": "text",
"linkedin": "text",
"x": "text",
"youtube": "text"
},
"createdAt": "2025-09-14T23:34:52.599Z",
"updatedAt": "2025-09-14T23:34:52.599Z"
},
"viewsCount": 0,
"likesCount": 0,
"commentsCount": 0,
"status": "draft",
"publishedAt": "2025-09-14T23:34:52.599Z",
"updatedAt": "2025-09-14T23:34:52.599Z"
}
}
Retrieves a paginated list of blogs by a specific user. Admins see all; users see only 'published'. Sorted by creation date descending.
ID of the user.
Maximum number of items to return.
20
Number of items to skip for pagination.
0
A list of blogs by the specified user.
Invalid input data provided. See errors object for details.
Authentication information is missing or invalid (e.g., missing/expired token).
An unexpected error occurred on the server.
GET /api/v1/blogs/user/{userId} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*
{
"limit": 1,
"offset": 1,
"total": 1,
"blogs": [
{
"_id": "text",
"title": "text",
"slug": "text",
"content": "text",
"banner": {
"url": "text",
"width": 1,
"height": 1
},
"author": {
"_id": "text",
"username": "text",
"email": "[email protected]",
"role": "user",
"firstName": "text",
"lastName": "text",
"socialLinks": {
"website": "text",
"facebook": "text",
"instagram": "text",
"linkedin": "text",
"x": "text",
"youtube": "text"
},
"createdAt": "2025-09-14T23:34:52.599Z",
"updatedAt": "2025-09-14T23:34:52.599Z"
},
"viewsCount": 0,
"likesCount": 0,
"commentsCount": 0,
"status": "draft",
"publishedAt": "2025-09-14T23:34:52.599Z",
"updatedAt": "2025-09-14T23:34:52.599Z"
}
]
}
Retrieves a single blog post by its unique slug. Regular users cannot view 'draft' posts.
Slug of the blog post.
The requested blog post.
Invalid input data provided. See errors object for details.
Authentication information is missing or invalid (e.g., missing/expired token).
Access denied due to insufficient permissions.
The specified resource was not found.
An unexpected error occurred on the server.
GET /api/v1/blogs/{slug} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*
{
"blog": {
"_id": "text",
"title": "text",
"slug": "text",
"content": "text",
"banner": {
"url": "text",
"width": 1,
"height": 1
},
"author": {
"_id": "text",
"username": "text",
"email": "[email protected]",
"role": "user",
"firstName": "text",
"lastName": "text",
"socialLinks": {
"website": "text",
"facebook": "text",
"instagram": "text",
"linkedin": "text",
"x": "text",
"youtube": "text"
},
"createdAt": "2025-09-14T23:34:52.599Z",
"updatedAt": "2025-09-14T23:34:52.599Z"
},
"viewsCount": 0,
"likesCount": 0,
"commentsCount": 0,
"status": "draft",
"publishedAt": "2025-09-14T23:34:52.599Z",
"updatedAt": "2025-09-14T23:34:52.599Z"
}
}
Updates an existing blog post. Banner update optional. Admin role required (route security).
ID of the blog post.
HTML content
New banner image file (png/jpg/webp, max 2MB)
Blog post updated successfully.
Invalid input data provided. See errors object for details.
Authentication information is missing or invalid (e.g., missing/expired token).
Access denied due to insufficient permissions.
The specified resource was not found.
Uploaded file exceeds size limit.
An unexpected error occurred on the server.
PUT /api/v1/blogs/{blogId} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Content-Type: multipart/form-data
Accept: */*
Content-Length: 74
{
"title": "text",
"content": "text",
"status": "draft",
"banner_image": "binary"
}
{
"blog": {
"_id": "text",
"title": "text",
"slug": "text",
"content": "text",
"banner": {
"url": "text",
"width": 1,
"height": 1
},
"author": {
"_id": "text",
"username": "text",
"email": "[email protected]",
"role": "user",
"firstName": "text",
"lastName": "text",
"socialLinks": {
"website": "text",
"facebook": "text",
"instagram": "text",
"linkedin": "text",
"x": "text",
"youtube": "text"
},
"createdAt": "2025-09-14T23:34:52.599Z",
"updatedAt": "2025-09-14T23:34:52.599Z"
},
"viewsCount": 0,
"likesCount": 0,
"commentsCount": 0,
"status": "draft",
"publishedAt": "2025-09-14T23:34:52.599Z",
"updatedAt": "2025-09-14T23:34:52.599Z"
}
}
Deletes a blog post by ID. Also removes banner. Admin role required (route security).
ID of the blog post.
Request successful, no response body.
No content
Authentication information is missing or invalid (e.g., missing/expired token).
Access denied due to insufficient permissions.
The specified resource was not found.
An unexpected error occurred on the server.
DELETE /api/v1/blogs/{blogId} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*
No content
Was this helpful?