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
- 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
- Verify API key is correct and active
- Check signature calculation:
- Ensure timestamp is current (within 5 minutes)
- Verify method is uppercase (GET, POST, PATCH, DELETE)
- Include query parameters in path if any
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- Retry the request after a short delay
- Check payment provider status
- Contact support if issue persists
Common Error Scenarios
Validation Errors
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:- Check System Status: status.ceypay.io
- Review Documentation: Ensure you’re following the API specification
- Enable Debug Logging: Log requests, responses, and signatures
- Contact Support: [email protected] with:
- Error message and status code
- Request details (endpoint, timestamp, signature)
- Steps to reproduce
- Logs (remove sensitive data!)
Related Documentation
- Authentication Guide - HMAC signature implementation
- Webhooks Guide - Webhook integration and errors
- Rate Limits - API rate limiting policies
- Quick Start - Getting started guide