Skip to main content
Proper error handling is essential for building robust applications with Notch Pay. This guide explains the key concepts of error handling and best practices for implementing it in your applications.
For detailed error codes, examples, and troubleshooting tips, see the API Errors Reference.

Understanding API Errors

When an error occurs, the Notch Pay API returns:
  1. An appropriate HTTP status code
  2. A JSON response with details about what went wrong

Common Error Categories

Authentication Errors

Status Codes: 401, 403Occur when there’s an issue with your API keys or permissions.Common causes:
  • Missing API key
  • Invalid API key
  • Insufficient permissions
  • Missing required headers

Validation Errors

Status Codes: 400, 422Occur when the request data doesn’t meet the required format or constraints.Common causes:
  • Missing required fields
  • Invalid field formats
  • Values outside allowed ranges
  • Incompatible parameter combinations

Resource Errors

Status Codes: 404, 409Occur when the requested resource doesn’t exist or there’s a conflict.Common causes:
  • Resource not found
  • Resource already exists
  • Resource in incompatible state

System Errors

Status Codes: 429, 500, 503Occur due to rate limiting or server-side issues.Common causes:
  • Rate limit exceeded
  • Server error
  • Service unavailable

Best Practices for Error Handling

1

Always Check for Errors

Don’t assume API requests will always succeed. Check for errors in all API responses.
2

Handle Different Error Types

Implement specific handling for different types of errors.
3

Implement Retry Logic

For transient errors like rate limiting or temporary server issues, implement retry logic with exponential backoff.
4

Provide User-Friendly Messages

Translate technical error messages into user-friendly messages that help users understand what went wrong and how to fix it.

Logging and Monitoring

Always log errors for debugging and monitoring purposes, but be careful not to log sensitive information like card details or API keys.
Implement a robust logging system that captures:
  • Error codes and messages
  • Request IDs for correlation
  • Timestamps
  • Contextual information (without sensitive data)
Regularly review your error logs to identify patterns and improve your integration.

Next Steps