Error Handling
The PayRequest API uses conventional HTTP response codes and returns detailed error messages to help you diagnose issues quickly.HTTP Status Codes
| Code | Meaning | Description |
|---|---|---|
200 | OK | Request succeeded |
201 | Created | Resource created successfully |
400 | Bad Request | Invalid request parameters or body |
401 | Unauthorized | Missing or invalid authentication |
403 | Forbidden | Valid auth but insufficient permissions |
404 | Not Found | Resource doesnβt exist or doesnβt belong to you |
422 | Unprocessable Entity | Validation errors |
429 | Too Many Requests | Rate limit exceeded |
500 | Internal Server Error | Something went wrong on our end |
Error Response Format
All error responses follow this structure:| Field | Type | Description |
|---|---|---|
success | boolean | Always false for errors |
error | string | General error description |
errors | object | Field-specific validation errors (optional) |
Common Errors
Authentication Errors
401 - Unauthenticated
401 - Unauthenticated
Cause: Missing, invalid, or expired access token.Solutions:
- Ensure youβre including the
Authorizationheader - Check that your token starts with
Bearer - Generate a new token if expired
403 - Insufficient Scope
403 - Insufficient Scope
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
422 - Validation Failed
422 - Validation Failed
Cause: Request body failed validation rules.Solutions:
- Check each field in the
errorsobject - Ensure required fields are provided
- Verify data types and formats match the documentation
Resource Errors
404 - Not Found
404 - Not Found
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
400 - Bad Request
400 - Bad Request
Cause: Business logic prevented the action.Solutions:
- Check the current state of the resource
- Review the error message for specific guidance
Rate Limiting
429 - Rate Limited
429 - Rate Limited
Cause: Too many requests in a short period.Headers included:Solutions:
- Implement exponential backoff
- Cache responses where possible
- Wait until
X-RateLimit-Resettimestamp
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:- Check this documentation for the endpoint requirements
- Verify your token has the correct scopes
- Test with a minimal request body
- Contact [email protected] with:
- The endpoint youβre calling
- Your request (without the token)
- The error response
- Your account email