Skip to content
Try Free →

AskVault API error codes

Last updated: · 5 min read

Error response shape

Every non-2xx response from /v1/* is JSON. Bodies are typically under 1 KB. Average error-handling cost is well under 5 ms on the client side:

{
"detail": "workspace_id is required",
"code": "missing_field",
"request_id": "req_5b45ff_xxx"
}
FieldDescription
detailHuman-readable error message. Log this for debugging. Never show raw to end users.
codeStable machine-readable error code. Use this for branching logic.
request_idUnique ID for this failed request. Include when reporting to support.

4xx: client errors (don't retry)

These mean your request needs fixing. Retrying without changing the request will return the same error.

400 Bad Request

Malformed request body or missing required field. Common variants:

codeCauseFix
missing_fieldA required field is absentAdd the field
invalid_workspace_idworkspace_id is malformedUse the format wt_xxxxxx_xxx from Settings > General
message_too_longmessage exceeds 4,000 charactersTrim or summarize before sending
invalid_jsonBody isn't valid JSONCheck Content-Type: application/json and the body

401 Unauthorized

Missing or invalid API key. The header must be exactly Authorization: Bearer ak_xxx.

codeCauseFix
missing_authNo Authorization headerAdd Authorization: Bearer ak_xxx
malformed_authHeader doesn't match Bearer ak_xxxCheck spelling, no quotes around the key
invalid_keyKey was revoked or never existedGenerate a new key in the dashboard
expired_keyKey expired (Enterprise contracts with TTL)Rotate the key

403 Forbidden

The API key is valid but lacks permission for the requested resource.

codeCauseFix
workspace_access_deniedKey belongs to a different workspace ownerUse a key from the same account
feature_not_in_planEndpoint requires a higher planUpgrade
verification_requiredIdentity verification required for this queryPass verification_token

404 Not Found

The resource doesn't exist.

codeCauseFix
workspace_not_foundworkspace_id doesn't exist or was deletedConfirm the ID in Settings > General
conversation_not_foundconversation_id is invalidOmit it to start a fresh conversation
document_not_foundA document in document_ids doesn't existCheck Knowledge Hub

409 Conflict

The request conflicts with the current state.

codeCauseFix
plan_downgrade_blockedSubscription downgrade isn't allowed mid-cycleCancel current subscription, then re-subscribe
duplicate_request_idIdempotency key already usedUse a fresh request ID

422 Unprocessable Entity

The request parsed but a field violates a constraint.

codeCauseFix
invalid_top_ktop_k is outside 1 to 10Use a value in range
invalid_temperaturetemperature is outside 0.0 to 1.0Use a value in range
invalid_strictnessstrictness is neither "strict" nor "helpful"Use one of the valid values
invalid_audienceaudience array contains tags not configured for the workspaceCheck Knowledge Hub audience tags

429 Too Many Requests

Rate limit exceeded. The response includes Retry-After in seconds.

codeCauseFix
rate_limit_minutePer-minute cap hitWait Retry-After seconds, retry
rate_limit_dayPer-day cap hitWait until midnight UTC, or upgrade
quota_exhaustedMonthly query allowance fully usedUpgrade plan or wait for cycle reset

See rate limits for cap values per plan.

5xx: server errors (retry with backoff)

These mean our infrastructure had a transient problem. Retry with exponential backoff.

500 Internal Server Error

Unexpected server error. Should be rare.

codeCauseFix
internal_errorAn exception slipped throughRetry. If it persists, contact support@askvault.co with request_id
model_provider_errorUpstream LLM provider returned an errorRetry; AskVault's automatic failover usually kicks in within seconds

502 Bad Gateway / 503 Service Unavailable

Temporary infrastructure issue.

codeCauseFix
upstream_timeoutBackend service timed outRetry with backoff
deployingWe're rolling out a new versionRetry after 30 seconds
provider_downAll upstream LLM providers are unavailableRetry; this is rare and usually resolves in minutes

504 Gateway Timeout

Your request took too long. Usually only happens on the synchronous /v1/query endpoint with very long retrieval. Switch to /v1/query/stream for time-sensitive UX.

Retry strategy

A simple, correct retry loop:

import time, requests
from random import uniform
def call_askvault(payload, max_attempts=5):
for attempt in range(max_attempts):
r = requests.post(
"https://api.askvault.co/v1/query",
headers={"Authorization": f"Bearer {API_KEY}"},
json=payload,
timeout=30,
)
if r.status_code == 200:
return r.json()
# 4xx: don't retry except 429
if 400 <= r.status_code < 500 and r.status_code != 429:
raise Exception(f"Client error {r.status_code}: {r.json()['detail']}")
# 429: respect Retry-After
if r.status_code == 429:
time.sleep(int(r.headers.get("Retry-After", 1)))
continue
# 5xx: exponential backoff with jitter
sleep_s = (2 ** attempt) + uniform(0, 1)
time.sleep(sleep_s)
raise Exception("Max attempts exceeded")

Rules of thumb:

  • 4xx other than 429: don't retry. The request is wrong; retrying gives the same error.
  • 429: sleep for Retry-After seconds, then retry.
  • 5xx: exponential backoff with jitter. Max 5 attempts.

Debugging tips

Three habits that make debugging much faster:

  1. Log request_id from every response, including errors. When you contact support, paste the request_id so we can find the exact failure in our logs.
  2. Distinguish 4xx and 5xx in your monitoring. 4xx counts are client bugs; 5xx counts are our problem. Mixing them in the same alert obscures both.
  3. Track the code field, not just the status code. Codes are more granular and stable across status code changes.

Common pitfalls

Treating every 4xx the same. A 401 means "fix auth", a 422 means "fix the request body", a 429 means "wait then retry". Different recovery paths.

Retrying 4xx in a loop. Burns your retry budget and slows everything down. Stop on 4xx (except 429).

Ignoring Retry-After. Retrying immediately after a 429 just gets another 429 and digs you deeper. Sleep for the suggested duration.

Not surfacing failed conversations to humans. A 5xx error shouldn't leave the customer stuck. Either retry transparently or hand off to a human via the escalate_to_human skill on your widget channel.

FAQ

How do I know if my retry was successful?

Same request_id makes the response idempotent if you pass Idempotency-Key: same-value on the retry. Without it, the server treats each retry as a new query (and consumes quota each time).

Are 5xx errors charged against my quota?

No. Failed requests don't count against your monthly query allowance.

What if I'm seeing only 5xx, never 2xx?

Check our status page. If we're up, the issue is your network or DNS. If we're down, watch the status page for the all-clear.

How do I reach support for a stuck error?

Email support@askvault.co with the request_id and the exact error response body. We can find the exact query in our logs and respond within one business day on every paid plan.

Was this page helpful?