Spectron uses standard HTTP status codes and follows RFC 7807 Problem Details for all error responses.
Error response format
All errors return a JSON body with the following fields:
| Field | Description |
|---|---|
type | A URI identifying the error type. Stable across versions. |
title | A short, human-readable summary of the problem type. |
status | The HTTP status code. |
detail | A human-readable explanation specific to this occurrence. |
instance | The request path that produced the error. |
HTTP status codes
400 Bad Request
The request body or query parameters are invalid. Common causes:
Malformed JSON body
Missing required fields
Invalid field values (e.g. unknown
modefor knowledge query)Scope floor violation (requesting a scope narrower than the key's floor)
401 Unauthorized
No Authorization: Bearer token was provided, or the key is malformed.
403 Forbidden
The API key is valid but does not have permission to perform this operation. Common causes:
Agent key attempting a management operation
Key's scope floor does not include the requested scope
Agent key attempting to persist a reflection (requires supervisor principal)
404 Not Found
The requested resource does not exist.
409 Conflict
A resource with the same identifier already exists, or an idempotency conflict occurred:
Duplicate Context id on create
Same
Idempotency-Keywith a different request body on/factsor/facts/batchDuplicate idempotency request while the first is still in flight
413 Payload Too Large
The uploaded file exceeds the per-Context size limit.
422 Unprocessable Entity
The request is syntactically valid but semantically invalid.
429 Too Many Requests
The Context has exceeded its token budget or rate limit. Applies to LLM-backed paths including /chat, /facts?infer=full, /reflect, and /consolidate — not to read-only cache hits or direct lookups.
500 Internal Server Error
An unexpected error occurred server-side. The detail field contains a request ID for support escalation.
503 Service Unavailable
The server is temporarily unable to handle requests – typically during a SurrealDB connection issue or startup.
SDK exceptions
Python SDK
| Exception | HTTP status | When |
|---|---|---|
SpectronAuthError | 401 | Missing or invalid API key |
SpectronScopeError | 403 | Scope floor or principal rejects the call |
SpectronNotFoundError | 404 | Resource does not exist |
SpectronAPIError | Other non-2xx | Generic API failure (includes 400, 409, 429, 5xx) |
See Errors and retries for the full hierarchy and retry behaviour.
JavaScript SDK
| Error class | HTTP status | When |
|---|---|---|
AuthError | 401 | Missing or invalid API key |
ScopeError | 403 | Scope floor or principal rejection |
NotFoundError | 404 | Resource does not exist |
ValidationError | 400, 422 | Invalid request payload |
RateLimitError | 429 | Token or rate limit exceeded |
ServerError | 500, 503 | Server-side failure |
ConnectionError | — | Network failure or timeout |
Ingestion pipeline errors
Documents that fail during async processing do not return HTTP errors – they set the document status to "failed" and populate the error field:
Poll GET /api/v1/{context_id}/documents/{id} to check document status. See Uploading documents for retry guidance.
MCP error handling
MCP tool failures use a different envelope from REST, but carry the same HTTP status semantics:
Operation failures →
isError: truetool result withstructuredContent.error.status(404, 403, 429, etc.). The JSON-RPC transport returns HTTP 200.Protocol faults → JSON-RPC
error(bad params, unknown tool).
Auth failures and missing Contexts are masked as 401, never 404, so unauthenticated callers cannot enumerate Context ids. See MCP tools.