Skip to main content
This guide covers how to handle errors from the Triqai API, including common error codes, troubleshooting tips, and best practices.

Error Response Format

All error responses follow a consistent structure:

Error Codes

Authentication Errors (401)

Payment Errors (402)

Not Found Errors (404)

Validation Errors (422)

Rate Limit Errors (429)

Rate-limited requests are automatically retried with exponential backoff, so you typically don’t need to handle 429 errors manually.

Server Errors (500)

Automatic Retries

Retries are handled automatically with exponential backoff. You can customize the retry behavior:
Retry behavior:
  • GET and DELETE requests are always retried on transient errors
  • POST requests are only retried when an idempotencyKey is provided
  • The Retry-After header from 429 responses is respected automatically
  • Retried status codes: 429, 500, 503, 504, and network errors
To disable retries entirely:

Complete Error Handling Pattern

Here’s a complete error handling example using typed error classes:
See the error handling reference for the full list of error classes.

Logging and Monitoring

Request Logging

Use built-in debug hooks for observability:
Or wrap calls for custom logging:

Error Tracking

Best Practices

The meta.requestId helps with debugging and support requests.
If errors persist, temporarily stop requests to prevent cascading failures.
Partial results (partial: true) are successes with some failures handle them differently from full failures.
Catch validation errors client-side when possible to reduce failed API calls.
Create error classes that make it easy to check error types and extract details.

Next Steps

API Reference

Complete API documentation with error codes

Rate Limits

Understand and manage rate limits