Skip to main content

Error Handling

The Torvus Security API uses conventional HTTP status codes and returns detailed error information in JSON format.


Error Response Format

All errors return a consistent JSON structure:

{
"error": {
"code": "vault_not_found",
"message": "The requested vault could not be found",
"details": {
"vault_id": "vault_abc123xyz"
},
"request_id": "req_xyz789abc",
"timestamp": "2025-10-08T14:00:00Z"
}
}

HTTP Status Codes

Status CodeMeaningWhen It Occurs
200OKSuccessful GET/PATCH request
201CreatedSuccessful POST (resource created)
204No ContentSuccessful DELETE
400Bad RequestInvalid request parameters
401UnauthorizedMissing or invalid API key
403ForbiddenInsufficient permissions
404Not FoundResource doesn't exist
422Unprocessable EntityValidation failed
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer error
503Service UnavailableTemporary outage

Common Error Codes

Authentication Errors (401)

Error CodeDescriptionSolution
invalid_api_keyAPI key is invalid or expiredCheck API key in dashboard
api_key_missingAuthorization header missingInclude Authorization: Bearer KEY
api_key_revokedAPI key has been revokedGenerate new API key

Permission Errors (403)

Error CodeDescriptionSolution
insufficient_permissionsYou lack permission for this actionCheck your role/permissions
vault_access_deniedNo access to this vaultVerify vault ownership
plan_limit_exceededFeature not available on your planUpgrade plan

Resource Errors (404)

Error CodeDescriptionSolution
vault_not_foundVault doesn't existCheck vault ID
document_not_foundDocument doesn't existCheck document ID
recipient_not_foundRecipient doesn't existCheck recipient ID

Validation Errors (422)

Error CodeDescriptionSolution
invalid_vault_nameVault name invalidUse 1-100 characters
invalid_emailEmail format invalidCheck email syntax
vault_already_releasedCannot modify released vaultVault is immutable after release
missing_required_fieldRequired field missingCheck API documentation

Error Handling Best Practices

1. Check Status Code First

const response = await fetch('/api/v1/vaults', {
headers: { 'Authorization': `Bearer ${apiKey}` }
});

if (!response.ok) {
const error = await response.json();
console.error(`Error ${response.status}:`, error.error.message);
}

2. Handle Specific Error Codes

const error = await response.json();

switch (error.error.code) {
case 'vault_not_found':
// Handle missing vault
break;
case 'rate_limit_exceeded':
// Implement retry with backoff
break;
case 'invalid_api_key':
// Prompt for new API key
break;
default:
// Generic error handling
}

3. Log Request IDs

Always log request_id from errors for support:

console.error(`Request ${error.error.request_id} failed:`, error.error.message);

4. Implement Retry Logic

async function retryableRequest(url, options, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
const response = await fetch(url, options);

if (response.ok) {
return response;
}

// Don't retry client errors (4xx)
if (response.status >= 400 && response.status < 500) {
throw new Error(await response.text());
}

// Retry server errors (5xx)
if (i < maxRetries - 1) {
await new Promise(resolve => setTimeout(resolve, Math.pow(2, i) * 1000));
}
} catch (error) {
if (i === maxRetries - 1) throw error;
}
}
}

Complete Error Code Reference

See individual endpoint documentation for endpoint-specific errors:


Last Updated: October 8, 2025