Skip to main content

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:

HTTP Status Codes

Success Codes

Client Error Codes

Server Error Codes

Error Types

Authentication Errors

invalid-api-key

Causes:
  • API key is malformed
  • API key has been deleted or revoked
  • Using test key in production or vice versa
Solution: Generate a new API key in your dashboard.

missing-authorization

Solution: Include the Authorization: Bearer pk_live_... header in your request.

Validation Errors

validation-error

Common validation codes:
  • required - Field is required but missing
  • invalid_type - Wrong data type
  • out_of_range - Value outside allowed range
  • invalid_format - Wrong format (e.g., invalid URL)
  • too_long - String exceeds max length

Resource Errors

template-not-found

Causes:
  • Template ID is incorrect
  • Template was deleted
  • Template belongs to a different project

binding-not-found

Rate Limiting

rate-limit-exceeded

Response Headers:
Solution: Wait for the Retry-After duration, then retry. Consider implementing exponential backoff.

Rendering Errors

render-failed

Common causes:
  • Invalid HTML/CSS syntax
  • Missing fonts or assets
  • JavaScript execution timeout
  • Memory limit exceeded

url-fetch-failed

Causes:
  • 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

  1. Validate your HTML with an online validator
  2. Ensure all tags are properly closed
  3. Check for unsupported CSS properties
  4. Test locally in a browser first

Timeout Errors

  1. Reduce page complexity
  2. Optimize images and assets
  3. Use inline styles instead of external CSS
  4. Consider using waitForSelector to wait for specific elements

Memory Errors

  1. Reduce image dimensions
  2. Simplify complex CSS (gradients, shadows)
  3. Limit number of DOM elements
  4. Use vector graphics (SVG) where possible

Rate Limit Errors

  1. Implement request queuing
  2. Use batch endpoints for bulk operations
  3. Cache rendered images
  4. Consider upgrading your plan