> For the complete documentation index, see [llms.txt](https://docs.blog-api.codewithsadee.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.blog-api.codewithsadee.com/references/models.md).

# Models

## The User object

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"components":{"schemas":{"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"]}}}}
```

## The UserInputRequired object

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"components":{"schemas":{"UserInputRequired":{"type":"object","properties":{"email":{"type":"string","format":"email","description":"User's email address","maxLength":50},"password":{"type":"string","description":"User's password","minLength":8,"writeOnly":true},"role":{"type":"string","enum":["admin","user"],"description":"User role (optional for registration)"}},"required":["email","password"]}}}}
```

## The UserUpdateInput object

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"components":{"schemas":{"UserUpdateInput":{"type":"object","properties":{"username":{"type":"string","description":"User's unique username","maxLength":20},"email":{"type":"string","format":"email","description":"User's unique email address","maxLength":50},"password":{"type":"string","description":"New password (min 8 chars)","minLength":8,"writeOnly":true},"first_name":{"type":"string","description":"User's first name","maxLength":20},"last_name":{"type":"string","description":"User's last name","maxLength":20},"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}}}}}}
```

## The Blog object

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"components":{"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"]}}}}
```

## The BlogInput object

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"components":{"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"]}}}}
```

## The BlogUpdateInput object

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"components":{"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)"}}}}}}
```

## The Comment object

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"components":{"schemas":{"Comment":{"type":"object","properties":{"_id":{"type":"string","format":"objectid","readOnly":true},"blogId":{"type":"string","format":"objectid","description":"ID of the associated blog post"},"userId":{"type":"string","format":"objectid","description":"ID of the user who commented","readOnly":true},"content":{"type":"string","maxLength":1000,"description":"The comment text"},"likesCount":{"type":"integer","default":0,"readOnly":true},"createdAt":{"type":"string","format":"date-time","readOnly":true},"updatedAt":{"type":"string","format":"date-time","readOnly":true}},"required":["blogId","userId","content"]}}}}
```

## The CommentInput object

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"components":{"schemas":{"CommentInput":{"type":"object","properties":{"content":{"type":"string","maxLength":1000,"description":"The comment text"}},"required":["content"]}}}}
```

## The PaginatedUsers object

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"components":{"schemas":{"PaginatedUsers":{"type":"object","properties":{"limit":{"type":"integer"},"offset":{"type":"integer"},"total":{"type":"integer"},"users":{"type":"array","items":{"$ref":"#/components/schemas/User"}}}},"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"]}}}}
```

## The PaginatedBlogs object

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"components":{"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"]}}}}
```

## The AccessTokenResponse object

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"components":{"schemas":{"AccessTokenResponse":{"type":"object","properties":{"accessToken":{"type":"string","description":"JWT Access Token"}}}}}}
```

## The LoginResponse object

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"components":{"schemas":{"LoginResponse":{"allOf":[{"$ref":"#/components/schemas/AccessTokenResponse"},{"type":"object","properties":{"user":{"$ref":"#/components/schemas/User"}}}]},"AccessTokenResponse":{"type":"object","properties":{"accessToken":{"type":"string","description":"JWT Access Token"}}},"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"]}}}}
```

## The ErrorResponse object

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"components":{"schemas":{"ErrorResponse":{"type":"object","properties":{"code":{"type":"string","description":"Application-specific error code"},"message":{"type":"string","description":"Human-readable error message"}},"required":["code","message"]}}}}
```

## The ValidationErrorDetail object

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"components":{"schemas":{"ValidationErrorDetail":{"type":"object","properties":{"type":{"type":"string"},"value":{"type":"string"},"msg":{"type":"string"},"path":{"type":"string"},"location":{"type":"string"}}}}}}
```

## The ValidationErrorResponse object

```json
{"openapi":"3.0.3","info":{"title":"Blog API","version":"1.0.0"},"components":{"schemas":{"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"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
