Error Handling
The Pictify API uses standard HTTP status codes and returns errors in RFC 9457 Problem Details format.Error Response Format
All errors follow this structure:| Field | Description |
|---|---|
type | URI identifying the error type (links to documentation) |
title | Short, human-readable summary |
status | HTTP status code |
detail | Detailed explanation of this specific error |
instance | The API endpoint that generated the error |
errors | Array of field-level errors (for validation errors) |
HTTP Status Codes
Success Codes
| Code | Description |
|---|---|
200 OK | Request succeeded |
201 Created | Resource created successfully |
202 Accepted | Async operation started (batch jobs) |
204 No Content | Success with no response body (DELETE) |
Client Error Codes
| Code | Description |
|---|---|
400 Bad Request | Invalid request syntax or parameters |
401 Unauthorized | Missing or invalid API key |
403 Forbidden | Valid API key but insufficient permissions |
404 Not Found | Resource doesn’t exist |
409 Conflict | Resource state conflict |
422 Unprocessable Entity | Valid syntax but semantic errors |
429 Too Many Requests | Rate limit exceeded |
Server Error Codes
| Code | Description |
|---|---|
500 Internal Server Error | Unexpected server error |
502 Bad Gateway | Upstream service error |
503 Service Unavailable | Temporary overload or maintenance |
504 Gateway Timeout | Upstream service timeout |
Error Types
Authentication Errors
invalid-api-key
- API key is malformed
- API key has been deleted or revoked
- Using test key in production or vice versa
missing-authorization
Authorization: Bearer pk_live_... header in your request.
Validation Errors
validation-error
required- Field is required but missinginvalid_type- Wrong data typeout_of_range- Value outside allowed rangeinvalid_format- Wrong format (e.g., invalid URL)too_long- String exceeds max length
Resource Errors
template-not-found
- Template ID is incorrect
- Template was deleted
- Template belongs to a different project
binding-not-found
Rate Limiting
rate-limit-exceeded
Retry-After duration, then retry. Consider implementing exponential backoff.
Rendering Errors
render-failed
- Invalid HTML/CSS syntax
- Missing fonts or assets
- JavaScript execution timeout
- Memory limit exceeded
url-fetch-failed
- URL is unreachable
- Server returned non-200 status
- Connection timeout
- SSL certificate error
expression-error
Batch Errors
batch-failed
Webhook Errors
webhook-delivery-failed
Error Handling Best Practices
1. Check Status Codes First
2. Implement Retry Logic
3. Log Errors for Debugging
4. Handle Field-Level Errors
Troubleshooting Common Issues
”Invalid HTML” Errors
- Validate your HTML with an online validator
- Ensure all tags are properly closed
- Check for unsupported CSS properties
- Test locally in a browser first
Timeout Errors
- Reduce page complexity
- Optimize images and assets
- Use inline styles instead of external CSS
- Consider using
waitForSelectorto wait for specific elements
Memory Errors
- Reduce image dimensions
- Simplify complex CSS (gradients, shadows)
- Limit number of DOM elements
- Use vector graphics (SVG) where possible
Rate Limit Errors
- Implement request queuing
- Use batch endpoints for bulk operations
- Cache rendered images
- Consider upgrading your plan