Skip to main content

Error Response Format

All API errors follow this consistent format:

HTTP Status Codes

2xx Success

200 OK

Request succeeded (GET, PATCH, DELETE operations).

201 Created

Resource created successfully (POST operations).

4xx Client Errors

400 Bad Request

Causes:
  • Invalid request body
  • Validation errors
  • Unsupported payment provider
  • Invalid currency
Example:
Fix:
  • Check request body matches the API specification
  • Ensure all required fields are provided
  • Validate field types and formats
  • Use supported currencies (USDT, LKR)

401 Unauthorized

Causes:
  • Invalid API key
  • Expired or revoked API key
  • Invalid HMAC signature
  • Timestamp outside valid window (±5 minutes)
  • Missing authentication headers
Example - Invalid Signature:
Fix:
  1. Verify API key is correct and active
  2. Check signature calculation:
  3. Ensure timestamp is current (within 5 minutes)
  4. Verify method is uppercase (GET, POST, PATCH, DELETE)
  5. Include query parameters in path if any
Example - Timestamp Error:
Fix:
  • Use current timestamp: Date.now().toString()
  • Check server clock is synchronized (use NTP)
  • Don’t reuse old timestamps

403 Forbidden

Causes:
  • Accessing resources belonging to another merchant
  • Insufficient permissions
  • Branch access denied
Example:
Fix:
  • Ensure you’re requesting your own resources
  • Check merchantId in request matches your account
  • Verify branch access if using branch-specific endpoints

404 Not Found

Causes:
  • Resource doesn’t exist
  • Invalid resource ID
  • Typo in endpoint URL
Example:
Fix:
  • Verify resource ID is correct
  • Check resource hasn’t been deleted
  • Ensure endpoint URL is correct

409 Conflict

Causes:
  • Duplicate resource
  • Resource state conflict
  • Payment link slug already exists
Example:
Fix:
  • Use a different slug/identifier
  • Check if resource already exists
  • Handle conflict in your application logic

410 Gone

Causes:
  • Payment link expired
  • Single-use payment link already consumed
  • Resource permanently deleted
Example:
Fix:
  • Create a new payment link
  • Check expiration dates before use
  • Don’t reuse single-use payment links

422 Unprocessable Entity

Causes:
  • Business logic validation failed
  • Invalid amount (negative, zero, or too large)
  • Custom amount not allowed
  • Amount outside min/max range
Example:
Fix:
  • Review business validation rules
  • Check amount constraints
  • Verify custom amount settings

429 Too Many Requests

Causes:
  • Rate limit exceeded for endpoint
  • Too many requests in time window
Example:
Headers:
Fix:
  • Wait for the time specified in retryAfter
  • Implement exponential backoff
  • Cache responses where appropriate
  • Review rate-limits.md for limits per endpoint

5xx Server Errors

500 Internal Server Error

Causes:
  • Unexpected server error
  • Database connection issue
  • Service temporarily unavailable
Example:
Fix:
  • Retry the request with exponential backoff
  • Check status.ceypay.io for service status
  • Contact support if error persists

502 Bad Gateway

Causes:
  • Payment provider (Bybit) API failure
  • Upstream service unavailable
  • Network timeout
Example:
Fix:
  • Retry the request after a short delay
  • Check payment provider status
  • Contact support if issue persists

Common Error Scenarios

Validation Errors

How to handle:

Authentication Errors

Rate Limit Handling

Network Error Handling

Error Handling Best Practices

1. Always Handle Errors

2. Implement Retry Logic

3. Log Errors with Context

4. Provide User-Friendly Messages

5. Monitor Error Rates

Getting Help

If you encounter persistent errors:
  1. Check System Status: status.ceypay.io
  2. Review Documentation: Ensure you’re following the API specification
  3. Enable Debug Logging: Log requests, responses, and signatures
  4. Contact Support: support@ceypay.io with:
    • Error message and status code
    • Request details (endpoint, timestamp, signature)
    • Steps to reproduce
    • Logs (remove sensitive data!)