Skip to content

Errors

When an API request fails, VisiHub returns an error response with an HTTP status code and a JSON body describing the problem.

{
"error": {
"code": "not_found",
"message": "The requested file does not exist."
}
}
CodeDescription
invalid_requestThe request body is malformed or missing required fields.
invalid_parameterA query parameter or body field has an invalid value.
unsupported_formatThe uploaded file format is not supported.
CodeDescription
unauthorizedNo valid authentication token was provided.
token_expiredThe JWT token has expired. Request a new magic link.
CodeDescription
forbiddenThe authenticated user does not have permission for this action.
CodeDescription
not_foundThe requested resource does not exist.
CodeDescription
conflictThe request conflicts with the current state (e.g., duplicate name).
CodeDescription
file_too_largeThe uploaded file exceeds the maximum allowed size.
CodeDescription
validation_errorThe request was well-formed but contains invalid data. Check the message field for details.
CodeDescription
rate_limitedToo many requests. Check X-RateLimit-Reset header for when to retry.
CodeDescription
internal_errorAn unexpected server error occurred. If this persists, contact support.
const response = await fetch('https://api.visihub.com/v1/files', {
headers: { 'Authorization': `Bearer ${token}` },
});
if (!response.ok) {
const { error } = await response.json();
switch (error.code) {
case 'unauthorized':
case 'token_expired':
// Re-authenticate
break;
case 'rate_limited':
// Wait and retry
const resetAt = response.headers.get('X-RateLimit-Reset');
break;
default:
console.error(`API error: ${error.code}${error.message}`);
}
}