📘
Blog API
  • Documentation
  • API References
  • Introduction
  • Authentication
  • Guides
    • Rate Limiting
    • Error Handling
Powered by GitBook

© 2025 codewithsadee

On this page
  • Common Status Codes & Error Codes
  • Error Response Format

Was this helpful?

Export as PDF
  1. Guides

Error Handling

The API uses standard HTTP status codes to indicate the success or failure of a request. Errors generally return a JSON body with code and message fields. Validation errors include an additional errors object.

Common Status Codes & Error Codes

Status Code

code Value(s)

Meaning

200 OK

N/A

Request successful.

201 Created

N/A

Resource created successfully.

204 No Content

N/A

Request successful, no response body needed (e.g., successful deletion).

400 Bad Request

ValidationError

Input validation failed (e.g., missing required field, invalid format). See errors object for details.

400 Bad Request

BadRequest

General bad request (e.g., trying to like an already liked blog).

401 Unauthorized

AuthenticationError

Missing, invalid, or expired accessToken or refreshToken. Check message for specifics.

403 Forbidden

AuthorizationError

User lacks permission (role) for the action, or attempting unauthorized admin registration.

404 Not Found

NotFound

The requested resource (user, blog, comment) could not be found.

413 Payload Too Large

ValidationError

Uploaded file exceeds the size limit (2MB for blog banners).

429 Too Many Requests

N/A

Rate limit exceeded (see Rate Limiting guide).

500 Internal Server Error

ServerError

An unexpected error occurred on the server. Contact support if this persists.

Error Response Format

General Error:

{
  "code": "NotFound",
  "message": "Blog not found"
}

Validation Error:

{
  "code": "ValidationError",
  "errors": {
    "email": {
      "type": "field",
      "value": "invalid-email",
      "msg": "Invalid email address",
      "path": "email",
      "location": "body"
    },
    "password": {
      "type": "field",
      "value": "short",
      "msg": "Password must be at least 8 characters long",
      "path": "password",
      "location": "body"
    }
  }
}
PreviousRate Limiting

Last updated 12 days ago

Was this helpful?