Error Codes
Every failed API request returns a JSON error envelope. The code field is a stable string from @timbl/core’s ErrorCodes enum.
{ "code": "VALIDATION_ERROR", "message": "Validation failed", "details": {}, "requestId": "..."}The message is human-readable and may change between releases. The code is stable and covered by semver. Match on code in your client logic, not on message.
All error codes
| Code | HTTP status | When it is thrown |
|---|---|---|
VALIDATION_ERROR | 400 | A field failed validation, or the request body did not match the collection schema |
REGISTRY_ERROR | 500 | The registry could not build or resolve a collection, global, plugin, or field definition |
NOT_FOUND | 404 | A requested resource (collection entry, global, asset) does not exist |
CONFLICT | 409 | A write conflicts with existing data, such as a duplicate slug or unique constraint violation |
UNAUTHORIZED | 401 | The request requires authentication and no valid principal was resolved |
FORBIDDEN | 403 | The principal was resolved but lacks the capability for the requested operation |
ADAPTER_ERROR | 500 | A configured adapter (database, auth, storage, HTTP) failed an operation |
PLUGIN_ERROR | 500 | A plugin threw during setup, hook execution, or route handling |
RUNTIME_ERROR | 500 | A runtime operation failed outside a specific adapter or plugin boundary |
NOT_IMPLEMENTED | 501 | The requested operation is valid but the current adapter does not implement it |
PAYLOAD_TOO_LARGE | 413 | An upload exceeded the configured size limit |
EXPORT_TOO_LARGE | 500 | The content export exceeded the maximum payload size |
INTERNAL_ERROR | 500 | An uncaught error with no specific code |
Using error codes in a client
The @timbl/client SDK throws TimblHttpError on non-2xx responses. Inspect the code property to decide how to react.
import { TimblHttpError } from "@timbl/client";
try { await client.collection("posts").findBySlug("missing");} catch (error) { if (error instanceof TimblHttpError && error.code === "NOT_FOUND") { // render a 404 page } else { throw error; }}The requestId in the error envelope is also available on the thrown error. Include it in bug reports so maintainers can trace the request in logs.
Error envelope shape
The envelope is the same for every endpoint. details is an optional object that carries field-level validation errors or other structured context.
type ErrorEnvelope = { code: ErrorCode; message: string; details?: Record<string, unknown>; requestId: string;};See also
- HTTP API Reference: the endpoints that return these errors
- Client SDK: how
TimblHttpErroris thrown and handled - Field Types: field validation that produces
VALIDATION_ERROR