Skip to content

Error Codes Reference

The Vysion API uses conventional HTTP response codes to indicate the success or failure of an API request. In general:

  • 2xx codes indicate success
  • 4xx codes indicate an error that failed given the information provided (e.g., a required parameter was omitted, invalid API key, etc.)
  • 5xx codes indicate an error with Vysion’s servers

All API errors follow this consistent response format:

{
"error": {
"code": 400,
"message": "Detailed error description"
}
}
CodeStatusDescription
200OKThe request was successful
CodeStatusDescription
400Bad RequestYour request is invalid. Check parameters and request format
401UnauthorizedYour API key is missing or invalid
403ForbiddenThe requested resource is hidden for administrators only
404Not FoundThe specified resource could not be found
405Method Not AllowedYou tried to access a resource with an invalid HTTP method
406Not AcceptableYou requested a format that isn’t JSON
410GoneThe requested resource has been removed from our servers
418I’m a teapotRFC 2324 - This should not occur in normal operation
422Unprocessable EntityThe request was well-formed but contains semantic errors
429Too Many RequestsYou’re requesting too many resources! Rate limit exceeded
CodeStatusDescription
500Internal Server ErrorWe had a problem with our server. Try again later
503Service UnavailableWe’re temporarily offline for maintenance. Please try again later
{
"error": {
"code": 401,
"message": "API key is required"
}
}
{
"error": {
"code": 422,
"message": "Validation Error",
"detail": [
{
"loc": ["query", "q"],
"msg": "field required",
"type": "value_error.missing"
}
]
}
}
{
"error": {
"code": 429,
"message": "Too Many Requests - Rate limit exceeded. Please slow down your requests."
}
}
{
"error": {
"code": 404,
"message": "Document not found with the specified ID"
}
}
import requests
response = requests.get('https://api.vysion.ai/api/v1/documents',
headers={'X-API-Key': 'your-api-key'})
if response.status_code == 200:
data = response.json()
# Process successful response
elif response.status_code == 401:
print("API key is invalid")
elif response.status_code == 429:
print("Rate limit exceeded - waiting before retry")
else:
print(f"Error {response.status_code}: {response.json()}")

For temporary errors (5xx codes and 429), implement exponential backoff:

import time
import random
def make_request_with_retry(url, headers, max_retries=3):
for attempt in range(max_retries):
response = requests.get(url, headers=headers)
if response.status_code == 200:
return response.json()
elif response.status_code in [429, 500, 502, 503, 504]:
if attempt < max_retries - 1:
wait_time = (2 ** attempt) + random.uniform(0, 1)
time.sleep(wait_time)
continue
# For other errors, don't retry
response.raise_for_status()
raise Exception(f"Max retries exceeded")
import logging
def handle_api_error(response):
error_data = response.json().get('error', {})
logging.error(f"API Error - Code: {error_data.get('code')}, "
f"Message: {error_data.get('message')}")
# Log validation details if present
if 'detail' in error_data:
for detail in error_data['detail']:
logging.error(f"Validation Error - Field: {detail.get('loc')}, "
f"Error: {detail.get('msg')}")

The API uses standardized error messages for common scenarios:

MessageCodeDescription
”Bad Request”400General request format error
”Unauthorized”401Authentication failure
”Forbidden”403Access denied
”Not Found”404Resource doesn’t exist
”Conflict”409Resource conflict
”Unprocessable Entity”422Validation error
”Too Many Requests”429Rate limit exceeded
”Internal Server Error”500Server-side error

Monitor the frequency of different error codes to identify issues:

  • High 4xx rates: May indicate client integration issues
  • High 5xx rates: May indicate server problems
  • 429 errors: Rate limiting - consider reducing request frequency

Configure alerts for:

  • Error rate exceeding normal thresholds
  • Consecutive 5xx errors
  • Authentication failures (potential security issues)