Skip to main content

Error Handling

The PayRequest API uses conventional HTTP response codes and returns detailed error messages to help you diagnose issues quickly.

HTTP Status Codes

Error Response Format

All error responses follow this structure:

Common Errors

Authentication Errors

Cause: Missing, invalid, or expired access token.
Solutions:
  • Ensure you’re including the Authorization header
  • Check that your token starts with Bearer
  • Generate a new token if expired
Cause: Your token doesn’t have the required scope.
Solutions:
  • Check which scope the endpoint requires
  • Create a new token with the required scopes
  • Use the Authentication guide for scope details

Validation Errors

Cause: Request body failed validation rules.
Solutions:
  • Check each field in the errors object
  • Ensure required fields are provided
  • Verify data types and formats match the documentation

Resource Errors

Cause: Resource doesn’t exist or doesn’t belong to your account.
Solutions:
  • Verify the resource ID is correct
  • Ensure the resource belongs to your account
  • Check if the resource was deleted
Cause: Business logic prevented the action.
Solutions:
  • Check the current state of the resource
  • Review the error message for specific guidance

Rate Limiting

Cause: Too many requests in a short period.
Headers included:
Solutions:
  • Implement exponential backoff
  • Cache responses where possible
  • Wait until X-RateLimit-Reset timestamp

Best Practices

Implement Proper Error Handling

Retry Strategy

For transient errors (5xx, network issues), implement exponential backoff:

Validate Before Sending

Catch validation issues early:

Getting Help

If you encounter persistent errors:
  1. Check this documentation for the endpoint requirements
  2. Verify your token has the correct scopes
  3. Test with a minimal request body
  4. Contact support@payrequest.io with:
    • The endpoint you’re calling
    • Your request (without the token)
    • The error response
    • Your account email