Error Handling
All NexSpace API errors return a consistent JSON structure with machine-readable codes and agent-friendly recovery hints.Error Format
Common Error Codes
When
retryable is omitted, infer it from the status: 429, 503, 408,
502, and 504 are retryable; other 4xx are not.
Codes you will hit on the headless surfaces
IDEMPOTENCY_KEY_TOO_LONG— the RESTIdempotency-Keymiddleware rejects any key over 255 characters before your handler runs. See Idempotency.API_KEY_REQUIREDon/api/agents/{id}/runs…— the credential authenticated but is org-only (no bound user). Agent runs execute as a user, so every route on that surface refuses. Use a PAT or a user-bound key/OAuth token.SELF_APPROVAL_FORBIDDEN/ALREADY_RESOLVED— fromPOST /api/approvals/{id}/{approve,reject}. See Agent Runs → Approvals.
Errors over MCP
MCP does not use the codes above. Everything on this page is the REST
contract. Over MCP the failure is a JSON-RPC error whose
code is a negative
integer (-32602, -32003, -32009, -32000, …), not one of the
SCREAMING_SNAKE strings — and the HTTP status is 200 even when the call
failed. The exceptions are the ones rejected before dispatch: 401
(authentication), 429 (rate limit), and 404 (unknown stream id). Check
response.error, not the status. See the
MCP error-code table for the authoritative list.- Protocol errors (unknown tool, bad params, insufficient scope) come back as
a JSON-RPC
errorobject. Theerror.datacarriessuggestionandretryable, mirroring the REST contract. - Execution failures (the tool ran but failed) come back as a normal
tools/callresult withisError: true. Thecontent[].textpayload includes the failure message followed by aSuggestion:line so the calling model can self-correct.
Best Practices
- Check
retryable— iftrue, retry with exponential backoff; iffalse, reformulate the request instead of retrying - Read
suggestion— it tells agents exactly how to fix the issue - Log
requestId— include it when you email admin@nexspace365.com - Handle
codeprogrammatically — don’t parsemessagestrings

