Skip to main content

Error Codes Reference

This document provides a complete reference for HTTP status codes and error responses returned by ekoDB's REST API. Understanding these errors helps you handle failures gracefully and troubleshoot issues efficiently.

Error Response Format

ekoDB uses two error response formats depending on the endpoint:

Standard Format (Most Endpoints)

{
"error": "Human-readable error description"
}

Authentication/Rate Limit Format

{
"code": 401,
"message": "Human-readable error description"
}

HTTP Status Codes

Success Codes (2xx)

CodeNameDescription
200OKRequest succeeded. Response body contains requested data.
201CreatedResource successfully created (documents, collections, indexes).
207Multi-StatusBatch operation completed with mixed results. Check individual item statuses.

Client Error Codes (4xx)

400 Bad Request

The request was malformed or contains invalid data.

Common Causes:

  • Invalid JSON syntax in request body
  • Missing required fields
  • Invalid field types or values
  • Malformed query expressions
  • Invalid filter operators
  • Collection name validation failed

Example Response:

{
"error": "Invalid JSON: expected value at line 1 column 15"
}

Troubleshooting:

  1. Validate your JSON syntax using a JSON linter
  2. Ensure all required fields are present
  3. Verify filter expressions use correct type values (Condition, Logical)
  4. Check operator names are spelled correctly (Eq, Gt, Lt, Gte, Lte, Ne)

401 Unauthorized

Authentication is required or credentials are invalid.

Common Causes:

  • Missing Authorization header
  • Expired JWT token (default: 1-hour lifetime)
  • Invalid API key
  • Malformed bearer token

Example Response:

{
"code": 401,
"message": "Invalid or expired token"
}

Troubleshooting:

  1. Ensure the Authorization: Bearer {TOKEN} header is present
  2. Generate a fresh token if the current one has expired
  3. Verify your API key is valid and has not been revoked
  4. Check for typos in the bearer token

Token Refresh Example:

curl -X POST https://{EKODB_API_URL}/api/auth/token \
-H "Content-Type: application/json" \
-d '{"api_key": "YOUR_API_KEY"}'

402 Payment Required

Usage limits exceeded for AI/Chat features.

Common Causes:

  • Chat API usage quota exceeded
  • AI token limits reached
  • Billing limits for AI features

Example Response:

{
"error": "Usage limit exceeded for chat operations"
}

Troubleshooting:

  1. Check your current usage in the ekoDB dashboard
  2. Upgrade your plan for higher AI/Chat limits
  3. Optimize chat prompts to reduce token usage

403 Forbidden

The authenticated user lacks permission for the requested operation.

Common Causes:

  • Attempting to access a collection without permission
  • API key lacks required scope
  • Collection-level access restrictions (writable_fields enforcement)
  • Admin-only operation attempted with non-admin key

Example Response:

{
"error": "Access denied: cannot modify fields: email, role"
}

Troubleshooting:

  1. Verify your API key has the required permissions
  2. Check collection permission settings
  3. Contact your administrator if you need elevated access
  4. Review collection_permissions on your API key

404 Not Found

The requested resource does not exist.

Common Causes:

  • Collection name is misspelled
  • Document ID does not exist
  • Endpoint URL is incorrect
  • Resource was deleted

Example Response:

{
"error": "Record not found"
}

Troubleshooting:

  1. Double-check the collection name (case-sensitive)
  2. Verify the document ID exists before updating/deleting
  3. Ensure the endpoint URL is correct
  4. List collections to see available resources

429 Too Many Requests

Rate limit exceeded. The client has sent too many requests in a given time window.

Example Response:

{
"code": 429,
"message": "Rate limit exceeded. Please try again in 60 seconds."
}

Response Headers:

HeaderDescription
Retry-AfterNumber of seconds to wait before retrying

Troubleshooting:

  1. Implement exponential backoff retry logic
  2. Respect the Retry-After header value
  3. Batch multiple operations where possible
  4. Consider upgrading your plan for higher limits

Retry Logic Example (JavaScript):

async function retryableRequest(fn, maxRetries = 3) {
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
return await fn();
} catch (error) {
if (error.status === 429) {
const retryAfter = parseInt(error.headers.get('Retry-After') || '60');
await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
} else {
throw error;
}
}
}
throw new Error('Max retries exceeded');
}

Server Error Codes (5xx)

500 Internal Server Error

An unexpected error occurred on the server.

Example Response:

{
"code": 500,
"message": "Internal Server Error"
}

Troubleshooting:

  1. Retry the request after a brief delay
  2. Check ekoDB status page for ongoing incidents
  3. Contact support if the error persists

503 Service Unavailable

The service is temporarily unavailable.

Common Causes:

  • Ripple (replication) service unavailable
  • Server maintenance
  • Server overload

Example Response:

{
"error": "Service temporarily unavailable"
}

Troubleshooting:

  1. Check ekoDB status page for maintenance windows
  2. Implement retry logic with exponential backoff
  3. Wait a few minutes before retrying

Operation-Specific Errors

Authentication Errors

ScenarioCodeExample Message
Missing API key401"API key is required"
Invalid API key401"Invalid API key provided"
Expired token401"Token has expired"
Malformed token401"Invalid token format"

Collection Errors

ScenarioCodeExample Message
Collection not found404"Collection 'users' not found"
Invalid collection name400"Invalid collection name"
Missing collection name400"Collection name is required"

Document Errors

ScenarioCodeExample Message
Document not found404"Record not found"
Invalid document data400"Invalid document format"
Field permission denied403"Cannot modify fields: email, role"

Batch Operation Errors

Batch operations return 207 Multi-Status when some operations succeed and others fail:

{
"success_count": 8,
"error_count": 2,
"results": [
{"id": "doc1", "status": "success"},
{"id": "doc2", "status": "error", "error": "Validation failed"}
]
}

Transaction Errors

ScenarioCodeExample Message
Transaction not found404"Transaction not found"
Transaction expired400"Transaction has expired"
Invalid isolation level400"Invalid isolation level"

Best Practices

Error Handling Pattern

try {
const result = await client.insert('users', userData);
} catch (error) {
switch (error.status) {
case 400:
console.error('Invalid request:', error.message);
// Fix request data and retry
break;
case 401:
console.error('Authentication failed');
// Refresh token and retry
await refreshToken();
break;
case 403:
console.error('Permission denied:', error.message);
// Check permissions
break;
case 404:
console.error('Resource not found:', error.message);
// Check if collection/document exists
break;
case 429:
console.error('Rate limited, waiting...');
// Wait and retry with backoff
break;
case 500:
case 503:
console.error('Server error, retrying...');
// Retry with exponential backoff
break;
default:
console.error('Unexpected error:', error);
}
}

Implementing Exponential Backoff

import time
import random

def exponential_backoff_retry(func, max_retries=5, base_delay=1):
for attempt in range(max_retries):
try:
return func()
except Exception as e:
if hasattr(e, 'status_code') and e.status_code in [429, 500, 503]:
delay = base_delay * (2 ** attempt) + random.uniform(0, 1)
time.sleep(delay)
else:
raise
raise Exception("Max retries exceeded")

Logging Error Responses

Always log the full error response for debugging:

match client.query("users", filter).await {
Ok(results) => { /* handle success */ }
Err(e) => {
error!(
status = %e.status,
error = %e.message,
endpoint = "query",
collection = "users",
"API request failed"
);
}
}

Getting Help

If you encounter persistent errors:

  1. Check the status page - Verify ekoDB services are operational
  2. Review the documentation - Ensure your request format is correct
  3. Search existing issues - Your error may already have a known solution
  4. Contact support - Include the full error response and request details
Support Resources