Skip to main content

API Troubleshooting

This guide helps you diagnose and fix common issues when interacting with the Neolens API.


🧾 Common Error Responses​

Below is a summary table of the most frequent HTTP errors and how to resolve them.

HTTP StatusDescriptionTypical CausesRecommended Actions
400 Bad RequestInvalid request syntax or parametersMalformed JSON, missing required fieldsValidate request payload and schema
401 UnauthorizedAuthentication failureMissing/invalid API key or tokenCheck authentication headers and token
403 ForbiddenPermission deniedInsufficient scopes or rolesVerify API key permissions and scopes
404 Not FoundResource does not existWrong endpoint or resource IDConfirm URL and resource identifiers
409 ConflictConflict with current stateDuplicate resource or conflicting dataCheck request data and retry if needed
429 Too Many RequestsRate limit exceededToo many requests in a given timeframeImplement retry logic with exponential backoff
500 Internal Server ErrorServer failureTemporary server issues, edge-case bugsRetry later; contact support with request_id if persistent

πŸ§ͺ Example Error Payloads​

{
"error": {
"code": 401,
"message": "Unauthorized: Invalid API key",
"details": null
}
}
{
"error": {
"code": 429,
"message": "Too Many Requests: Rate limit exceeded",
"retry_after": 60
}
}
{
"error": {
"code": 400,
"message": "Bad Request: Missing required field 'image_data'",
"details": {
"field": "image_data",
"issue": "This field is required."
}
}
}
{
"error": {
"code": 500,
"message": "Internal Server Error: An unexpected condition occurred.",
"request_id": "abc123-xyz789"
}
}

πŸ’‘ If available, always include the request_id when reporting issues β€” this helps the support team trace and diagnose faster.


πŸ§‘β€πŸ’» Handling Errors on the Client Side​

Here are examples of robust error handling in both Python and JavaScript:

Python (requests)

import requests

response = requests.post("https://api.neolens.ai/v1/analyze", json=payload)
if response.status_code != 200:
error = response.json().get("error", {})
print(f"[{response.status_code}] {error.get('message')}")
print("Request ID:", error.get("request_id", "N/A"))

JavaScript (fetch)

fetch("https://api.neolens.ai/v1/analyze", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload)
})
.then(res => res.json().then(data => {
if (!res.ok) {
console.error(`[${res.status}] ${data.error?.message}`);
console.warn("Request ID:", data.error?.request_id || "N/A");
}
}))
.catch(err => console.error("Network error:", err));

πŸ“‹ Understanding Custom Error Codes​

The following table explains optional fields you may find in error responses.

FieldTypeDescription
codeintegerHTTP status code of the error
messagestringHuman-readable description of the error
detailsobjectOptional context on which field or parameter failed
retry_afterinteger(for 429 errors) Seconds to wait before retry
request_idstringUnique identifier for debugging with support

πŸ› οΈ Troubleshooting Tips​

warning

Why do I get 429 Too Many Requests when I’m sending few requests ? Rate limits are enforced per API key and per IP.

Bursts of requests or parallel calls can trigger limits.

Use exponential backoff and monitor usage.

note

How to handle 401 Unauthorized errors ? Verify your API key is valid and included correctly.

Check if the token expired or was revoked.

Confirm you have the necessary scopes.

tip

What to do if 400 Bad Request errors occur ? Double-check JSON syntax and required fields.

Validate parameter types and values.

Review API reference for correct usage.


πŸ§‘β€πŸ’Ό Need Help ?​

If you can’t resolve an issue:

πŸ“§ Contact Neolens support πŸ• Typical response time: within 24 business hours

When reaching out, please include:

  • The full error message and status code
  • The request_id (if available)
  • Timestamp of the request
  • The request payload (or a sample, if sensitive)