Skip to content

Error Codes

All SandBase API errors return a consistent JSON structure. Use this page to look up any error code and its resolution.

Error Response Format

json
{
  "error": {
    "code": "invalid_api_key",
    "message": "The API key provided is invalid or has been revoked.",
    "type": "authentication_error",
    "param": null,
    "request_id": "req_abc123"
  }
}

Schema Fields

FieldTypeAlways PresentDescription
codestringMachine-readable error code (see tables below)
messagestringHuman-readable explanation with specific details
typestringError category — one of: authentication_error, rate_limit_error, billing_error, invalid_request_error, not_found_error, server_error. Agent-specific errors (run_failed, tool_execution_failed) use server_error type.
paramstring or nullThe parameter that caused the error, or null if not applicable
request_idstringUnique request ID — include this when contacting support

Authentication Errors

CodeHTTPDescriptionFix
invalid_api_key401API key is invalid or revokedVerify key at Console → API Keys. Regenerate if compromised.
missing_api_key401No Authorization header providedAdd header: Authorization: Bearer sk-sb-YOUR_KEY
expired_api_key401API key has expiredGenerate a new key in Console → API Keys
insufficient_permissions403Key lacks permission for this operationCheck key scopes in console; create a new key with required permissions
organization_suspended403Organization account is suspendedContact [email protected] with your request_id

Rate Limiting Errors

CodeHTTPDescriptionFix
rate_limited429Too many requests per minuteRespect Retry-After header; implement exponential backoff with jitter (see Retry Strategy)
concurrent_limit429Too many concurrent requestsReduce parallelism; default is 5 concurrent requests
daily_limit_exceeded429Daily request quota exhaustedWait for daily reset (midnight UTC) or upgrade plan in Console → Billing

Billing Errors

CodeHTTPDescriptionFix
insufficient_balance402Account balance too lowTop up at Console → Billing
payment_required402No payment method on fileAdd payment method at Console → Billing
spend_limit_reached402Spend limit for this period reachedIncrease limit in Console → Billing → Spend Limits

Model Errors

CodeHTTPDescriptionFix
model_not_found404Model doesn't exist or is disabledVerify model name with GET /v1/models; check for typos in vendor/model format
model_overloaded503Model is temporarily at capacityRetry after 5–10s or use a fallback model (see Retry Strategy)
model_deprecated410Model has been deprecatedCheck message field for the suggested replacement model
context_length_exceeded400Input exceeds model's context windowReduce input tokens; check model's context_window via GET /v1/models/{name}
output_length_exceeded400Output hit max_tokens limit before completingIncrease max_tokens parameter or accept truncated output (finish_reason: "length")

Request Errors

CodeHTTPDescriptionFix
invalid_request400Request body doesn't match expected schemaCheck message field for the specific validation error; compare with endpoint docs
invalid_json400Request body is not valid JSONValidate JSON before sending; check for trailing commas, unescaped characters, or encoding issues
invalid_parameter400A parameter value is out of range or wrong typeCheck param field; verify value constraints in API docs
missing_parameter400A required parameter is missingCheck param field for which parameter; see endpoint documentation for required fields
content_too_large413Request payload exceeds 10MB size limitReduce request size; split large inputs into multiple calls
unsupported_media_type415Content-Type not supportedUse Content-Type: application/json
content_policy_violation400Input or output violated content safety policyModify input to comply with usage policies; the message field contains details on what triggered the violation

Resource Errors

CodeHTTPDescriptionFix
not_found404Requested resource does not existVerify the resource ID; it may have been deleted or never existed
already_exists409Resource with this identifier already existsUse a different name/ID, or use the update endpoint to modify the existing resource
resource_archived410Resource has been archivedCreate a new resource; archived resources cannot be restored via API

Agent & Run Errors

CodeHTTPDescriptionFix
agent_not_found404Agent ID does not existVerify with GET /v1/agents; agent may have been archived
agent_not_published400Legacy publication resource is unavailableUse a version-pinned Agent directly with POST /v1/sessions; current Agents have no publish state
run_failed500Agent run encountered an internal errorRetrieve details via GET /v1/sessions/{id}/events — the last event contains the error
run_timeout408Agent run exceeded time limit (default: 5min)Simplify the task, reduce tool chain depth, or increase timeout in agent config
tool_execution_failed502An external tool/API call failed during agent executionCheck GET /v1/sessions/{id}/events for the failed tool call and its error output

Server Errors

CodeHTTPDescriptionFix
internal_error500Unexpected server errorRetry 1–2 times with backoff; if persistent, contact support with request_id
service_unavailable503Service is temporarily downRetry with exponential backoff (see Retry Strategy)
gateway_timeout504Upstream provider timed outRetry or try a different model from the same category

Streaming Errors

When using streaming ("stream": true or SSE endpoints), errors can occur mid-stream. These are delivered as an SSE event:

event: error
data: {"error": {"code": "internal_error", "message": "Stream interrupted", "type": "server_error"}}

Key differences from non-streaming errors:

  • No HTTP status code — the connection was already established with 200
  • Partial data may have been sent — handle gracefully by checking finish_reason
  • Always close the connection after receiving an error event
  • The same code values apply — use the tables above for resolution

Retry Strategy

For transient errors, use exponential backoff with jitter to avoid thundering herd:

wait = min(base_delay × 2^attempt, max_delay) + random(0, base_delay)

Recommended settings:

  • base_delay: 1 second
  • max_delay: 60 seconds
  • max_retries: 5
  • Always add random jitter

The Retry-After header (when present) overrides the calculated wait time — always respect it.

Retryable vs. Non-Retryable Errors

CodeRetryableStrategy
rate_limitedRespect Retry-After header
concurrent_limitBack off and reduce parallelism
model_overloadedWait 5–10s or switch to fallback model
service_unavailableExponential backoff
gateway_timeoutRetry or switch model
internal_error⚠️Retry 1–2 times only; if persistent, it's a real bug
daily_limit_exceededWait for daily reset
run_failedTerminal — inspect session events for cause
run_timeout⚠️May retry with simpler input or higher timeout
content_policy_violationModify input; retrying the same content will fail again
All 400 errorsFix the request; the same input will always fail
All 401/402/403 errorsFix credentials or billing; retrying won't help

See Also