Skip to main content

Error Response Format

The Password Manager API returns errors in a consistent JSON format. All error responses include a message field describing the error and a status field containing the HTTP status code.

Standard Error Structure

Validation Error Structure

When request validation fails, the API returns a more detailed error response that includes a list of validation errors:

HTTP Status Codes

The API uses the following HTTP status codes:
Success
Request completed successfully. The response includes the requested data or confirmation message.
Bad Request
The request contains invalid data or missing required fields. Check the errors object for validation details.
Not Found
The requested resource was not found. This occurs when accessing a password with an invalid ID or when no passwords exist.
Internal Server Error
An unexpected error occurred on the server, typically during database operations.

Common Error Scenarios

Returned when creating a password without required fields.Example Request:
Error Response:
Required Fields:
  • password - The password value
  • sistema - The system identifier
  • usuario - The username associated with the password
Returned when attempting to access, update, or delete a password that doesn’t exist.Example Request:
Error Response:
This error occurs in the following endpoints:
  • GET /api/getPassword/{id} - When password ID doesn’t exist
  • POST /api/updatePassword/{id} - When trying to update non-existent password
  • POST /api/deletePassword/{id} - When trying to delete non-existent password
  • GET /api/listPassword - Returns this when no passwords are found
Returned when a database operation fails during password creation.Example Scenario: Database connection issues or constraint violations during password creation.Error Response:
If you encounter 500 errors consistently, contact your system administrator to check database connectivity and logs.

Error Messages Reference

The following error messages are returned by the API:
All error responses include both a human-readable message and a numeric status field that matches the HTTP status code.

Best Practices

  1. Check Status Codes: Always check the HTTP status code to determine the type of error
  2. Handle Validation Errors: Parse the errors object for field-specific validation messages
  3. Implement Retry Logic: For 500 errors, implement exponential backoff retry logic
  4. Log Errors: Log error responses for debugging and monitoring purposes
  5. User-Friendly Messages: Convert technical error messages to user-friendly descriptions in your application