Error Handling
Learn how to handle API errors gracefully. Hebbrix uses standard HTTP status codes and returns detailed error messages to help you debug issues.
Error Response Format
The HTTP status is authoritative. Application HTTP exceptions normally use the following envelope; validation, rate-limit and legacy responses can carry additional or different fields. Do not require every optional field to be present.
{
"error": {
"message": "Invalid request",
"type": "http_exception",
"status_code": 400,
"request_id": "req_abc123xyz"
}
}| Field | Type | Description |
|---|---|---|
| code | string | Optional, operation-specific code; not present in every error |
| message | string | Description or structured operation-specific detail; not always a string |
| type | string | Error category (validation_error, auth_error, etc.) |
| param | string? | Parameter that caused the error (if applicable) |
| status_code | integer | HTTP status code when included; the HTTP response status is authoritative |
| request_id | string | Unique request ID for debugging |
Error response schema
Applications must tolerate operation-specific error details. Most application errors use a structured error object:
{
"error": {
"type": "...",
"message": "...",
"status_code": 400
}
}Request-validation failures raised by FastAPI (HTTP 422) use theerror.details array under a validation_error object. Entries contain sanitized field locations, types and messages, not rejected input values. Some upstream or legacy errors have different shapes; always check the HTTP status first:
{
"error": {
"type": "validation_error",
"message": "Request validation failed",
"details": [
{
"loc": ["body", "content"],
"msg": "Field required",
"type": "missing"
}
]
}
}Common status codes
| Field | Type | Description |
|---|---|---|
| 400 | status | Bad request (malformed body, or a destructive-action confirmation mismatch) |
| 401 | status | Authentication failed (missing, invalid, or revoked API key) |
| 403 | status | Forbidden (insufficient permission, or feature not available on your tier) |
| 402 | status | Your plan's credits or usage limit is exhausted for this operation (see Billing) |
| 404 | status | Resource not found, including a path no endpoint serves (for example OpenAI's Responses API path), a collection_id that is not yours, and a connector name the API does not support |
| 422 | status | Request validation failed (see the error.details array) |
| 424 | status | A call made with your own provider key (BYOK) failed at that provider. The body names the provider, upstream_status and upstream_error (the provider's own code, param and message), so a key problem can be told from a request problem. Hebbrix never retries it on a platform key |
| 428 | status | A delete wider than one end user, agent or run (every user of a collection, or every collection) needs X-Hebbrix-Confirm-Destructive: all-memories |
| 429 | status | Rate limited; honor Retry-After and retry |
| 501 | status | A connector or sign-in provider that is not enabled in this environment (for example Slack) |
| 500/502/503/504 | status | Server or dependency failure; retry only with the same Idempotency-Key and exponential backoff, honoring Retry-After when present |
Response headers & observability
Every response carries tracing headers, whether it succeeds or fails. Capture these so support can trace a request end-to-end, and so retries stay safe.
| Field | Type | Description |
|---|---|---|
| X-Request-ID | Response | A unique UUID attached to every response (success or error). Include it when reporting an issue so it can be traced in our logs. |
| X-Process-Time | Response | Server processing time, in milliseconds, emitted on every response. |
| Idempotency-Key | Request | Send a 1–255 character opaque key on a mutating POST/PUT/PATCH/DELETE. Generic response replays are scoped to the authenticated actor and exact request fingerprint for 24 hours; canonical memory and correction keys are bound to normalized request semantics in the durable PostgreSQL outbox for that record's lifecycle. |
| X-Idempotent-Replay | Response | Set to true for byte-exact response-cache replays. Canonical memory and correction writes use PostgreSQL/outbox replay instead and return the same logical resource without this header. |
| Retry-After | Response | On a retryable 429, 503, or in-progress idempotency 409, the number of seconds to wait before retrying. |
| X-RateLimit-Limit | Response | On every authenticated response, the account's per-minute request limit; see Rate limits. |
Idempotent retries
Attach an Idempotency-Key to any write request. Most operations retain a successful response for 24 hours, replay it byte-for-byte with X-Idempotent-Replay: true, and return 409 for a changed request fingerprint or an identical request still in progress. Canonical memory, batch, process, and correction writes use a PostgreSQL transactional-outbox contract: the same key and normalized request return the same logical resource, while readiness may advance from 202 processing to 201 completed; these logical replays do not emit X-Idempotent-Replay. A changed normalized request always returns deterministic 409, concurrent writers are serialized, and exactly one logical write commits. Failed and rate-limited response-cache operations are released for a safe same-key retry. Batch endpoints remain atomic at the durable boundary and preserve their per-item envelope; outbound webhooks carry a separate delivery key.
POST /v1/collections HTTP/1.1
Authorization: Bearer mem_sk_...
Idempotency-Key: 9f1c2b6e-7a3d-4e51-9c08-2b5d8e4a1f60
Content-Type: application/json
{"name":"Support knowledge"}
# A retry of the exact same request returns the first response:
HTTP/1.1 201 Created
X-Request-ID: 3f9a0c1d-8e2b-4a77-bd31-6c2f9e0a4b15
X-Process-Time: 0.42ms
X-Idempotent-Replay: trueRate limits
Three independent limits apply. Every 429 says which one rejected the request in the X-RateLimit-Scope header and in error.scope, with Retry-After in seconds.
| Plan | Account limit (all endpoints, per minute) | Endpoint multiplier | /search/reason | /search, /chat/ask, /memories/process, GET /collections |
|---|---|---|---|---|
| Free | 300 | 1x | 10 / min | 60 / min |
| Starter | 1,200 | 5x | 50 / min | 300 / min |
| Pro | 6,000 | 20x | 200 / min | 1,200 / min |
| Scale | 30,000 | 33.3x | 333 / min | 2,000 / min |
| Enterprise | 60,000 | 50x | 500 / min | 3,000 / min |
- Account limit (
scope: account): every authenticated request of the account counts, whatever the endpoint. - Endpoint limits (
scope: endpoint): each data endpoint has a base limit on the Free plan; paid plans get the base times the plan's multiplier, never above the account limit. Signup, login, password reset, MFA, billing and data-export limits are the same on every plan. - Edge limits per IP address, before the API: 20,000 requests per minute for requests carrying a Hebbrix API key (
scope: ip_api_key), 400 per minute without one (scope: ip). One backend serving many users from a few IP addresses is not throttled by its IP.
| Field | Type | Description |
|---|---|---|
| X-RateLimit-Limit / -Remaining / -Reset | every authenticated response | The account limit, what is left of it in the current minute, and when it resets (Unix seconds) |
| X-RateLimit-Endpoint-Limit / -Window | endpoint-limited responses and 429 | This endpoint's limit for your plan and its window in seconds, on responses from an endpoint that has its own limit |
| X-RateLimit-Scope | 429 | Which limit applied: account, endpoint, ip or ip_api_key |
| Retry-After | 429 | Seconds until a request in that scope will be accepted again |
The limits in force for each plan are also returned by GET /v1/slo under configured_rate_limits.plans. Request limits and monthly credits are separate controls; see credit costs.
HTTP Status Codes
400 Bad Request
The request was malformed or missing required parameters.
- Missing required fields
- Invalid JSON body
- Invalid parameter types
401 Unauthorized
Authentication failed or API key is invalid.
- Missing API key
- Invalid API key format
- Revoked API key
402 Payment Required
The account is out of operation credits for this billing period.
- Credits exhausted on Free
- Credits exhausted on a paid plan without overage billing
- Overage spend cap reached
403 Forbidden
The API key doesn't have permission for this action.
- Insufficient permissions
- Resource belongs to another user
- Feature not available on tier
404 Not Found
The requested resource doesn't exist.
- Invalid ID
- Resource was deleted
- Typo in endpoint URL
- A connector name the API does not support (/v1/integrations/{name}/...)
429 Too Many Requests
Rate limit exceeded. Slow down your requests.
- Account limit per minute
- Endpoint limit per minute
- Edge limit per IP address
500 Internal Server Error
Something went wrong on our end. Retry the request.
- Temporary system issue
- Database error
Error Codes
Operation-specific and legacy errors may use the following codes. They are not a mandatory global enumeration; inspect the status, type and documented operation detail even when error.code is absent:
| Field | Type | Description |
|---|---|---|
| invalid_api_key | code | The API key provided is invalid or expired |
| missing_api_key | code | No API key was provided in the request |
| invalid_request | code | The request body is malformed or missing fields |
| validation_error | code | A parameter failed validation rules |
| resource_not_found | code | The requested resource doesn't exist |
| collection_not_found | code | The specified collection doesn't exist |
| rate_limit_exceeded | code | Too many requests in the time window |
| credits_exhausted | type | HTTP 402: no operation credits are left this billing period and overage billing is off or at its cap (error.credits reports used, total and remaining; see Billing) |
| quota_exceeded | code | Monthly credit quota has been exceeded |
| document_too_large | code | Uploaded file exceeds size limit |
| unsupported_format | code | File format is not supported |
| permission_denied | code | The API key lacks required permissions |
| feature_not_available | code | Feature requires a higher tier (returned as 403; payload includes required_tier, upgrade_url, pricing_url) |
| internal_error | code | An unexpected server error occurred |
403 feature_not_available payload
When a tier-gated feature is called from a tier that doesn't include it, the backend returns HTTP 403 with the structured payload below (emitted by tier_features.get_upgrade_message):
{
"error": "feature_not_available",
"feature": "knowledge_graph",
"feature_name": "Knowledge Graph",
"message": "This graph operation requires Pro plan or higher. Basic graph reads and paid graph features have different access rules; see the knowledge-graph guide.",
"current_tier": {
"name": "free",
"display_name": "Free"
},
"required_tier": {
"name": "pro",
"display_name": "Pro",
"price": "$99/month",
"credits": "200K/month"
},
"upgrade_url": "https://app.hebbrix.com/dashboard/billing",
"pricing_url": "https://app.hebbrix.com/pricing"
}Handling Errors
Python
import asyncio
from hebbrix import MemoryClient
from hebbrix import (
HebbrixError,
AuthenticationError,
RateLimitError,
ValidationError,
NotFoundError,
)
async def main():
async with MemoryClient(api_key="mem_sk_...") as client:
try:
memory = await client.memories.create(
collection_id="YOUR_COLLECTION_ID",
content="Test memory",
infer=False,
)
except AuthenticationError as e:
# Invalid or missing API key
print(f"Auth error: {e}")
except RateLimitError as e:
# Too many requests; backend returned 429
print(f"Rate limited: {e}")
except ValidationError as e:
# 422: request body/params failed backend validation
print(f"Validation error: {e}")
except NotFoundError as e:
# 404: the collection or memory doesn't exist
print(f"Not found: {e}")
except HebbrixError as e:
# Catch-all for any other API error (5xx, etc.)
print(f"API error: {e}")
asyncio.run(main())TypeScript
import {
MemoryClient,
HebbrixError,
AuthenticationError,
RateLimitError,
ValidationError,
NotFoundError,
} from 'hebbrix';
const client = new MemoryClient({ apiKey: 'mem_sk_...' });
try {
await client.memories.create({
collection_id: 'YOUR_COLLECTION_ID',
content: 'Test memory',
infer: false,
});
} catch (error) {
if (error instanceof AuthenticationError) {
// Invalid or missing API key
console.error('Auth error:', error.message);
} else if (error instanceof RateLimitError) {
// Too many requests
console.error('Rate limited:', error.message);
// Wait a bit and retry
} else if (error instanceof ValidationError) {
// 422: backend rejected the request body
console.error('Validation error:', error.message);
} else if (error instanceof NotFoundError) {
// 404: resource doesn't exist
console.error('Not found:', error.message);
} else if (error instanceof HebbrixError) {
// Catch-all for other API errors
console.error(`API error [${error.status}]: ${error.message}`);
console.error(`Request ID: ${error.requestId}`);
} else {
throw error; // Re-throw unknown errors
}
}Rate Limit Handling
When you hit rate limits, the response includes headers to help you retry appropriately:
HTTP/1.1 429 Too Many Requests
Retry-After: 42
X-RateLimit-Scope: endpoint
X-RateLimit-Endpoint-Limit: 500
X-RateLimit-Endpoint-Window: 60
X-RateLimit-Limit: 60000
X-RateLimit-Remaining: 59120
{
"error": {
"type": "rate_limit_exceeded",
"scope": "endpoint",
"message": "This endpoint allows 500 requests per minute on the enterprise plan. Retry after 42 s. The account-wide limit is separate and is reported in X-RateLimit-Limit.",
"limit_amount": 500,
"window_seconds": 60,
"plan": "enterprise",
"retry_after": 42,
"docs": "https://www.hebbrix.com/docs/errors#rate-limits"
}
}Implementing Exponential Backoff
import asyncio
import random
from hebbrix import MemoryClient
from hebbrix import RateLimitError, HebbrixError
async def create_with_retry(client: MemoryClient, max_retries: int = 5):
"""Retry with exponential backoff + jitter on 429 / 5xx."""
for attempt in range(max_retries):
try:
return await client.memories.create(
collection_id="YOUR_COLLECTION_ID", content="Test", infer=False
)
except RateLimitError:
if attempt == max_retries - 1:
raise
sleep = (2 ** attempt) + random.uniform(0, 1)
print(f"Rate limited, retry in {sleep:.1f}s")
await asyncio.sleep(sleep)
except HebbrixError:
if attempt == max_retries - 1:
raise
sleep = (2 ** attempt) + random.uniform(0, 1)
print(f"Transient error, retry in {sleep:.1f}s")
await asyncio.sleep(sleep)
async def main():
async with MemoryClient(api_key="mem_sk_...") as client:
await create_with_retry(client)
asyncio.run(main())Best Practices
- Always Handle Errors - Wrap API calls in try/catch and handle specific error types appropriately.
- Implement Retries - Use exponential backoff for rate limits (429) and server errors (5xx).
- Log Request IDs - Save the request_id for debugging. Include it when contacting support.
- Don't Expose Errors - Don't show raw API errors to end users. Display friendly messages instead.