Skip to main content

Error Handling

The ChainPal API uses conventional HTTP status codes to indicate the success or failure of requests. All error responses follow a consistent JSON structure.

HTTP Status Codes

Error Response Format

All error responses use this structure:

Common Errors

Authentication Errors (401)

Missing API Key
Invalid API Key
Wrong Key Type

Authorization Errors (403)

IP Not Whitelisted

Validation Errors (400)

Missing Required Field
Invalid Email
Amount Below Minimum
Amount Above Maximum
Duplicate Reference
Invalid Reference Format
Unsupported Token/Network
Webhook Secret Required

Not Found Errors (404)

Payment Not Found
Invalid Payment ID Format

Rate Limit Errors (429)

Too Many Requests

Server Errors (500)

Generic Server Error

Handling Errors

Best Practices

  1. Check the success field first
  2. Handle specific status codes
  3. Implement retry logic for transient errors
  4. Log errors for debugging

Validation Rules

Amount Field

  • Must be a positive number
  • Must meet minimum and maximum limits for the currency
  • See Types & Enums for limits

Reference Field

  • Optional (auto-generated if not provided)
  • 12-16 alphanumeric characters
  • Must be unique per merchant

Email Field

  • Must be a valid email format

URL Fields (callbackURL, failureURL)

  • Must be valid URLs
  • Must use HTTPS protocol

Token/Network

  • Must be a supported combination for your country
  • See Types & Enums