Overview
The Trix API uses conventional HTTP response codes and returns detailed error information to help you diagnose and fix issues quickly.
Request succeeded. Response contains the requested data.
Request failed due to client-side issue. Check your request.
Request failed due to server issue. Safe to retry.
Error Response Format
All API errors follow a consistent JSON format:
{
"error": {
"code": "error_code",
"message": "Human-readable description of what went wrong",
"details": {
// Optional additional context
},
"request_id": "req_abc123xyz"
}
}| Field | Type | Description |
|---|---|---|
error.code | string | Machine-readable error code for programmatic handling |
error.message | string | Human-readable description suitable for logging |
error.details | object | Additional context (validation errors, limits, etc.) |
error.request_id | string | Unique ID for this request (include in support tickets) |
Always include the request_id when contacting support. It helps us
quickly locate your request in our logs.
HTTP Status Codes
| Status | Meaning | When It Happens |
|---|---|---|
| 200 | OK | Request succeeded |
| 201 | Created | Resource created successfully |
| 204 | No Content | Request succeeded, no response body (e.g., DELETE) |
| 400 | Bad Request | Invalid request body or parameters |
| 401 | Unauthorized | Missing or invalid API key |
| 403 | Forbidden | Valid key but insufficient permissions |
| 404 | Not Found | Resource doesn't exist |
| 409 | Conflict | Resource already exists or conflict with current state |
| 422 | Unprocessable Entity | Validation failed |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Server error (safe to retry) |
| 502 | Bad Gateway | Upstream service unavailable |
| 503 | Service Unavailable | Temporary maintenance or overload |
Error Codes Reference
Authentication Errors
| Code | HTTP | Description | Solution |
|---|---|---|---|
missing_api_key | 401 | No API key provided | Add Authorization: Bearer YOUR_KEY header |
invalid_api_key | 401 | API key is malformed | Check key format starts with gdb_ |
expired_api_key | 401 | API key has expired | Generate a new key with trix keys create |
revoked_api_key | 401 | API key was revoked | Generate a new key |
insufficient_permissions | 403 | Key lacks required permissions | Use a key with appropriate scopes |
Validation Errors
| Code | HTTP | Description | Solution |
|---|---|---|---|
validation_error | 422 | One or more fields failed validation | Check details.fields for specifics |
invalid_json | 400 | Request body is not valid JSON | Validate JSON syntax |
missing_required_field | 422 | Required field not provided | Add the missing field |
invalid_field_type | 422 | Field has wrong type | Use correct type (string, number, etc.) |
field_too_long | 422 | Field exceeds maximum length | Reduce content size |
invalid_enum_value | 422 | Value not in allowed options | Use one of the allowed values |
Resource Errors
| Code | HTTP | Description | Solution |
|---|---|---|---|
memory_not_found | 404 | Memory with given ID doesn't exist | Verify the memory ID |
space_not_found | 404 | Space with given ID doesn't exist | Verify the space ID |
cluster_not_found | 404 | Cluster with given ID doesn't exist | Verify the cluster ID |
relationship_not_found | 404 | Relationship doesn't exist | Verify the relationship ID |
duplicate_memory | 409 | Memory with same content hash exists | Update existing or use different content |
space_already_exists | 409 | Space with same name exists | Use a different name |
Rate Limit Errors
| Code | HTTP | Description | Solution |
|---|---|---|---|
rate_limit_exceeded | 429 | Too many requests per minute | Wait for retry_after seconds |
daily_limit_exceeded | 429 | Daily memory creation limit reached | Wait until midnight UTC or upgrade |
quota_exceeded | 403 | Monthly quota exhausted | Upgrade plan or wait for next cycle |
concurrent_limit_exceeded | 429 | Too many concurrent requests | Reduce parallelism |
Server Errors
| Code | HTTP | Description | Solution |
|---|---|---|---|
internal_error | 500 | Unexpected server error | Retry with backoff, contact support if persists |
embedding_failed | 500 | Failed to generate embeddings | Retry, check content isn't too large |
storage_error | 500 | Storage operation failed | Retry with backoff |
service_unavailable | 503 | Temporary maintenance | Check trixdb.com/status |
Error Handling Examples
Here's how to handle errors properly in different languages:
import { Trix, TrixError, RateLimitError, ValidationError } from '@trixdb/client';
const trix = new Trix({ apiKey: process.env.TRIX_API_KEY });
async function createMemory(content: string) {
try {
const memory = await trix.memories.create({ content });
return memory;
} catch (error) {
if (error instanceof RateLimitError) {
// Rate limited - wait and retry
console.log(`Rate limited. Retry after ${error.retryAfter}s`);
await sleep(error.retryAfter * 1000);
return createMemory(content); // Retry
}
if (error instanceof ValidationError) {
// Validation failed - log field errors
console.error('Validation failed:', error.fields);
throw error; // Don't retry
}
if (error instanceof TrixError) {
// Other API error
console.error(`API Error [${error.code}]: ${error.message}`);
console.error(`Request ID: ${error.requestId}`);
if (error.statusCode >= 500) {
// Server error - safe to retry
await sleep(1000);
return createMemory(content);
}
throw error;
}
throw error;
}
}
function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}Validation Error Details
Validation errors (HTTP 422) include detailed information about which fields failed and why:
{
"error": {
"code": "validation_error",
"message": "Request validation failed",
"details": {
"fields": {
"content": {
"code": "required",
"message": "Content is required"
},
"priority": {
"code": "invalid_range",
"message": "Priority must be between 0 and 10",
"received": 15,
"min": 0,
"max": 10
},
"tags": {
"code": "invalid_type",
"message": "Tags must be an array of strings",
"received": "string"
}
}
},
"request_id": "req_validation_abc123"
}
}Handle validation errors by checking each field:
if (error instanceof ValidationError) {
for (const [field, details] of Object.entries(error.fields)) {
switch (details.code) {
case 'required':
console.log(`Missing required field: ${field}`);
break;
case 'invalid_range':
console.log(`${field} must be between ${details.min} and ${details.max}`);
break;
case 'invalid_type':
console.log(`${field} has wrong type, got ${details.received}`);
break;
default:
console.log(`${field}: ${details.message}`);
}
}
}Rate Limit Errors
Rate limit errors include headers and body data to help you implement proper retry logic:
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
X-RateLimit-Limit: 300
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1705312800
Retry-After: 30
{
"error": {
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded. Please retry after 30 seconds.",
"details": {
"limit": 300,
"remaining": 0,
"reset": 1705312800,
"retry_after": 30,
"window": 60
},
"request_id": "req_rate_xyz789"
}
}Always respect the Retry-After header. Making requests before
this time may result in longer rate limit windows.
See our Rate Limits guide for best practices on handling and avoiding rate limits.
Retry Strategy
Use exponential backoff with jitter for retrying failed requests:
interface RetryConfig {
maxRetries: number;
baseDelay: number;
maxDelay: number;
retryableErrors: string[];
}
const defaultConfig: RetryConfig = {
maxRetries: 3,
baseDelay: 1000,
maxDelay: 30000,
retryableErrors: [
'rate_limit_exceeded',
'internal_error',
'storage_error',
'service_unavailable'
]
};
async function withRetry<T>(
fn: () => Promise<T>,
config = defaultConfig
): Promise<T> {
let lastError: Error;
for (let attempt = 0; attempt < config.maxRetries; attempt++) {
try {
return await fn();
} catch (error) {
lastError = error as Error;
if (error instanceof TrixError) {
if (!config.retryableErrors.includes(error.code)) {
throw error;
}
const retryAfter = error.details?.retry_after;
if (retryAfter) {
await sleep(retryAfter * 1000);
continue;
}
}
const delay = Math.min(
config.baseDelay * Math.pow(2, attempt) + Math.random() * 1000,
config.maxDelay
);
console.log(`Retry attempt ${attempt + 1} in ${delay}ms`);
await sleep(delay);
}
}
throw lastError!;
}SDK Built-in Retry: The official SDKs include automatic retry
logic. Enable it with { retry: { enabled: true } } in your
client configuration.
Debugging Tips
Log Request IDs
Always log request_id from errors. Include it when contacting support.
Enable Debug Mode
Set TRIX_DEBUG=true to see full request/response details.
Use trix doctor
Run trix doctor to diagnose connection and auth issues.
Check Status Page
Visit trixdb.com/status for service health.
# Run diagnostics
trix doctor
# Enable verbose logging
TRIX_DEBUG=true trix recall "test query"
# Check a specific request
curl -v -H "Authorization: Bearer $TRIX_API_KEY" \
https://api.trixdb.com/v1/memories/mem_abc123Getting Help
If you're encountering persistent errors:
- Check the Support page for troubleshooting guides
- Search the community forum for similar issues
- Include the
request_idand full error response when asking for help - For urgent issues, email [email protected]
Enterprise plans include priority support with faster response times. Learn more about Enterprise support.