Skip to main content

Error Response Schema

The Summer Notes API uses consistent error response formats and HTTP status codes to help you understand and handle errors effectively.

Standard Error Format

All error responses follow this consistent structure:

HTTP Status Codes

The API uses standard HTTP status codes to indicate the success or failure of requests:

200 - Success

  • Description: Request completed successfully
  • Usage: All successful GET, POST, PUT, and PATCH operations
  • Response: Contains the requested data or updated object

400 - Bad Request

  • Description: Invalid request due to client error
  • Common Causes:
    • Missing required fields
    • Invalid field values
    • Malformed JSON
    • Invalid enum values

404 - Not Found

  • Description: Requested resource does not exist
  • Common Causes:
    • Note ID not found
    • Invalid endpoint URL

500 - Internal Server Error

  • Description: Server encountered an unexpected error
  • Common Causes:
    • Database connection issues
    • Server configuration problems
    • Unexpected application errors

Common Error Examples

Missing Required Fields

Occurs when: Creating a note without providing all required fields

Invalid Category Value

Occurs when: Providing an invalid category value

Invalid Group Value

Occurs when: Providing an invalid group value

Invalid Color Value

Occurs when: Providing an invalid color value

Note Not Found

Occurs when: Trying to access, update, or archive a non-existent note

ID Mismatch

Occurs when: The ID in the request body doesn’t match the URL parameter

Already Archived

Occurs when: Trying to archive a note that’s already archived

Not Archived

Occurs when: Trying to unarchive a note that’s not archived

Malformed JSON

Occurs when: Request body contains invalid JSON syntax

Empty Fields

Occurs when: Required string fields are empty or whitespace-only

Error Handling Best Practices

JavaScript Example

Python Example

Debugging Tips

  1. Check HTTP Status Code: Always check the status code first to understand the type of error
  2. Read Error Messages: Error messages are descriptive and indicate exactly what went wrong
  3. Validate Input: Ensure all required fields are provided and use valid enum values
  4. Handle Network Errors: Implement proper error handling for network connectivity issues
  5. Log Errors: Log error responses for debugging and monitoring purposes