# Blogs

Blog post management

## Get All Blogs

> Retrieves a paginated list of blogs. Admins see all; users see only 'published'. Sorted by creation date descending.

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"tags":[{"name":"Blogs","description":"Blog post management"}],"servers":[{"url":"https://blog-api.codewithsadee.com/api/v1","description":"API v1 Base Path"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"JWT Access Token obtained via login/register/refresh"}},"parameters":{"LimitParam":{"in":"query","name":"limit","schema":{"type":"integer","minimum":1,"maximum":50,"default":20},"description":"Maximum number of items to return.","required":false},"OffsetParam":{"in":"query","name":"offset","schema":{"type":"integer","minimum":0,"default":0},"description":"Number of items to skip for pagination.","required":false}},"schemas":{"PaginatedBlogs":{"type":"object","properties":{"limit":{"type":"integer"},"offset":{"type":"integer"},"total":{"type":"integer"},"blogs":{"type":"array","items":{"$ref":"#/components/schemas/Blog"}}}},"Blog":{"type":"object","properties":{"_id":{"type":"string","format":"objectid","readOnly":true},"title":{"type":"string","maxLength":180},"slug":{"type":"string","readOnly":true,"description":"URL-friendly identifier, automatically generated"},"content":{"type":"string","description":"HTML content of the blog post"},"banner":{"type":"object","properties":{"url":{"type":"string","format":"url","description":"URL of the banner image","readOnly":true},"width":{"type":"integer","description":"Width of the banner image","readOnly":true},"height":{"type":"integer","description":"Height of the banner image","readOnly":true}}},"author":{"$ref":"#/components/schemas/User","readOnly":true},"viewsCount":{"type":"integer","default":0,"readOnly":true},"likesCount":{"type":"integer","default":0,"readOnly":true},"commentsCount":{"type":"integer","default":0,"readOnly":true},"status":{"type":"string","enum":["draft","published"],"default":"draft"},"publishedAt":{"type":"string","format":"date-time","readOnly":true},"updatedAt":{"type":"string","format":"date-time","readOnly":true}},"required":["title","content","banner","author","status"]},"User":{"type":"object","properties":{"_id":{"type":"string","format":"objectid","description":"Unique identifier for the user","readOnly":true},"username":{"type":"string","description":"User's unique username","maxLength":20},"email":{"type":"string","format":"email","description":"User's unique email address","maxLength":50},"role":{"type":"string","enum":["admin","user"],"description":"User role","readOnly":true,"default":"user"},"firstName":{"type":"string","description":"User's first name","maxLength":20},"lastName":{"type":"string","description":"User's last name","maxLength":20},"socialLinks":{"type":"object","properties":{"website":{"type":"string","format":"url","maxLength":100},"facebook":{"type":"string","format":"url","maxLength":100},"instagram":{"type":"string","format":"url","maxLength":100},"linkedin":{"type":"string","format":"url","maxLength":100},"x":{"type":"string","format":"url","maxLength":100},"youtube":{"type":"string","format":"url","maxLength":100}}},"createdAt":{"type":"string","format":"date-time","description":"Timestamp of user creation","readOnly":true},"updatedAt":{"type":"string","format":"date-time","description":"Timestamp of last user update","readOnly":true}},"required":["username","email","role"]},"ValidationErrorResponse":{"type":"object","properties":{"code":{"type":"string","enum":["ValidationError"]},"errors":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/ValidationErrorDetail"}}},"required":["code","errors"]},"ValidationErrorDetail":{"type":"object","properties":{"type":{"type":"string"},"value":{"type":"string"},"msg":{"type":"string"},"path":{"type":"string"},"location":{"type":"string"}}},"ErrorResponse":{"type":"object","properties":{"code":{"type":"string","description":"Application-specific error code"},"message":{"type":"string","description":"Human-readable error message"}},"required":["code","message"]}},"responses":{"BadRequestValidation":{"description":"Invalid input data provided. See errors object for details.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"Unauthorized":{"description":"Authentication information is missing or invalid (e.g., missing/expired token).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ServerError":{"description":"An unexpected error occurred on the server.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/blogs/":{"get":{"tags":["Blogs"],"summary":"Get All Blogs","description":"Retrieves a paginated list of blogs. Admins see all; users see only 'published'. Sorted by creation date descending.","operationId":"getAllBlogs","parameters":[{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/OffsetParam"}],"responses":{"200":{"description":"A list of blogs.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedBlogs"}}}},"400":{"$ref":"#/components/responses/BadRequestValidation"},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}}}}
```

## Create Blog Post (Admin)

> Creates a new blog post. Requires banner image upload. Admin role required.

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"tags":[{"name":"Blogs","description":"Blog post management"}],"servers":[{"url":"https://blog-api.codewithsadee.com/api/v1","description":"API v1 Base Path"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"JWT Access Token obtained via login/register/refresh"}},"schemas":{"BlogInput":{"type":"object","properties":{"title":{"type":"string","maxLength":180},"content":{"type":"string","description":"HTML content"},"status":{"type":"string","enum":["draft","published"],"default":"draft"},"banner_image":{"type":"string","format":"binary","description":"Banner image file (png/jpg/webp, max 2MB)"}},"required":["title","content","banner_image"]},"Blog":{"type":"object","properties":{"_id":{"type":"string","format":"objectid","readOnly":true},"title":{"type":"string","maxLength":180},"slug":{"type":"string","readOnly":true,"description":"URL-friendly identifier, automatically generated"},"content":{"type":"string","description":"HTML content of the blog post"},"banner":{"type":"object","properties":{"url":{"type":"string","format":"url","description":"URL of the banner image","readOnly":true},"width":{"type":"integer","description":"Width of the banner image","readOnly":true},"height":{"type":"integer","description":"Height of the banner image","readOnly":true}}},"author":{"$ref":"#/components/schemas/User","readOnly":true},"viewsCount":{"type":"integer","default":0,"readOnly":true},"likesCount":{"type":"integer","default":0,"readOnly":true},"commentsCount":{"type":"integer","default":0,"readOnly":true},"status":{"type":"string","enum":["draft","published"],"default":"draft"},"publishedAt":{"type":"string","format":"date-time","readOnly":true},"updatedAt":{"type":"string","format":"date-time","readOnly":true}},"required":["title","content","banner","author","status"]},"User":{"type":"object","properties":{"_id":{"type":"string","format":"objectid","description":"Unique identifier for the user","readOnly":true},"username":{"type":"string","description":"User's unique username","maxLength":20},"email":{"type":"string","format":"email","description":"User's unique email address","maxLength":50},"role":{"type":"string","enum":["admin","user"],"description":"User role","readOnly":true,"default":"user"},"firstName":{"type":"string","description":"User's first name","maxLength":20},"lastName":{"type":"string","description":"User's last name","maxLength":20},"socialLinks":{"type":"object","properties":{"website":{"type":"string","format":"url","maxLength":100},"facebook":{"type":"string","format":"url","maxLength":100},"instagram":{"type":"string","format":"url","maxLength":100},"linkedin":{"type":"string","format":"url","maxLength":100},"x":{"type":"string","format":"url","maxLength":100},"youtube":{"type":"string","format":"url","maxLength":100}}},"createdAt":{"type":"string","format":"date-time","description":"Timestamp of user creation","readOnly":true},"updatedAt":{"type":"string","format":"date-time","description":"Timestamp of last user update","readOnly":true}},"required":["username","email","role"]},"ValidationErrorResponse":{"type":"object","properties":{"code":{"type":"string","enum":["ValidationError"]},"errors":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/ValidationErrorDetail"}}},"required":["code","errors"]},"ValidationErrorDetail":{"type":"object","properties":{"type":{"type":"string"},"value":{"type":"string"},"msg":{"type":"string"},"path":{"type":"string"},"location":{"type":"string"}}},"ErrorResponse":{"type":"object","properties":{"code":{"type":"string","description":"Application-specific error code"},"message":{"type":"string","description":"Human-readable error message"}},"required":["code","message"]}},"responses":{"BadRequestValidation":{"description":"Invalid input data provided. See errors object for details.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"Unauthorized":{"description":"Authentication information is missing or invalid (e.g., missing/expired token).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Forbidden":{"description":"Access denied due to insufficient permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ServerError":{"description":"An unexpected error occurred on the server.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/blogs/":{"post":{"tags":["Blogs"],"summary":"Create Blog Post (Admin)","description":"Creates a new blog post. Requires banner image upload. Admin role required.","operationId":"createBlog","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/BlogInput"},"encoding":{"banner_image":{"contentType":"image/png, image/jpeg, image/webp"}}}}},"responses":{"201":{"description":"Blog post created successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"blog":{"$ref":"#/components/schemas/Blog"}}}}}},"400":{"$ref":"#/components/responses/BadRequestValidation"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"413":{"description":"Uploaded file exceeds size limit.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"$ref":"#/components/responses/ServerError"}}}}}}
```

## Get Blogs by User

> Retrieves a paginated list of blogs by a specific user. Admins see all; users see only 'published'. Sorted by creation date descending.

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"tags":[{"name":"Blogs","description":"Blog post management"}],"servers":[{"url":"https://blog-api.codewithsadee.com/api/v1","description":"API v1 Base Path"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"JWT Access Token obtained via login/register/refresh"}},"parameters":{"UserIdParam":{"in":"path","name":"userId","schema":{"type":"string","format":"objectid"},"required":true,"description":"ID of the user."},"LimitParam":{"in":"query","name":"limit","schema":{"type":"integer","minimum":1,"maximum":50,"default":20},"description":"Maximum number of items to return.","required":false},"OffsetParam":{"in":"query","name":"offset","schema":{"type":"integer","minimum":0,"default":0},"description":"Number of items to skip for pagination.","required":false}},"schemas":{"PaginatedBlogs":{"type":"object","properties":{"limit":{"type":"integer"},"offset":{"type":"integer"},"total":{"type":"integer"},"blogs":{"type":"array","items":{"$ref":"#/components/schemas/Blog"}}}},"Blog":{"type":"object","properties":{"_id":{"type":"string","format":"objectid","readOnly":true},"title":{"type":"string","maxLength":180},"slug":{"type":"string","readOnly":true,"description":"URL-friendly identifier, automatically generated"},"content":{"type":"string","description":"HTML content of the blog post"},"banner":{"type":"object","properties":{"url":{"type":"string","format":"url","description":"URL of the banner image","readOnly":true},"width":{"type":"integer","description":"Width of the banner image","readOnly":true},"height":{"type":"integer","description":"Height of the banner image","readOnly":true}}},"author":{"$ref":"#/components/schemas/User","readOnly":true},"viewsCount":{"type":"integer","default":0,"readOnly":true},"likesCount":{"type":"integer","default":0,"readOnly":true},"commentsCount":{"type":"integer","default":0,"readOnly":true},"status":{"type":"string","enum":["draft","published"],"default":"draft"},"publishedAt":{"type":"string","format":"date-time","readOnly":true},"updatedAt":{"type":"string","format":"date-time","readOnly":true}},"required":["title","content","banner","author","status"]},"User":{"type":"object","properties":{"_id":{"type":"string","format":"objectid","description":"Unique identifier for the user","readOnly":true},"username":{"type":"string","description":"User's unique username","maxLength":20},"email":{"type":"string","format":"email","description":"User's unique email address","maxLength":50},"role":{"type":"string","enum":["admin","user"],"description":"User role","readOnly":true,"default":"user"},"firstName":{"type":"string","description":"User's first name","maxLength":20},"lastName":{"type":"string","description":"User's last name","maxLength":20},"socialLinks":{"type":"object","properties":{"website":{"type":"string","format":"url","maxLength":100},"facebook":{"type":"string","format":"url","maxLength":100},"instagram":{"type":"string","format":"url","maxLength":100},"linkedin":{"type":"string","format":"url","maxLength":100},"x":{"type":"string","format":"url","maxLength":100},"youtube":{"type":"string","format":"url","maxLength":100}}},"createdAt":{"type":"string","format":"date-time","description":"Timestamp of user creation","readOnly":true},"updatedAt":{"type":"string","format":"date-time","description":"Timestamp of last user update","readOnly":true}},"required":["username","email","role"]},"ValidationErrorResponse":{"type":"object","properties":{"code":{"type":"string","enum":["ValidationError"]},"errors":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/ValidationErrorDetail"}}},"required":["code","errors"]},"ValidationErrorDetail":{"type":"object","properties":{"type":{"type":"string"},"value":{"type":"string"},"msg":{"type":"string"},"path":{"type":"string"},"location":{"type":"string"}}},"ErrorResponse":{"type":"object","properties":{"code":{"type":"string","description":"Application-specific error code"},"message":{"type":"string","description":"Human-readable error message"}},"required":["code","message"]}},"responses":{"BadRequestValidation":{"description":"Invalid input data provided. See errors object for details.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"Unauthorized":{"description":"Authentication information is missing or invalid (e.g., missing/expired token).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ServerError":{"description":"An unexpected error occurred on the server.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/blogs/user/{userId}":{"get":{"tags":["Blogs"],"summary":"Get Blogs by User","description":"Retrieves a paginated list of blogs by a specific user. Admins see all; users see only 'published'. Sorted by creation date descending.","operationId":"getBlogsByUser","parameters":[{"$ref":"#/components/parameters/UserIdParam"},{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/OffsetParam"}],"responses":{"200":{"description":"A list of blogs by the specified user.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedBlogs"}}}},"400":{"$ref":"#/components/responses/BadRequestValidation"},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}}}}
```

## Get Blog by Slug

> Retrieves a single blog post by its unique slug. Regular users cannot view 'draft' posts.

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"tags":[{"name":"Blogs","description":"Blog post management"}],"servers":[{"url":"https://blog-api.codewithsadee.com/api/v1","description":"API v1 Base Path"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"JWT Access Token obtained via login/register/refresh"}},"parameters":{"BlogSlugParam":{"in":"path","name":"slug","schema":{"type":"string"},"required":true,"description":"Slug of the blog post."}},"schemas":{"Blog":{"type":"object","properties":{"_id":{"type":"string","format":"objectid","readOnly":true},"title":{"type":"string","maxLength":180},"slug":{"type":"string","readOnly":true,"description":"URL-friendly identifier, automatically generated"},"content":{"type":"string","description":"HTML content of the blog post"},"banner":{"type":"object","properties":{"url":{"type":"string","format":"url","description":"URL of the banner image","readOnly":true},"width":{"type":"integer","description":"Width of the banner image","readOnly":true},"height":{"type":"integer","description":"Height of the banner image","readOnly":true}}},"author":{"$ref":"#/components/schemas/User","readOnly":true},"viewsCount":{"type":"integer","default":0,"readOnly":true},"likesCount":{"type":"integer","default":0,"readOnly":true},"commentsCount":{"type":"integer","default":0,"readOnly":true},"status":{"type":"string","enum":["draft","published"],"default":"draft"},"publishedAt":{"type":"string","format":"date-time","readOnly":true},"updatedAt":{"type":"string","format":"date-time","readOnly":true}},"required":["title","content","banner","author","status"]},"User":{"type":"object","properties":{"_id":{"type":"string","format":"objectid","description":"Unique identifier for the user","readOnly":true},"username":{"type":"string","description":"User's unique username","maxLength":20},"email":{"type":"string","format":"email","description":"User's unique email address","maxLength":50},"role":{"type":"string","enum":["admin","user"],"description":"User role","readOnly":true,"default":"user"},"firstName":{"type":"string","description":"User's first name","maxLength":20},"lastName":{"type":"string","description":"User's last name","maxLength":20},"socialLinks":{"type":"object","properties":{"website":{"type":"string","format":"url","maxLength":100},"facebook":{"type":"string","format":"url","maxLength":100},"instagram":{"type":"string","format":"url","maxLength":100},"linkedin":{"type":"string","format":"url","maxLength":100},"x":{"type":"string","format":"url","maxLength":100},"youtube":{"type":"string","format":"url","maxLength":100}}},"createdAt":{"type":"string","format":"date-time","description":"Timestamp of user creation","readOnly":true},"updatedAt":{"type":"string","format":"date-time","description":"Timestamp of last user update","readOnly":true}},"required":["username","email","role"]},"ValidationErrorResponse":{"type":"object","properties":{"code":{"type":"string","enum":["ValidationError"]},"errors":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/ValidationErrorDetail"}}},"required":["code","errors"]},"ValidationErrorDetail":{"type":"object","properties":{"type":{"type":"string"},"value":{"type":"string"},"msg":{"type":"string"},"path":{"type":"string"},"location":{"type":"string"}}},"ErrorResponse":{"type":"object","properties":{"code":{"type":"string","description":"Application-specific error code"},"message":{"type":"string","description":"Human-readable error message"}},"required":["code","message"]}},"responses":{"BadRequestValidation":{"description":"Invalid input data provided. See errors object for details.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"Unauthorized":{"description":"Authentication information is missing or invalid (e.g., missing/expired token).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Forbidden":{"description":"Access denied due to insufficient permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"NotFound":{"description":"The specified resource was not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ServerError":{"description":"An unexpected error occurred on the server.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/blogs/{slug}":{"get":{"tags":["Blogs"],"summary":"Get Blog by Slug","description":"Retrieves a single blog post by its unique slug. Regular users cannot view 'draft' posts.","operationId":"getBlogBySlug","parameters":[{"$ref":"#/components/parameters/BlogSlugParam"}],"responses":{"200":{"description":"The requested blog post.","content":{"application/json":{"schema":{"type":"object","properties":{"blog":{"$ref":"#/components/schemas/Blog"}}}}}},"400":{"$ref":"#/components/responses/BadRequestValidation"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/ServerError"}}}}}}
```

## Update Blog Post (Admin)

> Updates an existing blog post. Banner update optional. Admin role required (route security).

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"tags":[{"name":"Blogs","description":"Blog post management"}],"servers":[{"url":"https://blog-api.codewithsadee.com/api/v1","description":"API v1 Base Path"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"JWT Access Token obtained via login/register/refresh"}},"parameters":{"BlogIdParam":{"in":"path","name":"blogId","schema":{"type":"string","format":"objectid"},"required":true,"description":"ID of the blog post."}},"schemas":{"BlogUpdateInput":{"type":"object","properties":{"title":{"type":"string","maxLength":180},"content":{"type":"string","description":"HTML content"},"status":{"type":"string","enum":["draft","published"]},"banner_image":{"type":"string","format":"binary","description":"New banner image file (png/jpg/webp, max 2MB)"}}},"Blog":{"type":"object","properties":{"_id":{"type":"string","format":"objectid","readOnly":true},"title":{"type":"string","maxLength":180},"slug":{"type":"string","readOnly":true,"description":"URL-friendly identifier, automatically generated"},"content":{"type":"string","description":"HTML content of the blog post"},"banner":{"type":"object","properties":{"url":{"type":"string","format":"url","description":"URL of the banner image","readOnly":true},"width":{"type":"integer","description":"Width of the banner image","readOnly":true},"height":{"type":"integer","description":"Height of the banner image","readOnly":true}}},"author":{"$ref":"#/components/schemas/User","readOnly":true},"viewsCount":{"type":"integer","default":0,"readOnly":true},"likesCount":{"type":"integer","default":0,"readOnly":true},"commentsCount":{"type":"integer","default":0,"readOnly":true},"status":{"type":"string","enum":["draft","published"],"default":"draft"},"publishedAt":{"type":"string","format":"date-time","readOnly":true},"updatedAt":{"type":"string","format":"date-time","readOnly":true}},"required":["title","content","banner","author","status"]},"User":{"type":"object","properties":{"_id":{"type":"string","format":"objectid","description":"Unique identifier for the user","readOnly":true},"username":{"type":"string","description":"User's unique username","maxLength":20},"email":{"type":"string","format":"email","description":"User's unique email address","maxLength":50},"role":{"type":"string","enum":["admin","user"],"description":"User role","readOnly":true,"default":"user"},"firstName":{"type":"string","description":"User's first name","maxLength":20},"lastName":{"type":"string","description":"User's last name","maxLength":20},"socialLinks":{"type":"object","properties":{"website":{"type":"string","format":"url","maxLength":100},"facebook":{"type":"string","format":"url","maxLength":100},"instagram":{"type":"string","format":"url","maxLength":100},"linkedin":{"type":"string","format":"url","maxLength":100},"x":{"type":"string","format":"url","maxLength":100},"youtube":{"type":"string","format":"url","maxLength":100}}},"createdAt":{"type":"string","format":"date-time","description":"Timestamp of user creation","readOnly":true},"updatedAt":{"type":"string","format":"date-time","description":"Timestamp of last user update","readOnly":true}},"required":["username","email","role"]},"ValidationErrorResponse":{"type":"object","properties":{"code":{"type":"string","enum":["ValidationError"]},"errors":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/ValidationErrorDetail"}}},"required":["code","errors"]},"ValidationErrorDetail":{"type":"object","properties":{"type":{"type":"string"},"value":{"type":"string"},"msg":{"type":"string"},"path":{"type":"string"},"location":{"type":"string"}}},"ErrorResponse":{"type":"object","properties":{"code":{"type":"string","description":"Application-specific error code"},"message":{"type":"string","description":"Human-readable error message"}},"required":["code","message"]}},"responses":{"BadRequestValidation":{"description":"Invalid input data provided. See errors object for details.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"Unauthorized":{"description":"Authentication information is missing or invalid (e.g., missing/expired token).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Forbidden":{"description":"Access denied due to insufficient permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"NotFound":{"description":"The specified resource was not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ServerError":{"description":"An unexpected error occurred on the server.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/blogs/{blogId}":{"put":{"tags":["Blogs"],"summary":"Update Blog Post (Admin)","description":"Updates an existing blog post. Banner update optional. Admin role required (route security).","operationId":"updateBlog","parameters":[{"$ref":"#/components/parameters/BlogIdParam"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/BlogUpdateInput"},"encoding":{"banner_image":{"contentType":"image/png, image/jpeg, image/webp"}}}}},"responses":{"200":{"description":"Blog post updated successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"blog":{"$ref":"#/components/schemas/Blog"}}}}}},"400":{"$ref":"#/components/responses/BadRequestValidation"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"description":"Uploaded file exceeds size limit.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"$ref":"#/components/responses/ServerError"}}}}}}
```

## Delete Blog Post (Admin)

> Deletes a blog post by ID. Also removes banner. Admin role required (route security).

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"tags":[{"name":"Blogs","description":"Blog post management"}],"servers":[{"url":"https://blog-api.codewithsadee.com/api/v1","description":"API v1 Base Path"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"JWT Access Token obtained via login/register/refresh"}},"parameters":{"BlogIdParam":{"in":"path","name":"blogId","schema":{"type":"string","format":"objectid"},"required":true,"description":"ID of the blog post."}},"responses":{"NoContent":{"description":"Request successful, no response body."},"Unauthorized":{"description":"Authentication information is missing or invalid (e.g., missing/expired token).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Forbidden":{"description":"Access denied due to insufficient permissions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"NotFound":{"description":"The specified resource was not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ServerError":{"description":"An unexpected error occurred on the server.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"schemas":{"ErrorResponse":{"type":"object","properties":{"code":{"type":"string","description":"Application-specific error code"},"message":{"type":"string","description":"Human-readable error message"}},"required":["code","message"]}}},"paths":{"/blogs/{blogId}":{"delete":{"tags":["Blogs"],"summary":"Delete Blog Post (Admin)","description":"Deletes a blog post by ID. Also removes banner. Admin role required (route security).","operationId":"deleteBlog","parameters":[{"$ref":"#/components/parameters/BlogIdParam"}],"responses":{"204":{"$ref":"#/components/responses/NoContent"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/ServerError"}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.blog-api.codewithsadee.com/references/blogs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
